1
0
Просмотр исходного кода

[bridges] fix invalid use of empty() for php < 5.5

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
Pierre Mazière 7 лет назад
Родитель
Сommit
948bd9ae31

+ 4 - 2
bridges/CNETBridge.php

@@ -37,7 +37,8 @@ class CNETBridge extends BridgeAbstract {
             return $article_html;
         }
 
-        $pageUrl = $this->uri.(empty($this->getInput('topic')) ? '' : 'topics/'.$this->getInput('topic').'/');
+        $topic=$this->getInput('topic');
+        $pageUrl = $this->uri.(empty($topic) ? '' : 'topics/'.$topic.'/');
         $html = $this->getSimpleHTMLDOM($pageUrl) or $this->returnServerError('Could not request CNET: '.$pageUrl);
         $limit = 0;
 
@@ -69,7 +70,8 @@ class CNETBridge extends BridgeAbstract {
     }
 
     public function getName() {
-        return 'CNET News Bridge'.(empty($this->getInput('topic')) ? '' : ' - '.$this->getInput('topic'));
+        $topic=$this->getInput('topic');
+        return 'CNET News Bridge'.(empty($topic) ? '' : ' - '.$topic);
     }
 
     public function getCacheDuration() {

+ 3 - 2
bridges/CryptomeBridge.php

@@ -18,8 +18,9 @@ class CryptomeBridge extends BridgeAbstract{
     public function collectData(){
         $html = $this->getSimpleHTMLDOM($this->uri)
             or $this->returnServerError('Could not request Cryptome.');
-        if (!empty($this->getInput('n'))) {   /* number of documents */
-            $num = min($this->getInput('n'), 20);
+        $number=$this->getInput('n');
+        if (!empty($number)) {   /* number of documents */
+            $num = min($number, 20);
         }
 
 

+ 3 - 2
bridges/DauphineLibereBridge.php

@@ -41,8 +41,9 @@ class DauphineLibereBridge extends BridgeAbstract {
 
 		$context = stream_context_create($opts);
 
-		if (empty($this->getInput('u'))) {
-            $html = $this->getSimpleHTMLDOM($this->uri.$this->getInput('u').'/rss')
+        $category=$this->getInput('u');
+		if (empty($category)) {
+            $html = $this->getSimpleHTMLDOM($this->uri.$category.'/rss')
                 or $this->returnServerError('Could not request DauphineLibere.');
 		} else {
             $html = $this->getSimpleHTMLDOM($this->uri.'rss')

+ 2 - 2
bridges/FourchanBridge.php

@@ -35,8 +35,8 @@ class FourchanBridge extends BridgeAbstract{
 		$item['timestamp'] = $element->find('span.dateTime', 0)->getAttribute('data-utc');
 		$item['author'] = $element->find('span.name', 0)->plaintext;
 
-
-		if(!empty($element->find('.file', 0) ) ) {
+        $file=$element->find('.file', 0);
+		if(!empty($file) ) {
 			$item['image'] = $element->find('.file a', 0)->href;
 			$item['imageThumb'] = $element->find('.file img', 0)->src;
 			if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== FALSE)

+ 2 - 1
bridges/WallpaperStopBridge.php

@@ -63,7 +63,8 @@ class WallpaperStopBridge extends BridgeAbstract {
     }
 
     public function getName(){
-        return 'WallpaperStop - '.$this->getInput('c').(!empty($this->getInput('s')) ? ' > '.$this->getInput('s') : '').' ['.$this->getInput('r').']';
+        $subcategory=$this->getInput('s');
+        return 'WallpaperStop - '.$this->getInput('c').(!empty($subcategory) ? ' > '.$subcategory : '').' ['.$this->getInput('r').']';
     }
 
     public function getCacheDuration(){

+ 3 - 2
bridges/WorldOfTanksBridge.php

@@ -31,8 +31,9 @@ class WorldOfTanksBridge extends HttpCachingBridgeAbstract{
     function getURI(){
         $lang = $this->getInput('lang');
         $uri = $this->uri.$lang.'/news/';
-        if(!empty($this->getInput('category'))) {
-            $uri .= 'pc-browser/'.$this->getInput('category')."/";
+        $category=$this->getInput('category');
+        if(!empty($category)) {
+            $uri .= 'pc-browser/'.$category."/";
         }
         return $uri;
     }

+ 1 - 5
bridges/ZoneTelechargementBridge.php

@@ -18,11 +18,7 @@ class ZoneTelechargementBridge extends BridgeAbstract {
             return $string;
         }
 
-        $category = '/';
-        if (!empty($this->getInput('category')))
-            $category = '/'.$this->getInput('category').'/';
-
-        $url = $this->getURI().$category.'rss.xml';
+        $url = $this->getURI().$this->getInput('category').'rss.xml';
         $html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request Zone Telechargement: '.$url);
 
         foreach($html->find('item') as $element) {