From fe23a611b9479723c6c654c3fe4daba9e870cf0c Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 31 Jan 2019 17:43:30 +0100 Subject: Switching Facebook and Rss providers to universal classes --- providers/Rss.php | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'providers/Rss.php') diff --git a/providers/Rss.php b/providers/Rss.php index 4937f57..f303ee8 100644 --- a/providers/Rss.php +++ b/providers/Rss.php @@ -2,31 +2,25 @@ namespace Providers; -require_once('Provider.php'); +require_once('XmlFeed.php'); require_once('Item.php'); -class Rss extends \Providers\Provider { +class Rss extends \Providers\XmlFeed { - private $_feedUrl; - private $_feedXml; - - public function __construct($feed, $options=[]) { - parent::__construct($feed, $options); + protected function _getFeedUrl($feed) { $config = json_decode(file_get_contents('../config/rss.json'), TRUE); if (isset($config[$feed])) { - $this->_feedUrl = $config[$feed]; - } else { - throw new Exception('RSS feed "' . $feed . '" undefined'); + return $config[$feed]; } + return NULL; } protected function _getCachePath() { return '../cache/rss.%s'; } - protected function _fetchItems() { - $this->_feedXml = new \SimpleXMLElement($this->_feedUrl, 0, TRUE); - $feedItems = $this->_feedXml->channel->item ?: $this->_feedXml->entry; + protected function _parseFeedContent($feed) { + $feedItems = $feed->channel->item ?: $feed->entry; $items = []; foreach ($feedItems as $item) { $items[] = $item->asXML(); @@ -38,7 +32,6 @@ class Rss extends \Providers\Provider { $items = []; foreach ($content as $contentString) { $itemString = str_replace(['content:encoded>', '', '<', 'ID = strval($item->id ?: $item->guid); @@ -52,14 +45,6 @@ class Rss extends \Providers\Provider { return $items; } - protected function _spamFilter($content) { - return $content; - } - - protected function _sortContent($content) { - return $content; - } - public function title() { $cacheFile = sprintf($this->_getCachePath() . '.title', $this->_feed); if (!file_exists($cacheFile)) { -- cgit v1.2.3