diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ActionInterface.php | 2 | ||||
-rw-r--r-- | lib/BridgeCard.php | 2 | ||||
-rw-r--r-- | lib/BridgeList.php | 2 | ||||
-rw-r--r-- | lib/FeedExpander.php | 48 | ||||
-rw-r--r-- | lib/FeedItem.php | 4 |
5 files changed, 24 insertions, 34 deletions
diff --git a/lib/ActionInterface.php b/lib/ActionInterface.php index 63088573..c8684d52 100644 --- a/lib/ActionInterface.php +++ b/lib/ActionInterface.php @@ -22,5 +22,5 @@ interface ActionInterface { * * @return void */ - function execute(); + public function execute(); } diff --git a/lib/BridgeCard.php b/lib/BridgeCard.php index befde86a..22520170 100644 --- a/lib/BridgeCard.php +++ b/lib/BridgeCard.php @@ -286,7 +286,7 @@ This bridge is not fetching its content through a secure connection</div>'; * @param bool $isActive Indicates if the bridge is active or not * @return string The bridge card */ - static function displayBridgeCard($bridgeName, $formats, $isActive = true){ + public static function displayBridgeCard($bridgeName, $formats, $isActive = true){ $bridgeFac = new \BridgeFactory(); diff --git a/lib/BridgeList.php b/lib/BridgeList.php index 3b6d832e..c5082e57 100644 --- a/lib/BridgeList.php +++ b/lib/BridgeList.php @@ -194,7 +194,7 @@ EOD; * if enabled. * @return string The home page */ - static function create($showInactive = true) { + public static function create($showInactive = true) { $totalBridges = 0; $totalActiveBridges = 0; diff --git a/lib/FeedExpander.php b/lib/FeedExpander.php index 58d830b7..b84c608a 100644 --- a/lib/FeedExpander.php +++ b/lib/FeedExpander.php @@ -111,14 +111,17 @@ abstract class FeedExpander extends BridgeAbstract { case isset($rssContent->item[0]): Debug::log('Detected RSS 1.0 format'); $this->feedType = self::FEED_TYPE_RSS_1_0; + $this->collectRss1($rssContent, $maxItems); break; case isset($rssContent->channel[0]): Debug::log('Detected RSS 0.9x or 2.0 format'); $this->feedType = self::FEED_TYPE_RSS_2_0; + $this->collectRss2($rssContent, $maxItems); break; case isset($rssContent->entry[0]): Debug::log('Detected ATOM format'); $this->feedType = self::FEED_TYPE_ATOM_1_0; + $this->collectAtom1($rssContent, $maxItems); break; default: Debug::log('Unknown feed format/version'); @@ -126,9 +129,6 @@ abstract class FeedExpander extends BridgeAbstract { break; } - Debug::log('Calling function "collect_' . $this->feedType . '_data"'); - $this->{'collect_' . $this->feedType . '_data'}($rssContent, $maxItems); - return $this; } @@ -145,8 +145,8 @@ abstract class FeedExpander extends BridgeAbstract { * @todo Instead of passing $maxItems to all functions, just add all items * and remove excessive items later. */ - protected function collect_RSS_1_0_data($rssContent, $maxItems){ - $this->load_RSS_2_0_feed_data($rssContent->channel[0]); + protected function collectRss1($rssContent, $maxItems){ + $this->loadRss2Data($rssContent->channel[0]); foreach($rssContent->item as $item) { Debug::log('parsing item ' . var_export($item, true)); $tmp_item = $this->parseItem($item); @@ -170,13 +170,13 @@ abstract class FeedExpander extends BridgeAbstract { * @todo Instead of passing $maxItems to all functions, just add all items * and remove excessive items later. */ - protected function collect_RSS_2_0_data($rssContent, $maxItems){ + protected function collectRss2($rssContent, $maxItems){ $rssContent = $rssContent->channel[0]; Debug::log('RSS content is ===========\n' . var_export($rssContent, true) . '==========='); - $this->load_RSS_2_0_feed_data($rssContent); + $this->loadRss2Data($rssContent); foreach($rssContent->item as $item) { Debug::log('parsing item ' . var_export($item, true)); $tmp_item = $this->parseItem($item); @@ -200,8 +200,8 @@ abstract class FeedExpander extends BridgeAbstract { * @todo Instead of passing $maxItems to all functions, just add all items * and remove excessive items later. */ - protected function collect_ATOM_1_0_data($content, $maxItems){ - $this->load_ATOM_feed_data($content); + protected function collectAtom1($content, $maxItems){ + $this->loadAtomData($content); foreach($content->entry as $item) { Debug::log('parsing item ' . var_export($item, true)); $tmp_item = $this->parseItem($item); @@ -213,16 +213,6 @@ abstract class FeedExpander extends BridgeAbstract { } /** - * Convert RSS 2.0 time to timestamp - * - * @param object $item A feed item - * @return int The timestamp - */ - protected function RSS_2_0_time_to_timestamp($item){ - return DateTime::createFromFormat('D, d M Y H:i:s e', $item->pubDate)->getTimestamp(); - } - - /** * Load RSS 2.0 feed data into RSS-Bridge * * @param object $rssContent The RSS content @@ -230,7 +220,7 @@ abstract class FeedExpander extends BridgeAbstract { * * @todo set title, link, description, language, and so on */ - protected function load_RSS_2_0_feed_data($rssContent){ + protected function loadRss2Data($rssContent){ $this->title = trim((string)$rssContent->title); $this->uri = trim((string)$rssContent->link); @@ -245,7 +235,7 @@ abstract class FeedExpander extends BridgeAbstract { * @param object $content The Atom content * @return void */ - protected function load_ATOM_feed_data($content){ + protected function loadAtomData($content){ $this->title = (string)$content->title; // Find best link (only one, or first of 'alternate') @@ -282,7 +272,7 @@ abstract class FeedExpander extends BridgeAbstract { */ protected function parseATOMItem($feedItem){ // Some ATOM entries also contain RSS 2.0 fields - $item = $this->parseRSS_2_0_Item($feedItem); + $item = $this->parseRss2Item($feedItem); if(isset($feedItem->id)) $item['uri'] = (string)$feedItem->id; if(isset($feedItem->title)) $item['title'] = (string)$feedItem->title; @@ -317,7 +307,7 @@ abstract class FeedExpander extends BridgeAbstract { * @todo To reduce confusion, the RSS-Bridge item should maybe have a class * of its own? */ - protected function parseRSS_0_9_1_Item($feedItem){ + protected function parseRss091Item($feedItem){ $item = array(); if(isset($feedItem->link)) $item['uri'] = (string)$feedItem->link; if(isset($feedItem->title)) $item['title'] = (string)$feedItem->title; @@ -338,9 +328,9 @@ abstract class FeedExpander extends BridgeAbstract { * @todo To reduce confusion, the RSS-Bridge item should maybe have a class * of its own? */ - protected function parseRSS_1_0_Item($feedItem){ + protected function parseRss1Item($feedItem){ // 1.0 adds optional elements around the 0.91 standard - $item = $this->parseRSS_0_9_1_Item($feedItem); + $item = $this->parseRss091Item($feedItem); $namespaces = $feedItem->getNamespaces(true); if(isset($namespaces['dc'])) { @@ -362,9 +352,9 @@ abstract class FeedExpander extends BridgeAbstract { * @todo To reduce confusion, the RSS-Bridge item should maybe have a class * of its own? */ - protected function parseRSS_2_0_Item($feedItem){ + protected function parseRss2Item($feedItem){ // Primary data is compatible to 0.91 with some additional data - $item = $this->parseRSS_0_9_1_Item($feedItem); + $item = $this->parseRss091Item($feedItem); $namespaces = $feedItem->getNamespaces(true); if(isset($namespaces['dc'])) $dc = $feedItem->children($namespaces['dc']); @@ -418,10 +408,10 @@ abstract class FeedExpander extends BridgeAbstract { protected function parseItem($item){ switch($this->feedType) { case self::FEED_TYPE_RSS_1_0: - return $this->parseRSS_1_0_Item($item); + return $this->parseRss1Item($item); break; case self::FEED_TYPE_RSS_2_0: - return $this->parseRSS_2_0_Item($item); + return $this->parseRss2Item($item); break; case self::FEED_TYPE_ATOM_1_0: return $this->parseATOMItem($item); diff --git a/lib/FeedItem.php b/lib/FeedItem.php index 9a435730..8690eb95 100644 --- a/lib/FeedItem.php +++ b/lib/FeedItem.php @@ -483,7 +483,7 @@ class FeedItem { * @param string $name Property name * @param mixed $value Property value */ - function __set($name, $value) { + public function __set($name, $value) { switch($name) { case 'uri': $this->setURI($value); break; case 'title': $this->setTitle($value); break; @@ -506,7 +506,7 @@ class FeedItem { * @param string $name Property name * @return mixed Property value */ - function __get($name) { + public function __get($name) { switch($name) { case 'uri': return $this->getURI(); case 'title': return $this->getTitle(); |