From 95b99d42a4719c3c689091761e071b3a278af590 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 17 Dec 2016 16:39:18 +0100 Subject: [PATCH] bridges: Fix default return values and function scopes getURI and getName should fall back to parent::getURI or parent::getName respectively if it cannot build propper return values. Functions defined by bridges should be made private to prevent confusion with inherited functions --- bridges/AllocineFRBridge.php | 31 +++++++++++++++++---------- bridges/DailymotionBridge.php | 2 +- bridges/FuturaSciencesBridge.php | 8 +++---- bridges/IsoHuntBridge.php | 4 ++++ bridges/LeMondeInformatiqueBridge.php | 6 +++--- bridges/PinterestBridge.php | 2 ++ 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/bridges/AllocineFRBridge.php b/bridges/AllocineFRBridge.php index 7f8c6e8..0c4a048 100644 --- a/bridges/AllocineFRBridge.php +++ b/bridges/AllocineFRBridge.php @@ -23,27 +23,36 @@ class AllocineFRBridge extends BridgeAbstract{ )); public function getURI(){ - switch($this->getInput('category')){ - case 'faux-raccord': - $uri = static::URI.'video/programme-12284/saison-27129/'; - break; - case 'top-5': - $uri = static::URI.'video/programme-12299/saison-29561/'; - break; - case 'tueurs-en-serie': - $uri = static::URI.'video/programme-12286/saison-22938/'; - break; + if(!is_null($this->getInput('category'))){ + + switch($this->getInput('category')){ + case 'faux-raccord': + $uri = static::URI.'video/programme-12284/saison-27129/'; + break; + case 'top-5': + $uri = static::URI.'video/programme-12299/saison-29561/'; + break; + case 'tueurs-en-serie': + $uri = static::URI.'video/programme-12286/saison-22938/'; + break; + } + + return $uri; } - return $uri; + return parent::getURI(); } public function getName(){ + if(!is_null($this->getInput('category'))){ return self::NAME.' : ' .array_search( $this->getInput('category'), self::PARAMETERS[$this->queriedContext]['category']['values'] ); + } + + return parent::getName(); } public function collectData(){ diff --git a/bridges/DailymotionBridge.php b/bridges/DailymotionBridge.php index 50d8c0b..9547bab 100644 --- a/bridges/DailymotionBridge.php +++ b/bridges/DailymotionBridge.php @@ -34,7 +34,7 @@ class DailymotionBridge extends BridgeAbstract{ ) ); - function getMetadata($id) { + protected function getMetadata($id) { $metadata=array(); $html2 = getSimpleHTMLDOM(self::URI.'video/'.$id); if(!$html2){ diff --git a/bridges/FuturaSciencesBridge.php b/bridges/FuturaSciencesBridge.php index af00d5a..5f86497 100644 --- a/bridges/FuturaSciencesBridge.php +++ b/bridges/FuturaSciencesBridge.php @@ -93,7 +93,7 @@ class FuturaSciencesBridge extends FeedExpander { return $item; } - function StripWithDelimiters($string, $start, $end) { + private function StripWithDelimiters($string, $start, $end) { while (strpos($string, $start) !== false) { $section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); @@ -101,7 +101,7 @@ class FuturaSciencesBridge extends FeedExpander { } return $string; } - function StripRecursiveHTMLSection($string, $tag_name, $tag_start) { + private function StripRecursiveHTMLSection($string, $tag_name, $tag_start) { $open_tag = '<'.$tag_name; $close_tag = ''; $close_tag_length = strlen($close_tag); @@ -125,7 +125,7 @@ class FuturaSciencesBridge extends FeedExpander { return $string; } - function ExtractArticleContent($article){ + private function ExtractArticleContent($article){ $contents = $article->find('section[class=module article-text article-text-classic bg-white]', 0)->innertext; foreach (array( @@ -156,7 +156,7 @@ class FuturaSciencesBridge extends FeedExpander { } // Extracts the author from an article or element - function ExtractAuthor($article){ + private function ExtractAuthor($article){ $article_author = $article->find('span.author', 0); if($article_author){ return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext)); diff --git a/bridges/IsoHuntBridge.php b/bridges/IsoHuntBridge.php index a95c85b..8101d32 100644 --- a/bridges/IsoHuntBridge.php +++ b/bridges/IsoHuntBridge.php @@ -122,6 +122,8 @@ class IsoHuntBridge extends BridgeAbstract{ if($category!=='movies') $uri .= '&ihq=' . urlencode($this->getInput('search_name')); break; + + default: parent::getURI(); } return $uri; @@ -155,6 +157,8 @@ class IsoHuntBridge extends BridgeAbstract{ ); $name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . self::NAME; break; + + default: return parent::getName(); } return $name; diff --git a/bridges/LeMondeInformatiqueBridge.php b/bridges/LeMondeInformatiqueBridge.php index f737ed4..de6ac66 100644 --- a/bridges/LeMondeInformatiqueBridge.php +++ b/bridges/LeMondeInformatiqueBridge.php @@ -20,13 +20,13 @@ class LeMondeInformatiqueBridge extends FeedExpander { return $item; } - function StripCDATA($string) { + private function StripCDATA($string) { $string = str_replace('', '', $string); return $string; } - function StripWithDelimiters($string, $start, $end) { + private function StripWithDelimiters($string, $start, $end) { while (strpos($string, $start) !== false) { $section_to_remove = substr($string, strpos($string, $start)); $section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end)); @@ -34,7 +34,7 @@ class LeMondeInformatiqueBridge extends FeedExpander { } return $string; } - function CleanArticle($article_html) { + private function CleanArticle($article_html) { $article_html = $this->StripWithDelimiters($article_html, ''); $article_html = $this->StripWithDelimiters($article_html, '

'); return $article_html; diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index 65c3b60..1d8895e 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -103,6 +103,7 @@ EOD; case 'From search': $uri = self::URI . 'search/?q=' . urlencode($this->getInput('q')); break; + default: return parent::getURI(); } return $uri; } @@ -115,6 +116,7 @@ EOD; case 'From search': $specific = $this->getInput('q'); break; + default: return parent::getName(); } return $specific . ' - ' . self::NAME; }