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
This commit is contained in:
parent
271c71d0ac
commit
95b99d42a4
6 changed files with 34 additions and 19 deletions
|
@ -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(){
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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 = '</'.$tag_name.'>';
|
||||
$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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -20,13 +20,13 @@ class LeMondeInformatiqueBridge extends FeedExpander {
|
|||
return $item;
|
||||
}
|
||||
|
||||
function StripCDATA($string) {
|
||||
private function StripCDATA($string) {
|
||||
$string = str_replace('<![CDATA[', '', $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, '<script', '</script>');
|
||||
$article_html = $this->StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
|
||||
return $article_html;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue