summaryrefslogtreecommitdiff
path: root/providers/Rss.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-01-31 17:43:30 +0100
committeremkael <emkael@tlen.pl>2019-01-31 19:41:51 +0100
commitfe23a611b9479723c6c654c3fe4daba9e870cf0c (patch)
treef1e792b2b42d3f3fd9d83bee290cd75b42131047 /providers/Rss.php
parent5df7a81d952c9aed7c9adadadecdeb84f1e5c264 (diff)
Switching Facebook and Rss providers to universal classes
Diffstat (limited to 'providers/Rss.php')
-rw-r--r--providers/Rss.php29
1 files changed, 7 insertions, 22 deletions
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>', '<dc:', '</dc:', '<media:', '</media:'], ['content>', '<', '</', '<', '</'], $contentString);
- //var_dump($itemString);
$item = new \SimpleXMLElement($itemString);
$itemObject = new Item();
$itemObject->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)) {