diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index d44cba24..2e451e28 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -13,8 +13,7 @@ class ABCTabsBridge extends BridgeAbstract { $table = $html->find('table#myTable', 0)->children(1); - foreach ($table->find('tr') as $tab) - { + foreach ($table->find('tr') as $tab) { $item = array(); $item['author'] = $tab->find('td', 1)->plaintext . ' - ' diff --git a/bridges/AllocineFRBridge.php b/bridges/AllocineFRBridge.php index d5f2b7e3..604199b2 100644 --- a/bridges/AllocineFRBridge.php +++ b/bridges/AllocineFRBridge.php @@ -22,9 +22,9 @@ class AllocineFRBridge extends BridgeAbstract { )); public function getURI(){ - if(!is_null($this->getInput('category'))){ + if(!is_null($this->getInput('category'))) { - switch($this->getInput('category')){ + switch($this->getInput('category')) { case 'faux-raccord': $uri = static::URI . 'video/programme-12284/saison-29841/'; break; @@ -43,7 +43,7 @@ class AllocineFRBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('category'))){ + if(!is_null($this->getInput('category'))) { return self::NAME . ' : ' .array_search( $this->getInput('category'), @@ -64,15 +64,14 @@ class AllocineFRBridge extends BridgeAbstract { self::PARAMETERS[$this->queriedContext]['category']['values'] ); - foreach($html->find('figure.media-meta-fig') as $element){ + foreach($html->find('figure.media-meta-fig') as $element) { $item = array(); $title = $element->find('div.titlebar h3.title a', 0); $content = trim($element->innertext); $figCaption = strpos($content, $category); - if($figCaption !== false) - { + if($figCaption !== false) { $content = str_replace('src="/', 'src="' . static::URI, $content); $content = str_replace('href="/', 'href="' . static::URI, $content); $content = str_replace('src=\'/', 'src=\'' . static::URI, $content); diff --git a/bridges/AmazonBridge.php b/bridges/AmazonBridge.php index d7f77c51..cbc61190 100644 --- a/bridges/AmazonBridge.php +++ b/bridges/AmazonBridge.php @@ -51,7 +51,7 @@ class AmazonBridge extends BridgeAbstract { )); public function getName(){ - if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))){ + if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))) { return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q'); } diff --git a/bridges/AnimeUltimeBridge.php b/bridges/AnimeUltimeBridge.php index caedba1e..6c5427e5 100644 --- a/bridges/AnimeUltimeBridge.php +++ b/bridges/AnimeUltimeBridge.php @@ -120,7 +120,7 @@ class AnimeUltimeBridge extends BridgeAbstract { } public function getName() { - if(!is_null($this->getInput('type'))){ + if(!is_null($this->getInput('type'))) { $typeFilter = array_search( $this->getInput('type'), self::PARAMETERS[$this->queriedContext]['type']['values'] diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php index 09a1ee4d..3d7ae9de 100644 --- a/bridges/Arte7Bridge.php +++ b/bridges/Arte7Bridge.php @@ -44,7 +44,7 @@ class Arte7Bridge extends BridgeAbstract { ); public function collectData(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'Catégorie (Français)': $category = $this->getInput('catfr'); $lang = 'fr'; @@ -58,7 +58,7 @@ class Arte7Bridge extends BridgeAbstract { $url = self::URI . 'guide/' . $lang . '/plus7/' . $category; $input = getContents($url) or die('Could not request ARTE.'); - if(strpos($input, 'categoryVideoSet') !== false){ + if(strpos($input, 'categoryVideoSet') !== false) { $input = explode('categoryVideoSet="', $input); $input = explode('}}', $input[1]); $input = $input[0] . '}}'; diff --git a/bridges/AskfmBridge.php b/bridges/AskfmBridge.php index 4b1597db..e2274618 100644 --- a/bridges/AskfmBridge.php +++ b/bridges/AskfmBridge.php @@ -19,7 +19,7 @@ class AskfmBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Requested username can\'t be found.'); - foreach($html->find('div.streamItem-answer') as $element){ + foreach($html->find('div.streamItem-answer') as $element) { $item = array(); $item['uri'] = self::URI . $element->find('a.streamItemsAge', 0)->href; $question = trim($element->find('h1.streamItemContent-question', 0)->innertext); @@ -38,7 +38,7 @@ class AskfmBridge extends BridgeAbstract { // This probably should be cleaned up, especially for YouTube embeds $visual = $element->find('div.streamItemContent-visual', 0)->innertext; //Fix tracking links, also doesn't work - foreach($element->find('a') as $link){ + foreach($element->find('a') as $link) { if(strpos($link->href, 'l.ask.fm') !== false) { // Too slow @@ -57,7 +57,7 @@ class AskfmBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return self::NAME . ' : ' . $this->getInput('u'); } @@ -65,7 +65,7 @@ class AskfmBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0'; } diff --git a/bridges/BandcampBridge.php b/bridges/BandcampBridge.php index 28e9ba57..0527da03 100644 --- a/bridges/BandcampBridge.php +++ b/bridges/BandcampBridge.php @@ -18,7 +18,7 @@ class BandcampBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('No results for this query.'); - foreach($html->find('li.item') as $release){ + foreach($html->find('li.item') as $release) { $script = $release->find('div.art', 0)->getAttribute('onclick'); $uri = ltrim($script, "return 'url("); $uri = rtrim($uri, "')"); @@ -46,7 +46,7 @@ class BandcampBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('tag'))){ + if(!is_null($this->getInput('tag'))) { return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date'; } @@ -54,7 +54,7 @@ class BandcampBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('tag'))){ + if(!is_null($this->getInput('tag'))) { return $this->getInput('tag') . ' - Bandcamp Tag'; } diff --git a/bridges/BastaBridge.php b/bridges/BastaBridge.php index 11a31ac8..17d3da76 100644 --- a/bridges/BastaBridge.php +++ b/bridges/BastaBridge.php @@ -19,8 +19,8 @@ class BastaBridge extends BridgeAbstract { $limit = 0; - foreach($html->find('item') as $element){ - if($limit < 10){ + foreach($html->find('item') as $element) { + if($limit < 10) { $item = array(); $item['title'] = $element->find('title', 0)->innertext; $item['uri'] = $element->find('guid', 0)->plaintext; diff --git a/bridges/BlaguesDeMerdeBridge.php b/bridges/BlaguesDeMerdeBridge.php index 12814a50..25c018a8 100644 --- a/bridges/BlaguesDeMerdeBridge.php +++ b/bridges/BlaguesDeMerdeBridge.php @@ -11,11 +11,11 @@ class BlaguesDeMerdeBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request BDM.'); - foreach($html->find('article.joke_contener') as $element){ + foreach($html->find('article.joke_contener') as $element) { $item = array(); $temp = $element->find('a'); - if(isset($temp[2])){ + if(isset($temp[2])) { $item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext); $uri = $temp[2]->href; $item['uri'] = $uri; diff --git a/bridges/BooruprojectBridge.php b/bridges/BooruprojectBridge.php index 1219b72f..6815d370 100644 --- a/bridges/BooruprojectBridge.php +++ b/bridges/BooruprojectBridge.php @@ -28,7 +28,7 @@ class BooruprojectBridge extends GelbooruBridge { const PIDBYPAGE = 20; public function getURI(){ - if(!is_null($this->getInput('i'))){ + if(!is_null($this->getInput('i'))) { return 'http://' . $this->getInput('i') . '.booru.org/'; } @@ -36,7 +36,7 @@ class BooruprojectBridge extends GelbooruBridge { } public function getName(){ - if(!is_null($this->getInput('i'))){ + if(!is_null($this->getInput('i'))) { return static::NAME . ' ' . $this->getInput('i'); } diff --git a/bridges/CADBridge.php b/bridges/CADBridge.php index 761d77f4..09e3e65a 100644 --- a/bridges/CADBridge.php +++ b/bridges/CADBridge.php @@ -25,7 +25,7 @@ class CADBridge extends FeedExpander { $htmlpart = explode("/", $url); - switch ($htmlpart[3]){ + switch ($htmlpart[3]) { case 'cad': preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2); break; diff --git a/bridges/CNETBridge.php b/bridges/CNETBridge.php index 0abd02cc..eefb7051 100644 --- a/bridges/CNETBridge.php +++ b/bridges/CNETBridge.php @@ -17,7 +17,7 @@ topic found in some section URLs, else all topics are selected.'; public function collectData(){ function extractFromDelimiters($string, $start, $end){ - if(strpos($string, $start) !== false){ + if(strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; @@ -27,7 +27,7 @@ topic found in some section URLs, else all topics are selected.'; } function stripWithDelimiters($string, $start, $end){ - while(strpos($string, $start) !== false){ + 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)); $string = str_replace($section_to_remove, '', $string); @@ -49,14 +49,14 @@ topic found in some section URLs, else all topics are selected.'; $html = getSimpleHTMLDOM($pageUrl) or returnServerError('Could not request CNET: ' . $pageUrl); $limit = 0; - foreach($html->find('div.assetBody') as $element){ - if($limit < 8){ + foreach($html->find('div.assetBody') as $element) { + if($limit < 8) { $article_title = trim($element->find('h2', 0)->plaintext); $article_uri = self::URI . ($element->find('a', 0)->href); $article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext); $article_author = trim($element->find('a[rel=author]', 0)->plaintext); - if(!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false){ + if(!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false) { $article_html = getSimpleHTMLDOM($article_uri) or returnServerError('Could not request CNET: ' . $article_uri); $article_content = trim( @@ -83,7 +83,7 @@ topic found in some section URLs, else all topics are selected.'; } public function getName(){ - if(!is_null($this->getInput('topic'))){ + if(!is_null($this->getInput('topic'))) { $topic = $this->getInput('topic'); return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic); } diff --git a/bridges/CastorusBridge.php b/bridges/CastorusBridge.php index 119d3535..3ed1331e 100644 --- a/bridges/CastorusBridge.php +++ b/bridges/CastorusBridge.php @@ -57,7 +57,7 @@ class CastorusBridge extends BridgeAbstract { if(!$nodes) returnServerError('Cannot find nodes!'); - foreach($nodes as $node){ + foreach($nodes as $node) { $node->outertext = ''; } @@ -88,7 +88,7 @@ class CastorusBridge extends BridgeAbstract { if(!$activities) returnServerError('Failed to find activities!'); - foreach($activities as $activity){ + foreach($activities as $activity) { $item = array(); $item['title'] = $this->extractActivityTitle($activity); @@ -103,12 +103,12 @@ class CastorusBridge extends BridgeAbstract { . '

'; if(isset($zip_filter) - && !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)){ + && !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)) { continue; // Skip this item } if(isset($city_filter) - && !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)){ + && !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)) { continue; // Skip this item } diff --git a/bridges/CollegeDeFranceBridge.php b/bridges/CollegeDeFranceBridge.php index 6a570948..1f816832 100644 --- a/bridges/CollegeDeFranceBridge.php +++ b/bridges/CollegeDeFranceBridge.php @@ -37,7 +37,7 @@ class CollegeDeFranceBridge extends BridgeAbstract { . 'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all') or returnServerError('Could not request CollegeDeFrance.'); - foreach($html->find('a[data-target]') as $element){ + foreach($html->find('a[data-target]') as $element) { $item = array(); $item['title'] = $element->find('.title', 0)->plaintext; @@ -60,7 +60,7 @@ class CollegeDeFranceBridge extends BridgeAbstract { $timezone ); - if(!$d){ + if(!$d) { $d = DateTime::createFromFormat( '!d m Y', trim(str_replace( diff --git a/bridges/CopieDoubleBridge.php b/bridges/CopieDoubleBridge.php index af805f21..767cdce3 100644 --- a/bridges/CopieDoubleBridge.php +++ b/bridges/CopieDoubleBridge.php @@ -13,16 +13,16 @@ class CopieDoubleBridge extends BridgeAbstract { $table = $html->find('table table', 2); - foreach($table->find('tr') as $element){ + foreach($table->find('tr') as $element) { $td = $element->find('td', 0); - if($td->class === 'couleur_1'){ + if($td->class === 'couleur_1') { $item = array(); $title = $td->innertext; $pos = strpos($title, 'innertext, '/images/suivant.gif') === false){ + } elseif(strpos($element->innertext, '/images/suivant.gif') === false) { $a = $element->find('a', 0); $item['uri'] = self::URI . $a->href; $content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext); diff --git a/bridges/CourrierInternationalBridge.php b/bridges/CourrierInternationalBridge.php index e666bfd5..15738633 100644 --- a/bridges/CourrierInternationalBridge.php +++ b/bridges/CourrierInternationalBridge.php @@ -14,12 +14,12 @@ class CourrierInternationalBridge extends BridgeAbstract { $element = $html->find("article"); $article_count = 1; - foreach($element as $article){ + foreach($element as $article) { $item = array(); $item['uri'] = $article->parent->getAttribute('href'); - if(strpos($item['uri'], 'http') === false){ + if(strpos($item['uri'], 'http') === false) { $item['uri'] = self::URI . $item['uri']; } @@ -27,7 +27,7 @@ class CourrierInternationalBridge extends BridgeAbstract { $content = $page->find('.article-text', 0); - if(!$content){ + if(!$content) { $content = $page->find('.depeche-text', 0); } diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 9ca95f44..19efd84a 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -20,9 +20,9 @@ class CpasbienBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI . '/recherche/' . urlencode($request) . '.html') or returnServerError('No results for this query.'); - foreach($html->find('#gauche', 0)->find('div') as $episode){ + foreach($html->find('#gauche', 0)->find('div') as $episode) { if($episode->getAttribute('class') == 'ligne0' - || $episode->getAttribute('class') == 'ligne1'){ + || $episode->getAttribute('class') == 'ligne1') { $urlepisode = $episode->find('a', 0)->getAttribute('href'); $htmlepisode = getSimpleHTMLDOMCached($urlepisode, 86400 * 366 * 30); @@ -33,11 +33,11 @@ class CpasbienBridge extends BridgeAbstract { $item['pubdate'] = $this->getCachedDate($urlepisode); $textefiche = $htmlepisode->find('#textefiche', 0)->find('p', 1); - if(isset($textefiche)){ + if(isset($textefiche)) { $item['content'] = $textefiche->text(); } else { $p = $htmlepisode->find('#textefiche', 0)->find('p'); - if(!empty($p)){ + if(!empty($p)) { $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p', 0)->text(); } } @@ -50,7 +50,7 @@ class CpasbienBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('q'))){ + if(!is_null($this->getInput('q'))) { return $this->getInput('q') . ' : ' . self::NAME; } diff --git a/bridges/CryptomeBridge.php b/bridges/CryptomeBridge.php index 78fec3c1..8a3936f4 100644 --- a/bridges/CryptomeBridge.php +++ b/bridges/CryptomeBridge.php @@ -23,12 +23,12 @@ class CryptomeBridge extends BridgeAbstract { $number = $this->getInput('n'); /* number of documents */ - if(!empty($number)){ + if(!empty($number)) { $num = min($number, 20); } - foreach($html->find('pre') as $element){ - for($i = 0; $i < $num; ++$i){ + foreach($html->find('pre') as $element) { + for($i = 0; $i < $num; ++$i) { $item = array(); $item['uri'] = self::URI . substr($element->find('a', $i)->href, 20); $item['title'] = substr($element->find('b', $i)->plaintext, 22); diff --git a/bridges/DailymotionBridge.php b/bridges/DailymotionBridge.php index 15ea52ff..d075041c 100644 --- a/bridges/DailymotionBridge.php +++ b/bridges/DailymotionBridge.php @@ -35,7 +35,7 @@ class DailymotionBridge extends BridgeAbstract { protected function getMetadata($id){ $metadata = array(); $html2 = getSimpleHTMLDOM(self::URI . 'video/' . $id); - if(!$html2){ + if(!$html2) { return $metadata; } @@ -56,12 +56,12 @@ class DailymotionBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request Dailymotion.'); - foreach($html->find('div.media a.preview_link') as $element){ - if($count < $limit){ + foreach($html->find('div.media a.preview_link') as $element) { + if($count < $limit) { $item = array(); $item['id'] = str_replace('/video/', '', strtok($element->href, '_')); $metadata = $this->getMetadata($item['id']); - if(empty($metadata)){ + if(empty($metadata)) { continue; } $item['uri'] = $metadata['uri']; @@ -85,7 +85,7 @@ class DailymotionBridge extends BridgeAbstract { } public function getName(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By username': $specific = $this->getInput('u'); break; @@ -103,7 +103,7 @@ class DailymotionBridge extends BridgeAbstract { public function getURI(){ $uri = self::URI; - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By username': $uri .= 'user/' . urlencode($this->getInput('u')) . '/1'; break; @@ -112,7 +112,7 @@ class DailymotionBridge extends BridgeAbstract { break; case 'From search results': $uri .= 'search/' . urlencode($this->getInput('s')); - if($this->getInput('pa')){ + if($this->getInput('pa')) { $uri .= '/' . $this->getInput('pa'); } break; diff --git a/bridges/DansTonChatBridge.php b/bridges/DansTonChatBridge.php index 56bb4c19..545f1628 100644 --- a/bridges/DansTonChatBridge.php +++ b/bridges/DansTonChatBridge.php @@ -12,7 +12,7 @@ class DansTonChatBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI . 'latest.html') or returnServerError('Could not request DansTonChat.'); - foreach($html->find('div.item') as $element){ + foreach($html->find('div.item') as $element) { $item = array(); $item['uri'] = $element->find('a', 0)->href; $item['title'] = 'DansTonChat ' . $element->find('a', 1)->plaintext; diff --git a/bridges/DauphineLibereBridge.php b/bridges/DauphineLibereBridge.php index 35783358..7547d740 100644 --- a/bridges/DauphineLibereBridge.php +++ b/bridges/DauphineLibereBridge.php @@ -34,7 +34,7 @@ class DauphineLibereBridge extends FeedExpander { public function collectData(){ $url = self::URI . 'rss'; - if(empty($this->getInput('u'))){ + if(empty($this->getInput('u'))) { $url = self::URI . $this->getInput('u') . '/rss'; } diff --git a/bridges/DilbertBridge.php b/bridges/DilbertBridge.php index 2c5e6396..959a91a2 100644 --- a/bridges/DilbertBridge.php +++ b/bridges/DilbertBridge.php @@ -12,7 +12,7 @@ class DilbertBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request Dilbert: ' . $this->getURI()); - foreach($html->find('section.comic-item') as $element){ + foreach($html->find('section.comic-item') as $element) { $img = $element->find('img', 0); $link = $element->find('a', 0); diff --git a/bridges/DuckDuckGoBridge.php b/bridges/DuckDuckGoBridge.php index 554a050f..8533be5e 100644 --- a/bridges/DuckDuckGoBridge.php +++ b/bridges/DuckDuckGoBridge.php @@ -31,7 +31,7 @@ class DuckDuckGoBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort')) or returnServerError('Could not request DuckDuckGo.'); - foreach($html->find('div.results_links') as $element){ + foreach($html->find('div.results_links') as $element) { $item = array(); $item['uri'] = $element->find('a', 0)->href; $item['title'] = $element->find('a', 1)->innertext; diff --git a/bridges/EZTVBridge.php b/bridges/EZTVBridge.php index f17c2b46..4fb9e578 100644 --- a/bridges/EZTVBridge.php +++ b/bridges/EZTVBridge.php @@ -23,7 +23,7 @@ on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.'; $relativeDays = 0; $relativeHours = 0; - foreach(explode(" ", $relativeReleaseTime) as $relativeTimeElement){ + foreach(explode(" ", $relativeReleaseTime) as $relativeTimeElement) { if(substr($relativeTimeElement, -1) == "d") $relativeDays = substr($relativeTimeElement, 0, -1); if(substr($relativeTimeElement, -1) == "h") $relativeHours = substr($relativeTimeElement, 0, -1); } @@ -32,14 +32,14 @@ on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.'; // Loop on show ids $showList = explode(",", $this->getInput('i')); - foreach($showList as $showID){ + foreach($showList as $showID) { // Get show page $html = getSimpleHTMLDOM(self::URI . 'shows/' . rawurlencode($showID) . '/') or returnServerError('Could not request EZTV for id "' . $showID . '"'); // Loop on each element that look like an episode entry... - foreach($html->find('.forum_header_border') as $element){ + foreach($html->find('.forum_header_border') as $element) { // Filter entries that are not episode entries $ep = $element->find('td', 1); diff --git a/bridges/EliteDangerousGalnetBridge.php b/bridges/EliteDangerousGalnetBridge.php index 4c3362da..86a1bbfc 100644 --- a/bridges/EliteDangerousGalnetBridge.php +++ b/bridges/EliteDangerousGalnetBridge.php @@ -11,7 +11,7 @@ class EliteDangerousGalnetBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Error while downloading the website content'); - foreach($html->find('div.article') as $element){ + foreach($html->find('div.article') as $element) { $item = array(); $uri = $element->find('h3 a', 0)->href; diff --git a/bridges/ElsevierBridge.php b/bridges/ElsevierBridge.php index af9f3971..f6ba7ddb 100644 --- a/bridges/ElsevierBridge.php +++ b/bridges/ElsevierBridge.php @@ -27,7 +27,7 @@ class ElsevierBridge extends BridgeAbstract { // Extracts the timestamp from an article private function extractArticleTimestamp($article){ $time = $article->find('.article-info', 0); - if($time){ + if($time) { $timestring = trim($time->plaintext); /* The format depends on the age of an article: @@ -35,11 +35,11 @@ class ElsevierBridge extends BridgeAbstract { - July 2016 - May–June 2016 */ - if(preg_match('/\S*(\d+\s\S+\s\d{4})/ims', $timestring, $matches)){ + if(preg_match('/\S*(\d+\s\S+\s\d{4})/ims', $timestring, $matches)) { return strtotime($matches[0]); - } elseif (preg_match('/[A-Za-z]+\-([A-Za-z]+\s\d{4})/ims', $timestring, $matches)){ + } elseif (preg_match('/[A-Za-z]+\-([A-Za-z]+\s\d{4})/ims', $timestring, $matches)) { return strtotime($matches[0]); - } elseif (preg_match('/([A-Za-z]+\s\d{4})/ims', $timestring, $matches)){ + } elseif (preg_match('/([A-Za-z]+\s\d{4})/ims', $timestring, $matches)) { return strtotime($matches[0]); } else { return 0; @@ -51,7 +51,7 @@ class ElsevierBridge extends BridgeAbstract { // Extracts the content from an article private function extractArticleContent($article){ $content = $article->find('.article-content', 0); - if($content){ + if($content) { return trim($content->plaintext); } return ''; @@ -62,7 +62,7 @@ class ElsevierBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($uri) or returnServerError('No results for Elsevier journal ' . $this->getInput('j')); - foreach($html->find('.pod-listing') as $article){ + foreach($html->find('.pod-listing') as $article) { $item = array(); $item['uri'] = $article->find('.pod-listing-header>a', 0)->getAttribute('href') . '?np=y'; $item['title'] = $article->find('.pod-listing-header>a', 0)->plaintext; diff --git a/bridges/EstCeQuonMetEnProdBridge.php b/bridges/EstCeQuonMetEnProdBridge.php index 5526eae2..db9d1d5f 100644 --- a/bridges/EstCeQuonMetEnProdBridge.php +++ b/bridges/EstCeQuonMetEnProdBridge.php @@ -9,7 +9,7 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract { public function collectData(){ function extractFromDelimiters($string, $start, $end){ - if(strpos($string, $start) !== false){ + if(strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; diff --git a/bridges/EtsyBridge.php b/bridges/EtsyBridge.php index 756ab107..311d9109 100644 --- a/bridges/EtsyBridge.php +++ b/bridges/EtsyBridge.php @@ -38,7 +38,7 @@ class EtsyBridge extends BridgeAbstract { $results = $html->find('div.block-grid-item'); - foreach($results as $result){ + foreach($results as $result) { // Skip banner cards (ads for categories) if($result->find('a.banner-card')) continue; @@ -57,7 +57,7 @@ class EtsyBridge extends BridgeAbstract { $image = $result->find('img.placeholder', 0)->src; - if($this->getInput('showimage')){ + if($this->getInput('showimage')) { $item['content'] .= ''; } @@ -68,10 +68,10 @@ class EtsyBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('query'))){ + if(!is_null($this->getInput('query'))) { $uri = self::URI . '/search?q=' . urlencode($this->getInput('query')); - if(!is_null($this->getInput('queryextension'))){ + if(!is_null($this->getInput('queryextension'))) { $uri .= $this->getInput('queryextension'); } diff --git a/bridges/FB2Bridge.php b/bridges/FB2Bridge.php index 779b48aa..7d78b87f 100644 --- a/bridges/FB2Bridge.php +++ b/bridges/FB2Bridge.php @@ -18,7 +18,7 @@ class FB2Bridge extends BridgeAbstract { public function collectData(){ function extractFromDelimiters($string, $start, $end){ - if(strpos($string, $start) !== false){ + if(strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; @@ -29,7 +29,7 @@ class FB2Bridge extends BridgeAbstract { //Utility function for cleaning a Facebook link $unescape_fb_link = function($matches){ - if(is_array($matches) && count($matches) > 1){ + if(is_array($matches) && count($matches) > 1) { $link = $matches[1]; if(strpos($link, '/') === 0) $link = self::URI . $link . '"'; @@ -72,12 +72,12 @@ class FB2Bridge extends BridgeAbstract { return $matches[0]; }; - if($this->getInput('u') !== null){ + if($this->getInput('u') !== null) { $page = 'https://touch.facebook.com/' . $this->getInput('u'); $cookies = $this->getCookies($page); $pageID = $this->getPageID($page, $cookies); - if($pageID === null){ + if($pageID === null) { echo <<buildContent($fileContent); $author = $this->getInput('u'); - foreach($html->find("article") as $content){ + foreach($html->find("article") as $content) { $item = array(); @@ -223,8 +223,8 @@ EOD; //First request to get the cookie $cookies = ""; - foreach($http_response_header as $hdr){ - if(strpos($hdr, "Set-Cookie") !== false){ + foreach($http_response_header as $hdr) { + if(strpos($hdr, "Set-Cookie") !== false) { $cLine = explode(":", $hdr)[1]; $cLine = explode(";", $cLine)[0]; $cookies .= ";" . $cLine; @@ -255,7 +255,7 @@ EOD; $regex = "/page_id=([0-9]*)&/"; preg_match($regex, $pageContent, $matches); - if(count($matches) > 0){ + if(count($matches) > 0) { return $matches[1]; } diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index 5f6ca6d1..cc16196b 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -32,7 +32,7 @@ class FacebookBridge extends BridgeAbstract { //Extract a string using start and end delimiters function extractFromDelimiters($string, $start, $end){ - if(strpos($string, $start) !== false){ + if(strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; @@ -43,7 +43,7 @@ class FacebookBridge extends BridgeAbstract { //Utility function for cleaning a Facebook link $unescape_fb_link = function($matches){ - if(is_array($matches) && count($matches) > 1){ + if(is_array($matches) && count($matches) > 1) { $link = $matches[1]; if(strpos($link, '/') === 0) $link = self::URI . $link . '"'; @@ -89,12 +89,10 @@ class FacebookBridge extends BridgeAbstract { $html = null; //Handle captcha response sent by the viewer - if (isset($_POST['captcha_response'])) - { + if (isset($_POST['captcha_response'])) { if (session_status() == PHP_SESSION_NONE) session_start(); - if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) - { + if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) { $captcha_action = $_SESSION['captcha_action']; $captcha_fields = $_SESSION['captcha_fields']; $captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']); @@ -110,7 +108,7 @@ class FacebookBridge extends BridgeAbstract { $context = stream_context_create($http_options); $html = getContents($captcha_action, false, $context); - if($html === false){ + if($html === false) { returnServerError('Failed to submit captcha response back to Facebook'); } unset($_SESSION['captcha_fields']); @@ -121,7 +119,7 @@ class FacebookBridge extends BridgeAbstract { } //Retrieve page contents - if(is_null($html)){ + if(is_null($html)) { $http_options = array( 'http' => array( 'method' => 'GET', @@ -130,7 +128,7 @@ class FacebookBridge extends BridgeAbstract { ) ); $context = stream_context_create($http_options); - if(!strpos($this->getInput('u'), "/")){ + if(!strpos($this->getInput('u'), "/")) { $html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', false, $context) @@ -145,8 +143,7 @@ class FacebookBridge extends BridgeAbstract { //Handle captcha form? $captcha = $html->find('div.captcha_interstitial', 0); - if (!is_null($captcha)) - { + if (!is_null($captcha)) { //Save form for submitting after getting captcha response if (session_status() == PHP_SESSION_NONE) session_start(); @@ -182,7 +179,7 @@ EOD; ->next_sibling() ->children(0); - if(isset($element)){ + if(isset($element)) { $author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext); $profilePic = 'https://graph.facebook.com/' @@ -191,17 +188,17 @@ EOD; $this->authorName = $author; - foreach($element->children() as $cell){ + foreach($element->children() as $cell) { // Manage summary posts - if(strpos($cell->class, '_3xaf') !== false){ + if(strpos($cell->class, '_3xaf') !== false) { $posts = $cell->children(); } else { $posts = array($cell); } - foreach($posts as $post){ + foreach($posts as $post) { // Check media type - switch($this->getInput('media_type')){ + switch($this->getInput('media_type')) { case 'all': break; case 'video': if(empty($post->find('[aria-label=Video]'))) continue 2; @@ -214,7 +211,7 @@ EOD; $item = array(); - if(count($post->find('abbr')) > 0){ + if(count($post->find('abbr')) > 0) { //Retrieve post contents $content = preg_replace( @@ -270,7 +267,7 @@ EOD; //Retrieve date of the post $date = $post->find("abbr")[0]; - if(isset($date) && $date->hasAttribute('data-utime')){ + if(isset($date) && $date->hasAttribute('data-utime')) { $date = $date->getAttribute('data-utime'); } else { $date = 0; @@ -298,7 +295,7 @@ EOD; } public function getName(){ - if(!empty($this->authorName)){ + if(!empty($this->authorName)) { return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName . ' - Facebook Bridge'; } diff --git a/bridges/FeedExpanderExampleBridge.php b/bridges/FeedExpanderExampleBridge.php index b855c2e3..9d2f1788 100644 --- a/bridges/FeedExpanderExampleBridge.php +++ b/bridges/FeedExpanderExampleBridge.php @@ -25,7 +25,7 @@ class FeedExpanderExampleBridge extends FeedExpander { ); public function collectData(){ - switch($this->getInput('version')){ + switch($this->getInput('version')) { case 'rss_0_9_1': parent::collectExpandableDatas('http://static.userland.com/gems/backend/sampleRss.xml'); break; @@ -43,7 +43,7 @@ class FeedExpanderExampleBridge extends FeedExpander { } protected function parseItem($newsItem) { - switch($this->getInput('version')){ + switch($this->getInput('version')) { case 'rss_0_9_1': return $this->parseRSS_0_9_1_Item($newsItem); break; diff --git a/bridges/FierPandaBridge.php b/bridges/FierPandaBridge.php index 13864715..cd9d11bd 100644 --- a/bridges/FierPandaBridge.php +++ b/bridges/FierPandaBridge.php @@ -11,7 +11,7 @@ class FierPandaBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request Fier Panda.'); - foreach($html->find('div.container-content article') as $element){ + foreach($html->find('div.container-content article') as $element) { $item = array(); $item['uri'] = $this->getURI() . $element->find('a', 0)->href; $item['title'] = trim($element->find('h1 a', 0)->innertext); diff --git a/bridges/FilterBridge.php b/bridges/FilterBridge.php index 00f045f8..e8b451c7 100644 --- a/bridges/FilterBridge.php +++ b/bridges/FilterBridge.php @@ -31,7 +31,7 @@ class FilterBridge extends FeedExpander { protected function parseItem($newItem){ $item = parent::parseItem($newItem); - switch(true){ + switch(true) { case $this->getFilterType() === 'permit': if (preg_match($this->getFilter(), $item['title'])) { return $item; @@ -57,20 +57,20 @@ class FilterBridge extends FeedExpander { public function getURI(){ $url = $this->getInput('url'); - if(empty($url)){ + if(empty($url)) { $url = parent::getURI(); } return $url; } public function collectData(){ - if($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http'){ + if($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http') { // just in case someone find a way to access local files by playing with the url returnClientError('The url parameter must either refer to http or https protocol.'); } try{ $this->collectExpandableDatas($this->getURI()); - }catch (HttpException $e){ + } catch (HttpException $e) { $this->collectExpandableDatas($this->getURI()); } } diff --git a/bridges/FlickrBridge.php b/bridges/FlickrBridge.php index 57f53a3c..f5ebe9cf 100644 --- a/bridges/FlickrBridge.php +++ b/bridges/FlickrBridge.php @@ -34,7 +34,7 @@ class FlickrBridge extends BridgeAbstract { ); public function collectData(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'Explore': $key = 'photos'; $html = getSimpleHTMLDOM(self::URI . 'explore') @@ -68,7 +68,7 @@ class FlickrBridge extends BridgeAbstract { $model_json = json_decode($model_text, true); - foreach($html->find('.photo-list-photo-view') as $element){ + foreach($html->find('.photo-list-photo-view') as $element) { // Get the styles $style = explode(';', $element->style); @@ -83,17 +83,17 @@ class FlickrBridge extends BridgeAbstract { $imageID = reset($imageURIs); // Use JSON data to build items - foreach(reset($model_json)[0][$key]['_data'] as $element){ - if($element['id'] === $imageID){ + foreach(reset($model_json)[0][$key]['_data'] as $element) { + if($element['id'] === $imageID) { $item = array(); /* Author name depends on scope. On a keyword search the * author is part of the picture data. On a username search * the author is part of the owner data. */ - if(array_key_exists('username', $element)){ + if(array_key_exists('username', $element)) { $item['author'] = $element['username']; - } elseif (array_key_exists('owner', reset($model_json)[0])){ + } elseif (array_key_exists('owner', reset($model_json)[0])) { $item['author'] = reset($model_json)[0]['owner']['username']; } diff --git a/bridges/FootitoBridge.php b/bridges/FootitoBridge.php index 17cbda8d..ac06cd53 100644 --- a/bridges/FootitoBridge.php +++ b/bridges/FootitoBridge.php @@ -10,7 +10,7 @@ class FootitoBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request Footito.'); - foreach($html->find('div.post') as $element){ + foreach($html->find('div.post') as $element) { $item = array(); $content = trim($element->innertext); diff --git a/bridges/FourchanBridge.php b/bridges/FourchanBridge.php index 5cfc6ea4..6aaa13e5 100644 --- a/bridges/FourchanBridge.php +++ b/bridges/FourchanBridge.php @@ -20,7 +20,7 @@ class FourchanBridge extends BridgeAbstract { )); public function getURI(){ - if(!is_null($this->getInput('c')) && !is_null($this->getInput('t'))){ + if(!is_null($this->getInput('c')) && !is_null($this->getInput('t'))) { return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t'); } @@ -32,7 +32,7 @@ class FourchanBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError("Could not request 4chan, thread not found"); - foreach($html->find('div.postContainer') as $element){ + foreach($html->find('div.postContainer') as $element) { $item = array(); $item['id'] = $element->find('.post', 0)->getAttribute('id'); $item['uri'] = $this->getURI() . '#' . $item['id']; @@ -41,19 +41,19 @@ class FourchanBridge extends BridgeAbstract { $file = $element->find('.file', 0); - if(!empty($file)){ + 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) $item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg'; } - if(!empty($element->find('span.subject', 0)->innertext)){ + if(!empty($element->find('span.subject', 0)->innertext)) { $item['subject'] = $element->find('span.subject', 0)->innertext; } $item['title'] = 'reply ' . $item['id'] . ' | ' . $item['author']; - if(isset($item['subject'])){ + if(isset($item['subject'])) { $item['title'] = $item['subject'] . ' - ' . $item['title']; } @@ -61,7 +61,7 @@ class FourchanBridge extends BridgeAbstract { $content = str_replace('href="#p', 'href="' . $this->getURI() . '#p', $content); $item['content'] = '' . $content . ''; - if(isset($item['image'])){ + if(isset($item['image'])) { $item['content'] = ''
diff --git a/bridges/FuturaSciencesBridge.php b/bridges/FuturaSciencesBridge.php
index e41e5185..b9479c3d 100644
--- a/bridges/FuturaSciencesBridge.php
+++ b/bridges/FuturaSciencesBridge.php
@@ -95,7 +95,7 @@ class FuturaSciencesBridge extends FeedExpander {
 	}
 
 	private function stripWithDelimiters($string, $start, $end){
-		while(strpos($string, $start) !== false){
+		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));
 			$string = str_replace($section_to_remove, '', $string);
@@ -106,8 +106,8 @@ class FuturaSciencesBridge extends FeedExpander {
 		$open_tag = '<' . $tag_name;
 		$close_tag = '</' . $tag_name . '>';
 		$close_tag_length = strlen($close_tag);
-		if(strpos($tag_start, $open_tag) === 0){
-			while(strpos($string, $tag_start) !== false){
+		if(strpos($tag_start, $open_tag) === 0) {
+			while(strpos($string, $tag_start) !== false) {
 				$max_recursion = 100;
 				$section_to_remove = null;
 				$section_start = strpos($string, $tag_start);
@@ -165,7 +165,7 @@ class FuturaSciencesBridge extends FeedExpander {
 	// Extracts the author from an article or element
 	private function extractAuthor($article){
 		$article_author = $article->find('h3.epsilon', 0);
-		if($article_author){
+		if($article_author) {
 			return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext));
 		}
 		return '';
diff --git a/bridges/GBAtempBridge.php b/bridges/GBAtempBridge.php
index b8565139..f80a25ce 100644
--- a/bridges/GBAtempBridge.php
+++ b/bridges/GBAtempBridge.php
@@ -21,7 +21,7 @@ class GBAtempBridge extends BridgeAbstract {
 	));
 
 	private function extractFromDelimiters($string, $start, $end){
-		if(strpos($string, $start) !== false){
+		if(strpos($string, $start) !== false) {
 			$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
 			$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
 			return $section_retrieved;
@@ -31,7 +31,7 @@ class GBAtempBridge extends BridgeAbstract {
 	}
 
 	private function stripWithDelimiters($string, $start, $end){
-		while(strpos($string, $start) !== false){
+		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));
 			$string = str_replace($section_to_remove, '', $string);
@@ -59,7 +59,7 @@ class GBAtempBridge extends BridgeAbstract {
 
 	private function fetchPostContent($uri, $site_url){
 		$html = getSimpleHTMLDOM($uri);
-		if(!$html){
+		if(!$html) {
 			return 'Could not request GBAtemp ' . $uri;
 		}
 
@@ -72,9 +72,9 @@ class GBAtempBridge extends BridgeAbstract {
 		$html = getSimpleHTMLDOM(self::URI)
 			or returnServerError('Could not request GBAtemp.');
 
-		switch($this->getInput('type')){
+		switch($this->getInput('type')) {
 		case 'N':
-			foreach($html->find('li[class=news_item full]') as $newsItem){
+			foreach($html->find('li[class=news_item full]') as $newsItem) {
 				$url = self::URI . $newsItem->find('a', 0)->href;
 				$time = intval(
 					$this->extractFromDelimiters(
@@ -89,7 +89,7 @@ class GBAtempBridge extends BridgeAbstract {
 				$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
 			}
 		case 'R':
-			foreach($html->find('li.portal_review') as $reviewItem){
+			foreach($html->find('li.portal_review') as $reviewItem) {
 				$url = self::URI . $reviewItem->find('a', 0)->href;
 				$title = $reviewItem->find('span.review_title', 0)->plaintext;
 				$content = getSimpleHTMLDOM($url)
@@ -111,7 +111,7 @@ class GBAtempBridge extends BridgeAbstract {
 				$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
 			}
 		case 'T':
-			foreach($html->find('li.portal-tutorial') as $tutorialItem){
+			foreach($html->find('li.portal-tutorial') as $tutorialItem) {
 				$url = self::URI . $tutorialItem->find('a', 0)->href;
 				$title = $tutorialItem->find('a', 0)->plaintext;
 				$time = intval(
@@ -126,7 +126,7 @@ class GBAtempBridge extends BridgeAbstract {
 				$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
 			}
 		case 'F':
-			foreach($html->find('li.rc_item') as $postItem){
+			foreach($html->find('li.rc_item') as $postItem) {
 				$url = self::URI . $postItem->find('a', 1)->href;
 				$title = $postItem->find('a', 1)->plaintext;
 				$time = intval(
@@ -144,7 +144,7 @@ class GBAtempBridge extends BridgeAbstract {
 	}
 
 	public function getName() {
-		if(!is_null($this->getInput('type'))){
+		if(!is_null($this->getInput('type'))) {
 			$type = array_search(
 				$this->getInput('type'),
 				self::PARAMETERS[$this->queriedContext]['type']['values']
diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php
index e8b0dc1b..26d1ebaf 100644
--- a/bridges/GiphyBridge.php
+++ b/bridges/GiphyBridge.php
@@ -27,14 +27,14 @@ class GiphyBridge extends BridgeAbstract {
 			or returnServerError('No results for this query.');
 
 		$max = GIPHY_LIMIT;
-		if($this->getInput('n')){
+		if($this->getInput('n')) {
 			$max = $this->getInput('n');
 		}
 
 		$limit = 0;
 		$kw = urlencode($this->getInput('s'));
-		foreach($html->find('div.hoverable-gif') as $entry){
-			if($limit < $max){
+		foreach($html->find('div.hoverable-gif') as $entry) {
+			if($limit < $max) {
 				$node = $entry->first_child();
 				$href = $node->getAttribute('href');
 
@@ -54,7 +54,7 @@ class GiphyBridge extends BridgeAbstract {
 					$title = str_replace($kw, '', $title);
 					$title = preg_replace('/\s+/', ' ', $title);
 					$title = trim($title);
-					if(strlen($title) <= 0){
+					if(strlen($title) <= 0) {
 						$title = $item['id'];
 					}
 				$item['title'] = trim($title);
diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php
index d008f073..4f121d8a 100644
--- a/bridges/GithubIssueBridge.php
+++ b/bridges/GithubIssueBridge.php
@@ -35,9 +35,9 @@ class GithubIssueBridge extends BridgeAbstract {
 
 	public function getName(){
 		$name = $this->getInput('u') . '/' . $this->getInput('p');
-		switch($this->queriedContext){
+		switch($this->queriedContext) {
 		case 'Project Issues':
-			if($this->getInput('c')){
+			if($this->getInput('c')) {
 				$prefix = static::NAME . 's comments for ';
 			} else {
 				$prefix = static::NAME . 's for ';
@@ -53,11 +53,11 @@ class GithubIssueBridge extends BridgeAbstract {
 	}
 
 	public function getURI(){
-		if(!is_null($this->getInput('u')) && !is_null($this->getInput('p'))){
+		if(!is_null($this->getInput('u')) && !is_null($this->getInput('p'))) {
 			$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues';
-			if($this->queriedContext === 'Issue comments'){
+			if($this->queriedContext === 'Issue comments') {
 				$uri .= '/' . $this->getInput('i');
-			} elseif($this->getInput('c')){
+			} elseif($this->getInput('c')) {
 				$uri .= '?q=is%3Aissue+sort%3Aupdated-desc';
 			}
 			return $uri;
@@ -70,29 +70,29 @@ class GithubIssueBridge extends BridgeAbstract {
 		$class = $comment->getAttribute('class');
 		$classes = explode(' ', $class);
 		$event = false;
-		if(in_array('discussion-item', $classes)){
+		if(in_array('discussion-item', $classes)) {
 			$event = true;
 		}
 
 		$author = 'unknown';
-		if($comment->find('.author', 0)){
+		if($comment->find('.author', 0)) {
 			$author = $comment->find('.author', 0)->plaintext;
 		}
 
 		$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr;
 
 		$comment = $comment->firstChild();
-		if(!$event){
+		if(!$event) {
 			$comment = $comment->nextSibling();
 		}
 
-		if($event){
+		if($event) {
 			$title .= ' / ' . substr($class, strpos($class, 'discussion-item-') + strlen('discussion-item-'));
-			if(!$comment->hasAttribute('id')){
+			if(!$comment->hasAttribute('id')) {
 				$items = array();
 				$timestamp = strtotime($comment->find('relative-time', 0)->getAttribute('datetime'));
 				$content = $comment->innertext;
-				while($comment = $comment->nextSibling()){
+				while($comment = $comment->nextSibling()) {
 					$item = array();
 					$item['author'] = $author;
 					$item['title'] = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
@@ -123,12 +123,12 @@ class GithubIssueBridge extends BridgeAbstract {
 		$title = $issue->find('.gh-header-title', 0)->plaintext;
 		$issueNbr = trim(substr($issue->find('.gh-header-number', 0)->plaintext, 1));
 		$comments = $issue->find('.js-discussion', 0);
-		foreach($comments->children() as $comment){
+		foreach($comments->children() as $comment) {
 			$classes = explode(' ', $comment->getAttribute('class'));
 			if(in_array('discussion-item', $classes)
-			|| in_array('timeline-comment-wrapper', $classes)){
+			|| in_array('timeline-comment-wrapper', $classes)) {
 				$item = $this->extractIssueComment($issueNbr, $title, $comment);
-				if(array_keys($item) !== range(0, count($item) - 1)){
+				if(array_keys($item) !== range(0, count($item) - 1)) {
 					$item = array($item);
 				}
 				$items = array_merge($items, $item);
@@ -141,22 +141,22 @@ class GithubIssueBridge extends BridgeAbstract {
 		$html = getSimpleHTMLDOM($this->getURI())
 			or returnServerError('No results for Github Issue ' . $this->getURI());
 
-		switch($this->queriedContext){
+		switch($this->queriedContext) {
 		case 'Issue comments':
 			$this->items = $this->extractIssueComments($html);
 			break;
 		case 'Project Issues':
-			foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue){
+			foreach($html->find('.js-active-navigation-container .js-navigation-item') as $issue) {
 				$info = $issue->find('.opened-by', 0);
 				$issueNbr = substr(trim($info->plaintext), 1, strpos(trim($info->plaintext), ' '));
 
 				$item = array();
 				$item['content'] = '';
 
-				if($this->getInput('c')){
+				if($this->getInput('c')) {
 					$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr;
 					$issue = getSimpleHTMLDOMCached($uri, static::CACHE_TIMEOUT);
-					if($issue){
+					if($issue) {
 						$this->items = array_merge($this->items, $this->extractIssueComments($issue));
 						continue;
 					}
diff --git a/bridges/GithubSearchBridge.php b/bridges/GithubSearchBridge.php
index 3763ee81..d3a615b5 100644
--- a/bridges/GithubSearchBridge.php
+++ b/bridges/GithubSearchBridge.php
@@ -24,7 +24,7 @@ class GithubSearchBridge extends BridgeAbstract {
 		$html = getSimpleHTMLDOM($url)
 			or returnServerError('Error while downloading the website content');
 
-		foreach($html->find('div.repo-list-item') as $element){
+		foreach($html->find('div.repo-list-item') as $element) {
 			$item = array();
 
 			$uri = $element->find('h3 a', 0)->href;
@@ -34,10 +34,9 @@ class GithubSearchBridge extends BridgeAbstract {
 			$title = $element->find('h3', 0)->plaintext;
 			$item['title'] = $title;
 
-			if (count($element->find('p')) == 2){
+			if (count($element->find('p')) == 2) {
 				$content = $element->find('p', 0)->innertext;
-			}
-			else{
+			} else{
 				$content = '';
 			}
 			$item['content'] = $content;
diff --git a/bridges/GizmodoBridge.php b/bridges/GizmodoBridge.php
index c98f7550..35f162b8 100644
--- a/bridges/GizmodoBridge.php
+++ b/bridges/GizmodoBridge.php
@@ -11,11 +11,11 @@ class GizmodoBridge extends FeedExpander {
 		$item = parent::parseItem($item);
 
 		$articleHTMLContent = getSimpleHTMLDOMCached($item['uri']);
-		if(!$articleHTMLContent){
+		if(!$articleHTMLContent) {
 			$text = 'Could not load ' . $item['uri'];
 		} else {
 			$text = $articleHTMLContent->find('div.entry-content', 0)->innertext;
-			foreach($articleHTMLContent->find('pagespeed_iframe') as $element){
+			foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
 				$text .= '<p>link to a iframe (could be a video): <a href=src . '">' diff --git a/bridges/GoComicsBridge.php b/bridges/GoComicsBridge.php index d4a6be21..27621d8a 100644 --- a/bridges/GoComicsBridge.php +++ b/bridges/GoComicsBridge.php @@ -18,7 +18,7 @@ class GoComicsBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request GoComics: ' . $this->getURI()); - foreach($html->find('div.item-comic-container') as $element){ + foreach($html->find('div.item-comic-container') as $element) { $img = $element->find('img', 0); $link = $element->find('a.item-comic-link', 0); @@ -42,7 +42,7 @@ class GoComicsBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('comicname'))){ + if(!is_null($this->getInput('comicname'))) { return self::URI . urlencode($this->getInput('comicname')); } @@ -50,7 +50,7 @@ class GoComicsBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('comicname'))){ + if(!is_null($this->getInput('comicname'))) { return $this->getInput('comicname') . ' - GoComics'; } diff --git a/bridges/GooglePlusPostBridge.php b/bridges/GooglePlusPostBridge.php index 69b6a0c0..0fccc96a 100644 --- a/bridges/GooglePlusPostBridge.php +++ b/bridges/GooglePlusPostBridge.php @@ -21,7 +21,7 @@ class GooglePlusPostBridge extends BridgeAbstract{ $username = $this->getInput('username'); // Usernames start with a + if it's not an ID - if(!is_numeric($username) && substr($username, 0, 1) !== '+'){ + if(!is_numeric($username) && substr($username, 0, 1) !== '+') { $username = '+' . $username; } @@ -34,7 +34,7 @@ class GooglePlusPostBridge extends BridgeAbstract{ $this->_url = $html->find('meta[property=og:url]', 0)->getAttribute('content'); // I don't even know where to start with this discusting html... - foreach($html->find('div[jsname=WsjYwc]') as $post){ + foreach($html->find('div[jsname=WsjYwc]') as $post) { $item = array(); $item['author'] = $item['fullname'] = $post->find('div div div div a', 0)->innertext; @@ -44,7 +44,7 @@ class GooglePlusPostBridge extends BridgeAbstract{ $timestamp = $post->find('a.qXj2He span', 0); - if($timestamp){ + if($timestamp) { $item['timestamp'] = strtotime('+' . preg_replace( '/[^0-9A-Za-z]/', '', @@ -77,15 +77,15 @@ class GooglePlusPostBridge extends BridgeAbstract{ // XXX ugly but I don't have any idea how to do a better stuff, // str_replace on link doesn't work as expected and ask too many checks - foreach($content->find('a') as $link){ + foreach($content->find('a') as $link) { $hasHttp = strpos($link->href, 'http'); $hasDoubleSlash = strpos($link->href, '//'); if((!$hasHttp && !$hasDoubleSlash) || (false !== $hasHttp && strpos($link->href, 'http') != 0) - || (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0)){ + || (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0)) { // skipp bad link, for some hashtag or other stuff - if(strpos($link->href, '/') == 0){ + if(strpos($link->href, '/') == 0) { $link->href = substr($link->href, 1); } diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php index 67e14dc4..2c4a5f1b 100644 --- a/bridges/GoogleSearchBridge.php +++ b/bridges/GoogleSearchBridge.php @@ -33,8 +33,8 @@ class GoogleSearchBridge extends BridgeAbstract { $emIsRes = $html->find('div[id=ires]', 0); - if(!is_null($emIsRes)){ - foreach($emIsRes->find('div[class=g]') as $element){ + if(!is_null($emIsRes)) { + foreach($emIsRes->find('div[class=g]') as $element) { $item = array(); @@ -42,7 +42,7 @@ class GoogleSearchBridge extends BridgeAbstract { $t = $element->find('a[href]', 0)->href; $item['uri'] = '' . $t; parse_str(parse_url($t, PHP_URL_QUERY), $parameters); - if(isset($parameters['q'])){ + if(isset($parameters['q'])) { $item['uri'] = $parameters['q']; } @@ -55,7 +55,7 @@ class GoogleSearchBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('q'))){ + if(!is_null($this->getInput('q'))) { return $this->getInput('q') . ' - Google search'; } diff --git a/bridges/HDWallpapersBridge.php b/bridges/HDWallpapersBridge.php index 29f9c00c..cea6e344 100644 --- a/bridges/HDWallpapersBridge.php +++ b/bridges/HDWallpapersBridge.php @@ -23,7 +23,7 @@ class HDWallpapersBridge extends BridgeAbstract { public function collectData(){ $category = $this->category; - if(strrpos($category, 'wallpapers') !== strlen($category) - strlen('wallpapers')){ + if(strrpos($category, 'wallpapers') !== strlen($category) - strlen('wallpapers')) { $category .= '-desktop-wallpapers'; } @@ -31,17 +31,17 @@ class HDWallpapersBridge extends BridgeAbstract { $max = $this->getInput('m') ?: 14; $lastpage = 1; - for($page = 1; $page <= $lastpage; $page++){ + for($page = 1; $page <= $lastpage; $page++) { $link = self::URI . '/' . $category . '/page/' . $page; $html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.'); - if($page === 1){ + if($page === 1) { preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches); $lastpage = min($matches[1], ceil($max / 14)); } - foreach($html->find('.wallpapers .wall a') as $element){ + foreach($html->find('.wallpapers .wall a') as $element) { $thumbnail = $element->find('img', 0); $item = array(); @@ -70,7 +70,7 @@ class HDWallpapersBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))){ + if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))) { return 'HDWallpapers - ' . str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')) . ' [' diff --git a/bridges/HentaiHavenBridge.php b/bridges/HentaiHavenBridge.php index 14f4ee57..21a0ff5e 100644 --- a/bridges/HentaiHavenBridge.php +++ b/bridges/HentaiHavenBridge.php @@ -11,7 +11,7 @@ class HentaiHavenBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request Hentai Haven.'); - foreach($html->find('div.zoe-grid') as $element){ + foreach($html->find('div.zoe-grid') as $element) { $item = array(); $item['uri'] = $element->find('div.brick-content h3 a', 0)->href; $thumbnailUri = $element->find('a.thumbnail-image img', 0)->getAttribute('data-src'); diff --git a/bridges/IdenticaBridge.php b/bridges/IdenticaBridge.php index 826ff5b9..ef52998f 100644 --- a/bridges/IdenticaBridge.php +++ b/bridges/IdenticaBridge.php @@ -18,7 +18,7 @@ class IdenticaBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Requested username can\'t be found.'); - foreach($html->find('li.major') as $dent){ + foreach($html->find('li.major') as $dent) { $item = array(); // get dent link @@ -35,7 +35,7 @@ class IdenticaBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return $this->getInput('u') . ' - Identica Bridge'; } @@ -43,7 +43,7 @@ class IdenticaBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return self::URI . urlencode($this->getInput('u')); } diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 4df5a799..7ae6a45f 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -30,13 +30,13 @@ class InstagramBridge extends BridgeAbstract { $innertext = null; - foreach($html->find('script') as $script){ - if('' === $script->innertext){ + foreach($html->find('script') as $script) { + if('' === $script->innertext) { continue; } $pos = strpos(trim($script->innertext), 'window._sharedData'); - if(0 !== $pos){ + if(0 !== $pos) { continue; } @@ -49,9 +49,9 @@ class InstagramBridge extends BridgeAbstract { $userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes; - foreach($userMedia as $media){ + foreach($userMedia as $media) { // Check media type - switch($this->getInput('media_type')){ + switch($this->getInput('media_type')) { case 'all': break; case 'video': if($media->is_video === false) continue 2; @@ -65,7 +65,7 @@ class InstagramBridge extends BridgeAbstract { $item = array(); $item['uri'] = self::URI . 'p/' . $media->code . '/'; $item['content'] = ''; - if (isset($media->caption)){ + if (isset($media->caption)) { $item['title'] = $media->caption; } else { $item['title'] = basename($media->display_src); @@ -76,7 +76,7 @@ class InstagramBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return $this->getInput('u') . ' - Instagram Bridge'; } @@ -84,7 +84,7 @@ class InstagramBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return self::URI . urlencode($this->getInput('u')); } diff --git a/bridges/IsoHuntBridge.php b/bridges/IsoHuntBridge.php index a465bdd0..57038fcc 100644 --- a/bridges/IsoHuntBridge.php +++ b/bridges/IsoHuntBridge.php @@ -92,9 +92,9 @@ class IsoHuntBridge extends BridgeAbstract { public function getURI(){ $uri = self::URI; - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By "Latest" category': - switch($this->getInput('latest_category')){ + switch($this->getInput('latest_category')) { case 'hot_torrents': $uri .= 'statistic/hot/torrents'; break; @@ -128,7 +128,7 @@ class IsoHuntBridge extends BridgeAbstract { } public function getName(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By "Latest" category': $categoryName = array_search( $this->getInput('latest_category'), @@ -163,9 +163,9 @@ class IsoHuntBridge extends BridgeAbstract { public function collectData(){ $html = $this->loadHtml($this->getURI()); - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By "Latest" category': - switch($this->getInput('latest_category')){ + switch($this->getInput('latest_category')) { case 'hot_torrents': $this->getLatestHotTorrents($html); break; @@ -179,7 +179,7 @@ class IsoHuntBridge extends BridgeAbstract { } break; case 'By "Torrent" category': - if($this->getInput('torrent_category') === 'movies'){ + if($this->getInput('torrent_category') === 'movies') { // This one is special (content wise) $this->getMovieTorrents($html); } else { @@ -187,7 +187,7 @@ class IsoHuntBridge extends BridgeAbstract { } break; case 'Search torrent by name': - if( $this->getInput('search_category') === 'movies'){ + if($this->getInput('search_category') === 'movies') { // This one is special (content wise) $this->getMovieTorrents($html); } else { @@ -208,7 +208,7 @@ class IsoHuntBridge extends BridgeAbstract { if(!$torrents) returnServerError('Unable to find torrents!'); - foreach($torrents as $torrent){ + foreach($torrents as $torrent) { $anchor = $torrent->find('a', 0); if(!$anchor) @@ -246,7 +246,7 @@ class IsoHuntBridge extends BridgeAbstract { // Remove first element (header row) $torrents = array_slice($torrents, 1); - foreach($torrents as $torrent){ + foreach($torrents as $torrent) { $cell = $torrent->find('td', 0); if(!$cell) @@ -281,7 +281,7 @@ class IsoHuntBridge extends BridgeAbstract { if(!$posts) returnServerError('Unable to find posts!'); - foreach($posts as $post){ + foreach($posts as $post) { $item = array(); $item['uri'] = $this->latestNewsExtractUri($post); @@ -316,7 +316,7 @@ class IsoHuntBridge extends BridgeAbstract { $timestamp = strtotime($matches[1]); // Make sure date is not in the future (dates are given like 'Nov. 20' without year) - if($timestamp > time()){ + if($timestamp > time()) { $timestamp = strtotime('-1 year', $timestamp); } @@ -345,12 +345,12 @@ class IsoHuntBridge extends BridgeAbstract { returnServerError('Unable to find content!'); // Remove

...

(title) - foreach($content->find('h2') as $element){ + foreach($content->find('h2') as $element) { $element->outertext = ''; } // Remove ... (author) - foreach($content->find('small') as $element){ + foreach($content->find('small') as $element) { $element->outertext = ''; } @@ -370,7 +370,7 @@ class IsoHuntBridge extends BridgeAbstract { if(!$torrents) returnServerError('Unable to find torrents!'); - foreach($torrents as $torrent){ + foreach($torrents as $torrent) { $item = array(); $item['uri'] = $this->latestTorrentsExtractUri($torrent); @@ -444,7 +444,7 @@ class IsoHuntBridge extends BridgeAbstract { } private function buildCategoryUri($category, $order_popularity = false){ - switch($category){ + switch($category) { case 'anime': $index = 1; break; case 'software' : $index = 2; break; case 'games' : $index = 3; break; diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php index 040754cd..c80bb24c 100644 --- a/bridges/JapanExpoBridge.php +++ b/bridges/JapanExpoBridge.php @@ -38,7 +38,7 @@ class JapanExpoBridge extends BridgeAbstract { } $convert_article_images = function($matches){ - if(is_array($matches) && count($matches) > 1){ + if(is_array($matches) && count($matches) > 1) { return ''; } }; @@ -48,7 +48,7 @@ class JapanExpoBridge extends BridgeAbstract { $fullcontent = $this->getInput('mode'); $count = 0; - foreach($html->find('a._tile2') as $element){ + foreach($html->find('a._tile2') as $element) { $url = $element->href; $thumbnail = 'http://s.japan-expo.com/katana/images/JES049/paris.png'; @@ -57,8 +57,8 @@ class JapanExpoBridge extends BridgeAbstract { if(count($img_search_result) >= 2) $thumbnail = trim($img_search_result[1], "'"); - if($fullcontent){ - if($count >= 5){ + if($fullcontent) { + if($count >= 5) { break; } diff --git a/bridges/KATBridge.php b/bridges/KATBridge.php index 86d7f16e..c4325a60 100644 --- a/bridges/KATBridge.php +++ b/bridges/KATBridge.php @@ -49,23 +49,22 @@ class KATBridge extends BridgeAbstract { return $timestamp; } $catBool = $this->getInput('cat_check'); - if($catBool){ + if($catBool) { $catNum = $this->getInput('cat'); } $critList = $this->getInput('crit'); $trustedBool = $this->getInput('trusted'); $keywordsList = explode(';', $this->getInput('q')); - foreach($keywordsList as $keywords){ - switch($critList){ + foreach($keywordsList as $keywords) { + switch($critList) { case 'search': - if($catBool == false){ + if($catBool == false) { $html = getSimpleHTMLDOM( self::URI . 'torrents-search.php?search=' . rawurlencode($keywords) ) or returnServerError('Could not request KAT.'); - } - else { + } else { $html = getSimpleHTMLDOM( self::URI . 'torrents-search.php?search=' . @@ -92,10 +91,10 @@ class KATBridge extends BridgeAbstract { } if ($html->find('table.ttable_headinner', 0) == false) returnServerError('No result for query ' . $keywords); - foreach($html->find('tr.t-row') as $element){ + foreach($html->find('tr.t-row') as $element) { if(!$trustedBool || !is_null($element->find('i[title="Elite Uploader"]', 0)) - || !is_null($element->find('i[title="Verified Uploader"]', 0))){ + || !is_null($element->find('i[title="Verified Uploader"]', 0))) { $item = array(); $item['uri'] = self::URI . $element->find('a', 2)->href; $item['id'] = self::URI . $element->find('a.cellMainLink', 0)->href; diff --git a/bridges/KernelBugTrackerBridge.php b/bridges/KernelBugTrackerBridge.php index 6494a218..567ee50c 100644 --- a/bridges/KernelBugTrackerBridge.php +++ b/bridges/KernelBugTrackerBridge.php @@ -66,18 +66,18 @@ class KernelBugTrackerBridge extends BridgeAbstract { // Get and limit comments $comments = $html->find('div.bz_comment'); - if($limit > 0 && count($comments) > $limit){ + if($limit > 0 && count($comments) > $limit) { $comments = array_slice($comments, count($comments) - $limit, $limit); } // Order comments - switch($sorting){ + switch($sorting) { case 'lf': $comments = array_reverse($comments, true); case 'of': default: // Nothing to do, keep original order } - foreach($comments as $comment){ + foreach($comments as $comment) { $comment = $this->inlineStyles($comment); $item = array(); @@ -99,7 +99,7 @@ class KernelBugTrackerBridge extends BridgeAbstract { } public function getURI(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'Bug comments': return parent::getURI() . '/show_bug.cgi?id=' @@ -110,7 +110,7 @@ class KernelBugTrackerBridge extends BridgeAbstract { } public function getName(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'Bug comments': return 'Bug ' . $this->bugid @@ -142,7 +142,7 @@ class KernelBugTrackerBridge extends BridgeAbstract { * attributes. */ private function inlineStyles($html){ - foreach($html->find('.bz_obsolete') as $element){ + foreach($html->find('.bz_obsolete') as $element) { $element->style = 'text-decoration:line-through;'; } diff --git a/bridges/KununuBridge.php b/bridges/KununuBridge.php index ad3fdea4..e99e1350 100644 --- a/bridges/KununuBridge.php +++ b/bridges/KununuBridge.php @@ -41,13 +41,13 @@ class KununuBridge extends BridgeAbstract { private $companyName = ''; public function getURI(){ - if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))){ + if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))) { $company = $this->fixCompanyName($this->getInput('company')); $site = $this->getInput('site'); $section = ''; - switch($site){ + switch($site) { case 'at': case 'de': case 'ch': @@ -65,7 +65,7 @@ class KununuBridge extends BridgeAbstract { } function getName(){ - if(!is_null($this->getInput('company'))){ + if(!is_null($this->getInput('company'))) { $company = $this->fixCompanyName($this->getInput('company')); return ($this->companyName ?: $company) . ' - ' . self::NAME; } @@ -94,7 +94,7 @@ class KununuBridge extends BridgeAbstract { returnServerError('Unable to find articles!'); // Go through all articles - foreach($articles as $article){ + foreach($articles as $article) { $item = array(); $item['author'] = $this->extractArticleAuthorPosition($article); @@ -208,8 +208,8 @@ class KununuBridge extends BridgeAbstract { // Go through all h2 elements to find index of required span (I know... it's stupid) $author_position = 'Unknown'; - foreach($user_content->find('div') as $content){ - if(stristr(strtolower($content->plaintext), 'position')){ /* This works for at, ch, de, us */ + foreach($user_content->find('div') as $content) { + if(stristr(strtolower($content->plaintext), 'position')) { /* This works for at, ch, de, us */ $author_position = $content->next_sibling()->plaintext; break; } diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php index 78ef3ede..dc06a6db 100644 --- a/bridges/LWNprevBridge.php +++ b/bridges/LWNprevBridge.php @@ -11,9 +11,9 @@ class LWNprevBridge extends BridgeAbstract{ } private function jumpToNextTag(&$node){ - while($node && $node->nodeType === XML_TEXT_NODE){ + while($node && $node->nodeType === XML_TEXT_NODE) { $nextNode = $node->nextSibling; - if(!$nextNode){ + if(!$nextNode) { break; } $node = $nextNode; @@ -21,9 +21,9 @@ class LWNprevBridge extends BridgeAbstract{ } private function jumpToPreviousTag(&$node){ - while($node && $node->nodeType === XML_TEXT_NODE){ + while($node && $node->nodeType === XML_TEXT_NODE) { $previousNode = $node->previousSibling; - if(!$previousNode){ + if(!$previousNode) { break; } $node = $previousNode; @@ -44,8 +44,8 @@ class LWNprevBridge extends BridgeAbstract{ $cat1 = ''; $cat2 = ''; - foreach($html->getElementsByTagName('a') as $a){ - if($a->textContent === 'Multi-page format'){ + foreach($html->getElementsByTagName('a') as $a) { + if($a->textContent === 'Multi-page format') { break; } } @@ -57,8 +57,8 @@ class LWNprevBridge extends BridgeAbstract{ substr($edition, strpos($edition, 'for ') + strlen('for ')) ); - foreach($html->getElementsByTagName('h2') as $h2){ - if($h2->getAttribute('class') !== 'SummaryHL'){ + foreach($html->getElementsByTagName('h2') as $h2) { + if($h2->getAttribute('class') !== 'SummaryHL') { continue; } @@ -67,7 +67,7 @@ class LWNprevBridge extends BridgeAbstract{ $h2NextSibling = $h2->nextSibling; $this->jumpToNextTag($h2NextSibling); - switch($h2NextSibling->getAttribute('class')){ + switch($h2NextSibling->getAttribute('class')) { case 'FeatureByline': $item['author'] = $h2NextSibling->getElementsByTagName('b')->item(0)->textContent; break; @@ -82,9 +82,9 @@ class LWNprevBridge extends BridgeAbstract{ $h2FirstChild = $h2->firstChild; $this->jumpToNextTag($h2FirstChild); - if($h2FirstChild->nodeName === 'a'){ + if($h2FirstChild->nodeName === 'a') { $item['uri'] = self::URI . $h2FirstChild->getAttribute('href'); - }else{ + } else{ $item['uri'] = $realURI . '#' . $URICounter; } $URICounter++; @@ -93,12 +93,12 @@ class LWNprevBridge extends BridgeAbstract{ $h2PrevSibling = $h2->previousSibling; $this->jumpToPreviousTag($h2PrevSibling); - switch($h2PrevSibling->getAttribute('class')){ + switch($h2PrevSibling->getAttribute('class')) { case 'Cat2HL': $cat2 = $h2PrevSibling->textContent; $h2PrevSibling = $h2PrevSibling->previousSibling; $this->jumpToPreviousTag($h2PrevSibling); - if($h2PrevSibling->getAttribute('class') !== 'Cat1HL'){ + if($h2PrevSibling->getAttribute('class') !== 'Cat1HL') { break; } $cat1 = $h2PrevSibling->textContent; @@ -113,7 +113,7 @@ class LWNprevBridge extends BridgeAbstract{ $h2PrevSibling = null; $item['title'] = ''; - if(!empty($cat1)){ + if(!empty($cat1)) { $item['title'] .= '[' . $cat1 . ($cat2 ? '/' . $cat2 : '') . '] '; } $item['title'] .= $h2->textContent; @@ -121,7 +121,7 @@ class LWNprevBridge extends BridgeAbstract{ $node = $h2; $content = ''; $contentEnd = false; - while(!$contentEnd){ + while(!$contentEnd) { $node = $node->nextSibling; if(!$node || ( $node->nodeType !== XML_TEXT_NODE && ( @@ -132,9 +132,9 @@ class LWNprevBridge extends BridgeAbstract{ ) ) ) - ){ + ) { $contentEnd = true; - }else{ + } else{ $content .= $node->C14N(); } } diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index 89413883..d4da546e 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -141,7 +141,7 @@ region, and optionally a category and a keyword .'; public function collectData(){ $category = $this->getInput('c'); - if(empty($category)){ + if(empty($category)) { $category = 'annonces'; } @@ -154,13 +154,13 @@ region, and optionally a category and a keyword .'; or returnServerError('Could not request LeBonCoin.'); $list = $html->find('.tabsContent', 0); - if($list === null){ + if($list === null) { return; } $tags = $list->find('li'); - foreach($tags as $element){ + foreach($tags as $element) { $element = $element->find('a', 0); @@ -169,7 +169,7 @@ region, and optionally a category and a keyword .'; $title = html_entity_decode($element->getAttribute('title')); $content_image = $element->find('div.item_image', 0)->find('.lazyload', 0); - if($content_image !== null){ + if($content_image !== null) { $content = 'thumbnail'; } else { $content = ""; diff --git a/bridges/LeMondeInformatiqueBridge.php b/bridges/LeMondeInformatiqueBridge.php index e315f937..706752ff 100644 --- a/bridges/LeMondeInformatiqueBridge.php +++ b/bridges/LeMondeInformatiqueBridge.php @@ -27,7 +27,7 @@ class LeMondeInformatiqueBridge extends FeedExpander { } private function stripWithDelimiters($string, $start, $end){ - while(strpos($string, $start) !== false){ + 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)); $string = str_replace($section_to_remove, '', $string); diff --git a/bridges/LegifranceJOBridge.php b/bridges/LegifranceJOBridge.php index 2233db4a..348be8f1 100644 --- a/bridges/LegifranceJOBridge.php +++ b/bridges/LegifranceJOBridge.php @@ -19,10 +19,10 @@ class LegifranceJOBridge extends BridgeAbstract { $item['uri'] = $this->uri . '#' . count($this->items); $item['title'] = $section->plaintext; - if(!is_null($origin)){ + if(!is_null($origin)) { $item['title'] = '[ ' . $item['title'] . ' / ' . $subsection->plaintext . ' ] ' . $origin->plaintext; $data = $origin; - } elseif(!is_null($subsection)){ + } elseif(!is_null($subsection)) { $item['title'] = '[ ' . $item['title'] . ' ] ' . $subsection->plaintext; $data = $subsection; } else { @@ -30,7 +30,7 @@ class LegifranceJOBridge extends BridgeAbstract { } $item['content'] = ''; - foreach($data->nextSibling()->find('a') as $content){ + foreach($data->nextSibling()->find('a') as $content) { $text = $content->plaintext; $href = $content->nextSibling()->getAttribute('resource'); $item['content'] .= '

' . $text . '

'; @@ -47,19 +47,19 @@ class LegifranceJOBridge extends BridgeAbstract { $this->uri = trim(substr($uri, strpos($uri, 'https'))); $this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/'))); - foreach($html->find('h3') as $section){ + foreach($html->find('h3') as $section) { $subsections = $section->nextSibling()->find('h4'); - foreach($subsections as $subsection){ + foreach($subsections as $subsection) { $origins = $subsection->nextSibling()->find('h5'); - foreach($origins as $origin){ + foreach($origins as $origin) { $this->items[] = $this->extractItem($section, $subsection, $origin); } - if(!empty($origins)){ + if(!empty($origins)) { continue; } $this->items[] = $this->extractItem($section, $subsection); } - if(!empty($subsections)){ + if(!empty($subsections)) { continue; } $this->items[] = $this->extractItem($section); diff --git a/bridges/LesJoiesDuCodeBridge.php b/bridges/LesJoiesDuCodeBridge.php index 79dfc5ea..34145a1d 100644 --- a/bridges/LesJoiesDuCodeBridge.php +++ b/bridges/LesJoiesDuCodeBridge.php @@ -11,7 +11,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request LesJoiesDuCode.'); - foreach($html->find('div.blog-post') as $element){ + foreach($html->find('div.blog-post') as $element) { $item = array(); $temp = $element->find('h1 a', 0); $titre = html_entity_decode($temp->innertext); @@ -21,7 +21,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract { // retrieve .gif instead of static .jpg $images = $temp->find('p img'); - foreach($images as $image){ + foreach($images as $image) { $img_src = str_replace(".jpg", ".gif", $image->src); $image->src = $img_src; } @@ -30,7 +30,7 @@ class LesJoiesDuCodeBridge extends BridgeAbstract { $auteur = $temp->find('i', 0); $pos = strpos($auteur->innertext, "by"); - if($pos > 0){ + if($pos > 0) { $auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2)))); $item['author'] = $auteur; } diff --git a/bridges/LinkedInCompanyBridge.php b/bridges/LinkedInCompanyBridge.php index 73cdcbf0..e629211d 100644 --- a/bridges/LinkedInCompanyBridge.php +++ b/bridges/LinkedInCompanyBridge.php @@ -22,9 +22,9 @@ class LinkedInCompanyBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($link) or returnServerError('Could not request LinkedIn.'); - foreach($html->find('//*[@id="my-feed-post"]/li') as $element){ + foreach($html->find('//*[@id="my-feed-post"]/li') as $element) { $title = $element->find('span.share-body', 0)->innertext; - if($title){ + if($title) { $item = array(); $item['uri'] = $link; $item['title'] = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0, 100); diff --git a/bridges/MangareaderBridge.php b/bridges/MangareaderBridge.php index 6dd746f3..cd7dddc1 100644 --- a/bridges/MangareaderBridge.php +++ b/bridges/MangareaderBridge.php @@ -80,7 +80,7 @@ class MangareaderBridge extends BridgeAbstract { public function collectData(){ // We'll use the DOM parser for this as it makes navigation easier $html = getContents($this->getURI()); - if(!$html){ + if(!$html) { returnClientError('Could not receive data for ' . $path . '!'); } libxml_use_internal_errors(true); @@ -92,7 +92,7 @@ class MangareaderBridge extends BridgeAbstract { $xpath = new DomXPath($doc); $this->request = ''; - switch($this->queriedContext){ + switch($this->queriedContext) { case 'Get latest updates': $this->request = 'Latest updates'; $this->getLatestUpdates($xpath); @@ -105,7 +105,7 @@ class MangareaderBridge extends BridgeAbstract { break; case 'Get manga updates': $limit = $this->getInput('limit'); - if(empty($limit)){ + if(empty($limit)) { $limit = self::PARAMETERS[$this->queriedContext]['limit']['defaultValue']; } @@ -118,7 +118,7 @@ class MangareaderBridge extends BridgeAbstract { } // Return some dummy-data if no content available - if(empty($this->items)){ + if(empty($this->items)) { $item = array(); $item['content'] = "

No updates available

"; @@ -130,14 +130,14 @@ class MangareaderBridge extends BridgeAbstract { // Query each item (consists of Manga + chapters) $nodes = $xpath->query("//*[@id='latestchapters']/table//td"); - foreach ($nodes as $node){ + foreach ($nodes as $node) { // Query the manga $manga = $xpath->query("a[@class='chapter']", $node)->item(0); // Collect the chapters for each Manga $chapters = $xpath->query("a[@class='chaptersrec']", $node); - if (isset($manga) && $chapters->length >= 1){ + if (isset($manga) && $chapters->length >= 1) { $item = array(); $item['uri'] = self::URI . htmlspecialchars($manga->getAttribute('href')); $item['title'] = htmlspecialchars($manga->nodeValue); @@ -145,8 +145,8 @@ class MangareaderBridge extends BridgeAbstract { // Add each chapter to the feed $item['content'] = ""; - foreach ($chapters as $chapter){ - if($item['content'] <> ""){ + foreach ($chapters as $chapter) { + if($item['content'] <> "") { $item['content'] .= "
"; } $item['content'] .= "')" @@ -203,13 +203,13 @@ EOD; private function getMangaUpdates($xpath, $limit){ $query = "(.//*[@id='listing']//tr)[position() > 1]"; - if($limit !== -1){ + if($limit !== -1) { $query = "(.//*[@id='listing']//tr)[position() > 1][position() > last() - {$limit}]"; } $chapters = $xpath->query($query); - foreach ($chapters as $chapter){ + foreach ($chapters as $chapter) { $item = array(); $item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter) ->item(0) @@ -225,13 +225,13 @@ EOD; } public function getURI(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'Get latest updates': $path = "latest"; break; case 'Get popular mangas': $path = "popular"; - if($this->getInput('category') !== "all"){ + if($this->getInput('category') !== "all") { $path .= "/" . $this->getInput('category'); } break; diff --git a/bridges/MixCloudBridge.php b/bridges/MixCloudBridge.php index 073cdf2c..aa6340a1 100644 --- a/bridges/MixCloudBridge.php +++ b/bridges/MixCloudBridge.php @@ -16,7 +16,7 @@ class MixCloudBridge extends BridgeAbstract { )); public function getName(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return 'MixCloud - ' . $this->getInput('u'); } @@ -28,7 +28,7 @@ class MixCloudBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI . $this->getInput('u')) or returnServerError('Could not request MixCloud.'); - foreach($html->find('section.card') as $element){ + foreach($html->find('section.card') as $element) { $item = array(); @@ -40,7 +40,7 @@ class MixCloudBridge extends BridgeAbstract { $image = $element->find('a.album-art img', 0); - if($image){ + if($image) { $item['content'] = ''; } diff --git a/bridges/MoebooruBridge.php b/bridges/MoebooruBridge.php index 787a45f7..9d9a625b 100644 --- a/bridges/MoebooruBridge.php +++ b/bridges/MoebooruBridge.php @@ -35,7 +35,7 @@ class MoebooruBridge extends BridgeAbstract { $data[] = preg_replace('/}\)(.*)/', '}', $element); unset($data[0]); - foreach($data as $datai){ + foreach($data as $datai) { $json = json_decode($datai, true); $item = array(); $item['uri'] = $this->getURI() . '/post/show/' . $json['id']; diff --git a/bridges/MoinMoinBridge.php b/bridges/MoinMoinBridge.php index d57f1b0b..5b41924a 100644 --- a/bridges/MoinMoinBridge.php +++ b/bridges/MoinMoinBridge.php @@ -92,17 +92,17 @@ class MoinMoinBridge extends BridgeAbstract { $sections = $this->splitSections($html); - foreach($sections as $section){ + foreach($sections as $section) { $item = array(); $item['uri'] = $this->findSectionAnchor($section[0]); - switch($this->getInput('content')){ + switch($this->getInput('content')) { case 'none': // Do not return any content break; case 'follow': // Follow the anchor // We can only follow anchors (use default otherwise) - if($this->getInput('separator') === 'a'){ + if($this->getInput('separator') === 'a') { $content = $this->followAnchor($item['uri']); // Return only actual content @@ -124,14 +124,14 @@ class MoinMoinBridge extends BridgeAbstract { $item['title'] = strip_tags($section[1]); // Skip items with empty title - if(empty(trim($item['title']))){ + if(empty(trim($item['title']))) { continue; } $this->items[] = $item; if($this->getInput('limit') > 0 - && count($this->items) >= $this->getInput('limit')){ + && count($this->items) >= $this->getInput('limit')) { break; } } @@ -177,7 +177,7 @@ class MoinMoinBridge extends BridgeAbstract { ); // Some pages don't use headers, return page as one feed - if(count($sections) === 0){ + if(count($sections) === 0) { return array( array( $content, @@ -198,13 +198,13 @@ class MoinMoinBridge extends BridgeAbstract { // For IDs $anchor = $html->find($this->getInput('separator') . '[id=]', 0); - if(!is_null($anchor)){ + if(!is_null($anchor)) { return $this->getInput('source') . '#' . $anchor->id; } // For actual anchors $anchor = $html->find($this->getInput('separator') . '[href=]', 0); - if(!is_null($anchor)){ + if(!is_null($anchor)) { return $anchor->href; } @@ -225,11 +225,11 @@ class MoinMoinBridge extends BridgeAbstract { */ $pageinfo = $html->find('[id="pageinfo"]', 0); - if(is_null($pageinfo)){ + if(is_null($pageinfo)) { return null; } else { $author = $pageinfo->find('[title=]', 0); - if(is_null($author)){ + if(is_null($author)) { return null; } else { return trim(explode('@', $author->title)[0]); @@ -246,7 +246,7 @@ class MoinMoinBridge extends BridgeAbstract { // See example of findAuthor() $pageinfo = $html->find('[id="pageinfo"]', 0); - if(is_null($pageinfo)){ + if(is_null($pageinfo)) { return null; } else { $timestamp = $pageinfo->innertext; @@ -264,8 +264,8 @@ class MoinMoinBridge extends BridgeAbstract { $source = $source ?: $this->getURI(); - foreach($html->find('a') as $anchor){ - switch(substr($anchor->href, 0, 1)){ + foreach($html->find('a') as $anchor) { + switch(substr($anchor->href, 0, 1)) { case 'h': // http or https, no actions required break; case '/': // some relative path @@ -287,12 +287,12 @@ class MoinMoinBridge extends BridgeAbstract { * wiki domain) */ private function followAnchor($anchor){ - if(strrpos($anchor, $this->findDomain($this->getInput('source')) === false)){ + if(strrpos($anchor, $this->findDomain($this->getInput('source')) === false)) { return null; } $html = getSimpleHTMLDOMCached($anchor); - if(!$html){ // Cannot load article + if(!$html) { // Cannot load article return null; } @@ -310,7 +310,7 @@ class MoinMoinBridge extends BridgeAbstract { /* This function is a copy from CNETBridge */ private function stripWithDelimiters($string, $start, $end){ - while(strpos($string, $start) !== false){ + 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)); $string = str_replace($section_to_remove, '', $string); diff --git a/bridges/MondeDiploBridge.php b/bridges/MondeDiploBridge.php index b543c64b..85f771e3 100644 --- a/bridges/MondeDiploBridge.php +++ b/bridges/MondeDiploBridge.php @@ -11,7 +11,7 @@ class MondeDiploBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request MondeDiplo. for : ' . self::URI); - foreach($html->find('div.unarticle') as $article){ + foreach($html->find('div.unarticle') as $article) { $element = $article->parent(); $item = array(); $item['uri'] = self::URI . $element->href; diff --git a/bridges/MsnMondeBridge.php b/bridges/MsnMondeBridge.php index 81a8dd83..12d3d2fc 100644 --- a/bridges/MsnMondeBridge.php +++ b/bridges/MsnMondeBridge.php @@ -21,8 +21,8 @@ class MsnMondeBridge extends BridgeAbstract { or returnServerError('Could not request MsnMonde.'); $limit = 0; - foreach($html->find('.smalla') as $article){ - if($limit < 10){ + foreach($html->find('.smalla') as $article) { + if($limit < 10) { $item = array(); $item['title'] = utf8_decode($article->find('h4', 0)->innertext); $item['uri'] = self::URI . utf8_decode($article->find('a', 0)->href); diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php index dcf84244..74fd219b 100644 --- a/bridges/NasaApodBridge.php +++ b/bridges/NasaApodBridge.php @@ -14,7 +14,7 @@ class NasaApodBridge extends BridgeAbstract { $list = explode("
", $html->find('b', 0)->innertext); - for($i = 0; $i < 3; $i++){ + for($i = 0; $i < 3; $i++) { $line = $list[$i]; $item = array(); diff --git a/bridges/NeuviemeArtBridge.php b/bridges/NeuviemeArtBridge.php index 2b899411..d0954fc3 100644 --- a/bridges/NeuviemeArtBridge.php +++ b/bridges/NeuviemeArtBridge.php @@ -7,7 +7,7 @@ class NeuviemeArtBridge extends FeedExpander { const DESCRIPTION = 'Returns the newest articles.'; private function stripWithDelimiters($string, $start, $end){ - while(strpos($string, $start) !== false){ + 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)); $string = str_replace($section_to_remove, '', $string); @@ -20,21 +20,21 @@ class NeuviemeArtBridge extends FeedExpander { $item = parent::parseItem($item); $article_html = getSimpleHTMLDOMCached($item['uri']); - if(!$article_html){ + if(!$article_html) { $item['content'] = 'Could not request 9eme Art: ' . $item['uri']; return $item; } $article_image = ''; - foreach ($article_html->find('img.img_full') as $img){ - if ($img->alt == $item['title']){ + foreach ($article_html->find('img.img_full') as $img) { + if ($img->alt == $item['title']) { $article_image = self::URI . $img->src; break; } } $article_content = ''; - if($article_image){ + if($article_image) { $article_content = '

'; } $article_content .= str_replace( diff --git a/bridges/NextgovBridge.php b/bridges/NextgovBridge.php index c141e612..370b0bf6 100644 --- a/bridges/NextgovBridge.php +++ b/bridges/NextgovBridge.php @@ -35,9 +35,9 @@ class NextgovBridge extends FeedExpander { $item['content'] = ''; $namespaces = $newsItem->getNamespaces(true); - if(isset($namespaces['media'])){ + if(isset($namespaces['media'])) { $media = $newsItem->children($namespaces['media']); - if(isset($media->content)){ + if(isset($media->content)) { $attributes = $media->content->attributes(); $item['content'] = ''; } diff --git a/bridges/NovelUpdatesBridge.php b/bridges/NovelUpdatesBridge.php index 5a2a8dab..729eb485 100644 --- a/bridges/NovelUpdatesBridge.php +++ b/bridges/NovelUpdatesBridge.php @@ -17,7 +17,7 @@ class NovelUpdatesBridge extends BridgeAbstract { private $seriesTitle = ''; public function getURI(){ - if(!is_null($this->getInput('n'))){ + if(!is_null($this->getInput('n'))) { return static::URI . '/series/' . $this->getInput('n') . '/'; } @@ -35,7 +35,7 @@ class NovelUpdatesBridge extends BridgeAbstract { $html = stristr($html, ''); //strip thead $html = stristr($html, ''); //remove tbody $html = str_get_html(stristr($html, '', true)); //remove last tbody and get back as an array - foreach($html->find('tr') as $element){ + foreach($html->find('tr') as $element) { $item = array(); $item['uri'] = $element->find('td', 2)->find('a', 0)->href; $item['title'] = $element->find('td', 2)->find('a', 0)->plaintext; @@ -60,7 +60,7 @@ class NovelUpdatesBridge extends BridgeAbstract { } public function getName(){ - if(!empty($this->seriesTitle)){ + if(!empty($this->seriesTitle)) { return $this->seriesTitle . ' - ' . static::NAME; } diff --git a/bridges/OpenClassroomsBridge.php b/bridges/OpenClassroomsBridge.php index eb4366cc..5f0daca4 100644 --- a/bridges/OpenClassroomsBridge.php +++ b/bridges/OpenClassroomsBridge.php @@ -27,7 +27,7 @@ class OpenClassroomsBridge extends BridgeAbstract { )); public function getURI(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return self::URI . '/courses?categories=' . $this->getInput('u') . '&title=&sort=updatedAt+desc'; } @@ -38,7 +38,7 @@ class OpenClassroomsBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request OpenClassrooms.'); - foreach($html->find('.courseListItem') as $element){ + foreach($html->find('.courseListItem') as $element) { $item = array(); $item['uri'] = self::URI . $element->find('a', 0)->href; $item['title'] = $element->find('h3', 0)->plaintext; diff --git a/bridges/ParuVenduImmoBridge.php b/bridges/ParuVenduImmoBridge.php index 5d050ae6..a2e2b335 100644 --- a/bridges/ParuVenduImmoBridge.php +++ b/bridges/ParuVenduImmoBridge.php @@ -29,15 +29,15 @@ class ParuVenduImmoBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request paruvendu.'); - foreach($html->find('div.annonce a') as $element){ + foreach($html->find('div.annonce a') as $element) { - if(!$element->title){ + if(!$element->title) { continue; } $img = ''; - foreach($element->find('span.img img') as $img){ - if($img->original){ + foreach($element->find('span.img img') as $img) { + if($img->original) { $img = ''; } } @@ -65,33 +65,33 @@ class ParuVenduImmoBridge extends BridgeAbstract { . $appartment . $maison; - if($this->getInput('minarea')){ + if($this->getInput('minarea')) { $link .= '&sur0=' . urlencode($this->getInput('minarea')); } - if($this->getInput('maxprice')){ + if($this->getInput('maxprice')) { $link .= '&px1=' . urlencode($this->getInput('maxprice')); } - if($this->getInput('pa')){ + if($this->getInput('pa')) { $link .= '&pa=' . urlencode($this->getInput('pa')); } - if($this->getInput('lo')){ + if($this->getInput('lo')) { $link .= '&lo=' . urlencode($this->getInput('lo')); } return $link; } public function getName(){ - if(!is_null($this->getInput('minarea'))){ + if(!is_null($this->getInput('minarea'))) { $request = ''; $minarea = $this->getInput('minarea'); - if(!empty($minarea)){ + if(!empty($minarea)) { $request .= ' ' . $minarea . ' m2'; } $location = $this->getInput('lo'); - if(!empty($location)){ + if(!empty($location)) { $request .= ' In: ' . $location; } return 'Paru Vendu Immobilier' . $request; diff --git a/bridges/PickyWallpapersBridge.php b/bridges/PickyWallpapersBridge.php index 340474e3..6c26df7a 100644 --- a/bridges/PickyWallpapersBridge.php +++ b/bridges/PickyWallpapersBridge.php @@ -34,16 +34,16 @@ class PickyWallpapersBridge extends BridgeAbstract { $max = $this->getInput('m'); $resolution = $this->getInput('r'); // Wide wallpaper default - for($page = 1; $page <= $lastpage; $page++){ + for($page = 1; $page <= $lastpage; $page++) { $html = getSimpleHTMLDOM($this->getURI() . '/page-' . $page . '/') or returnServerError('No results for this query.'); - if($page === 1){ + if($page === 1) { preg_match('/page-(\d+)\/$/', $html->find('.pages li a', -2)->href, $matches); $lastpage = min($matches[1], ceil($max / 12)); } - foreach($html->find('.items li img') as $element){ + foreach($html->find('.items li img') as $element) { $item = array(); $item['uri'] = str_replace('www', 'wallpaper', self::URI) . '/' @@ -70,7 +70,7 @@ class PickyWallpapersBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('s')) && !is_null($this->getInput('r')) && !is_null($this->getInput('c'))){ + if(!is_null($this->getInput('s')) && !is_null($this->getInput('r')) && !is_null($this->getInput('c'))) { $subcategory = $this->getInput('s'); $link = self::URI . $this->getInput('r') @@ -86,7 +86,7 @@ class PickyWallpapersBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('s'))){ + if(!is_null($this->getInput('s'))) { $subcategory = $this->getInput('s'); return 'PickyWallpapers - ' . $this->getInput('c') diff --git a/bridges/PinterestBridge.php b/bridges/PinterestBridge.php index 13815d87..c5282ff5 100644 --- a/bridges/PinterestBridge.php +++ b/bridges/PinterestBridge.php @@ -32,9 +32,9 @@ class PinterestBridge extends FeedExpander { ); public function collectData(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By username and board': - if($this->getInput('r')){ + if($this->getInput('r')) { $html = getSimpleHTMLDOMCached($this->getURI()); $this->getUserResults($html); } else { @@ -55,7 +55,7 @@ class PinterestBridge extends FeedExpander { $fullname = $json['resourceDataCache'][0]['data']['owner']['full_name']; $avatar = $json['resourceDataCache'][0]['data']['owner']['image_small_url']; - foreach($results as $result){ + foreach($results as $result) { $item = array(); $item['uri'] = $result['link']; @@ -97,7 +97,7 @@ class PinterestBridge extends FeedExpander { $json = json_decode($html->find('#jsInit1', 0)->innertext, true); $results = $json['resourceDataCache'][0]['data']['results']; - foreach($results as $result){ + foreach($results as $result) { $item = array(); $item['uri'] = self::URI . $result['board']['url']; @@ -136,7 +136,7 @@ class PinterestBridge extends FeedExpander { } public function getURI(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By username and board': $uri = self::URI . '/' . urlencode($this->getInput('u')) . '/' . urlencode($this->getInput('b'));// . '.rss'; break; @@ -149,7 +149,7 @@ class PinterestBridge extends FeedExpander { } public function getName(){ - switch($this->queriedContext){ + switch($this->queriedContext) { case 'By username and board': $specific = $this->getInput('u') . ' - ' . $this->getInput('b'); break; diff --git a/bridges/PlanetLibreBridge.php b/bridges/PlanetLibreBridge.php index ecf687bd..03a6024d 100644 --- a/bridges/PlanetLibreBridge.php +++ b/bridges/PlanetLibreBridge.php @@ -16,8 +16,8 @@ class PlanetLibreBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request PlanetLibre.'); $limit = 0; - foreach($html->find('div.post') as $element){ - if($limit < 5){ + foreach($html->find('div.post') as $element) { + if($limit < 5) { $item = array(); $item['title'] = $element->find('h1', 0)->plaintext; $item['uri'] = $element->find('a', 0)->href; diff --git a/bridges/RTBFBridge.php b/bridges/RTBFBridge.php index e622a055..22cdaf41 100644 --- a/bridges/RTBFBridge.php +++ b/bridges/RTBFBridge.php @@ -22,8 +22,8 @@ class RTBFBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request RTBF.'); - foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element){ - if($count >= $limit){ + foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) { + if($count >= $limit) { break; } @@ -49,7 +49,7 @@ class RTBFBridge extends BridgeAbstract { } public function getURI(){ - if(!is_null($this->getInput('c'))){ + if(!is_null($this->getInput('c'))) { return self::URI . 'emissions/detail?id=' . $this->getInput('c'); } @@ -57,7 +57,7 @@ class RTBFBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('c'))){ + if(!is_null($this->getInput('c'))) { return $this->getInput('c') .' - RTBF Bridge'; } diff --git a/bridges/RainbowSixSiegeBridge.php b/bridges/RainbowSixSiegeBridge.php index 1e0fa9db..302bb896 100644 --- a/bridges/RainbowSixSiegeBridge.php +++ b/bridges/RainbowSixSiegeBridge.php @@ -17,7 +17,7 @@ class RainbowSixSiegeBridge extends BridgeAbstract { $json = $json['items']; // Start at index 2 to remove highlighted articles - for($i = 0; $i < count($json); $i++){ + for($i = 0; $i < count($json); $i++) { $jsonItem = $json[$i]['Content']; $article = str_get_html($jsonItem); diff --git a/bridges/ReadComicsBridge.php b/bridges/ReadComicsBridge.php index 8540fe3e..33c8ed9e 100644 --- a/bridges/ReadComicsBridge.php +++ b/bridges/ReadComicsBridge.php @@ -26,11 +26,11 @@ class ReadComicsBridge extends BridgeAbstract { } $keywordsList = explode(";", $this->getInput('q')); - foreach($keywordsList as $keywords){ + foreach($keywordsList as $keywords) { $html = $this->getSimpleHTMLDOM(self::URI . 'comic/' . rawurlencode($keywords)) or $this->returnServerError('Could not request readcomics.tv.'); - foreach($html->find('li') as $element){ + foreach($html->find('li') as $element) { $item = array(); $item['uri'] = $element->find('a.ch-name', 0)->href; $item['id'] = $item['uri']; diff --git a/bridges/Releases3DSBridge.php b/bridges/Releases3DSBridge.php index c14e576e..a7e1778e 100644 --- a/bridges/Releases3DSBridge.php +++ b/bridges/Releases3DSBridge.php @@ -10,7 +10,7 @@ class Releases3DSBridge extends BridgeAbstract { public function collectData(){ function extractFromDelimiters($string, $start, $end){ - if(strpos($string, $start) !== false){ + if(strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; @@ -20,7 +20,7 @@ class Releases3DSBridge extends BridgeAbstract { } function typeToString($type){ - switch($type){ + switch($type) { case 1: return '3DS Game'; case 4: return 'eShop'; default: return '??? (' . $type . ')'; @@ -28,7 +28,7 @@ class Releases3DSBridge extends BridgeAbstract { } function cardToString($card){ - switch($card){ + switch($card) { case 1: return 'Regular (CARD1)'; case 2: return 'NAND (CARD2)'; default: return '??? (' . $card . ')'; @@ -40,17 +40,17 @@ class Releases3DSBridge extends BridgeAbstract { or returnServerError('Could not request 3dsdb: ' . $dataUrl); $limit = 0; - foreach(array_reverse(explode('', $xml)) as $element){ - if($limit >= 5){ + foreach(array_reverse(explode('', $xml)) as $element) { + if($limit >= 5) { break; } - if(strpos($element, '') === false){ + if(strpos($element, '') === false) { continue; } $releasename = extractFromDelimiters($element, '', ''); - if(empty($releasename)){ + if(empty($releasename)) { continue; } @@ -77,7 +77,7 @@ class Releases3DSBridge extends BridgeAbstract { $ignCoverArt = ''; $ignSearchUrl = 'http://www.ign.com/search?q=' . urlencode($name); - if($ignResult = getSimpleHTMLDOM($ignSearchUrl)){ + if($ignResult = getSimpleHTMLDOM($ignSearchUrl)) { $ignCoverArt = $ignResult->find('div.search-item-media', 0)->find('img', 0)->src; $ignDesc = $ignResult->find('div.search-item-description', 0)->plaintext; $ignLink = $ignResult->find('div.search-item-sub-title', 0)->find('a', 1)->href; diff --git a/bridges/ReporterreBridge.php b/bridges/ReporterreBridge.php index dff8818f..db1104c1 100644 --- a/bridges/ReporterreBridge.php +++ b/bridges/ReporterreBridge.php @@ -9,7 +9,7 @@ class ReporterreBridge extends BridgeAbstract { private function extractContent($url){ $html2 = getSimpleHTMLDOM($url); - foreach($html2->find('div[style=text-align:justify]') as $e){ + foreach($html2->find('div[style=text-align:justify]') as $e) { $text = $e->outertext; } @@ -32,7 +32,7 @@ class ReporterreBridge extends BridgeAbstract { or returnServerError('Could not request Reporterre.'); $limit = 0; - foreach($html->find('item') as $element){ + foreach($html->find('item') as $element) { if($limit < 5) { $item = array(); $item['title'] = html_entity_decode($element->find('title', 0)->plaintext); diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php index aefd29ff..2107aa3d 100644 --- a/bridges/ScmbBridge.php +++ b/bridges/ScmbBridge.php @@ -12,7 +12,7 @@ class ScmbBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request Se Coucher Moins Bete.'); - foreach($html->find('article') as $article){ + foreach($html->find('article') as $article) { $item = array(); $item['uri'] = self::URI . $article->find('p.summary a', 0)->href; $item['title'] = $article->find('header h1 a', 0)->innertext; diff --git a/bridges/ScoopItBridge.php b/bridges/ScoopItBridge.php index 21c7aa1b..997837da 100644 --- a/bridges/ScoopItBridge.php +++ b/bridges/ScoopItBridge.php @@ -21,7 +21,7 @@ class ScoopItBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($link) or returnServerError('Could not request ScoopIt. for : ' . $link); - foreach($html->find('div.post-view') as $element){ + foreach($html->find('div.post-view') as $element) { $item = array(); $item['uri'] = $element->find('a', 0)->href; $item['title'] = preg_replace( diff --git a/bridges/SensCritiqueBridge.php b/bridges/SensCritiqueBridge.php index d8ba094d..7ac35f2c 100644 --- a/bridges/SensCritiqueBridge.php +++ b/bridges/SensCritiqueBridge.php @@ -36,10 +36,10 @@ class SensCritiqueBridge extends BridgeAbstract { public function collectData(){ $categories = array(); - foreach(self::PARAMETERS[$this->queriedContext] as $category => $properties){ - if($this->getInput($category)){ + foreach(self::PARAMETERS[$this->queriedContext] as $category => $properties) { + if($this->getInput($category)) { $uri = self::URI; - switch($category){ + switch($category) { case 'm': $uri .= 'films/cette-semaine'; break; case 's': $uri .= 'series/actualite'; @@ -63,11 +63,11 @@ class SensCritiqueBridge extends BridgeAbstract { } private function extractDataFromList($list){ - if($list === null){ + if($list === null) { returnClientError('Cannot extract data from list'); } - foreach($list->find('li') as $movie){ + foreach($list->find('li') as $movie) { $item = array(); $item['author'] = htmlspecialchars_decode($movie->find('.elco-title a', 0)->plaintext, ENT_QUOTES) . ' ' diff --git a/bridges/SexactuBridge.php b/bridges/SexactuBridge.php index 8446a296..5bc552ab 100644 --- a/bridges/SexactuBridge.php +++ b/bridges/SexactuBridge.php @@ -24,11 +24,11 @@ class SexactuBridge extends BridgeAbstract { $sexactu = $html->find('.container_sexactu', 0); $rowList = $sexactu->find('.row'); - foreach($rowList as $row){ + foreach($rowList as $row) { // only use first list as second one only contains pages numbers $title = $row->find('.title', 0); - if($title){ + if($title) { $item = array(); $item['author'] = self::AUTHOR; $item['title'] = $title->plaintext; @@ -36,9 +36,9 @@ class SexactuBridge extends BridgeAbstract { $uri = $title->$urlAttribute; if($uri === false) continue; - if(substr($uri, 0, 1) === 'h'){ // absolute uri + if(substr($uri, 0, 1) === 'h') { // absolute uri $item['uri'] = $uri; - } else if(substr($uri, 0, 1) === '/'){ // domain relative url + } else if(substr($uri, 0, 1) === '/') { // domain relative url $item['uri'] = self::URI . $uri; } else { $item['uri'] = $this->getURI() . $uri; @@ -66,7 +66,7 @@ class SexactuBridge extends BridgeAbstract { $html = getSimpleHTMLDOMCached($uri); $content = $html->find('#article', 0); - if($content){ + if($content) { return $content; } diff --git a/bridges/ShanaprojectBridge.php b/bridges/ShanaprojectBridge.php index cdf8ed25..e86f7729 100644 --- a/bridges/ShanaprojectBridge.php +++ b/bridges/ShanaprojectBridge.php @@ -110,7 +110,7 @@ class ShanaprojectBridge extends BridgeAbstract { if(!$animes) returnServerError('Could not find anime headers!'); - foreach($animes as $anime){ + foreach($animes as $anime) { $item = array(); $item['title'] = $this->extractAnimeTitle($anime); $item['author'] = $this->extractAnimeAuthor($anime); diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index ea80d56a..92d77daa 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -32,7 +32,7 @@ class SoundCloudBridge extends BridgeAbstract { . self::CLIENT_ID )) or returnServerError('No results for this user'); - for($i = 0; $i < 10; $i++){ + for($i = 0; $i < 10; $i++) { $item = array(); $item['author'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title; $item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title; @@ -55,7 +55,7 @@ class SoundCloudBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return self::NAME . ' - ' . $this->getInput('u'); } diff --git a/bridges/StripeAPIChangeLogBridge.php b/bridges/StripeAPIChangeLogBridge.php index 721b46ad..22ef3816 100644 --- a/bridges/StripeAPIChangeLogBridge.php +++ b/bridges/StripeAPIChangeLogBridge.php @@ -10,7 +10,7 @@ class StripeAPIChangeLogBridge extends BridgeAbstract { $html = getSimpleHTMLDOM(self::URI) or returnServerError('No results for Stripe API Changelog'); - foreach($html->find('h3') as $change){ + foreach($html->find('h3') as $change) { $item = array(); $item['title'] = trim($change->plaintext); $item['uri'] = self::URI . '#' . $item['title']; diff --git a/bridges/SuperbWallpapersBridge.php b/bridges/SuperbWallpapersBridge.php index 874f3abf..610dd323 100644 --- a/bridges/SuperbWallpapersBridge.php +++ b/bridges/SuperbWallpapersBridge.php @@ -38,12 +38,12 @@ class SuperbWallpapersBridge extends BridgeAbstract { $lastpage = min($html->find('.paging .cpage', 0)->innertext(), ceil($max / 36)); - for($page = 1; $page <= $lastpage; $page++){ + for($page = 1; $page <= $lastpage; $page++) { $link = self::URI . '/' . $category . '/' . $page . '.html'; $html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.'); - foreach($html->find('.wpl .i a') as $element){ + foreach($html->find('.wpl .i a') as $element) { $thumbnail = $element->find('img', 0); $item = array(); @@ -61,7 +61,7 @@ class SuperbWallpapersBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))){ + if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))) { return self::NAME . '- ' . $this->getInput('c') . ' [' . $this->getInput('r') . ']'; } diff --git a/bridges/T411Bridge.php b/bridges/T411Bridge.php index 040dd0d0..15cf628b 100644 --- a/bridges/T411Bridge.php +++ b/bridges/T411Bridge.php @@ -18,7 +18,7 @@ class T411Bridge extends BridgeAbstract { //Utility function for retrieving text based on start and end delimiters function extractFromDelimiters($string, $start, $end){ - if(strpos($string, $start) !== false){ + if(strpos($string, $start) !== false) { $section_retrieved = substr($string, strpos($string, $start) + strlen($start)); $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end)); return $section_retrieved; @@ -42,13 +42,13 @@ class T411Bridge extends BridgeAbstract { $limit = 0; //Process each item individually - foreach($results->find('tr') as $element){ + foreach($results->find('tr') as $element) { //Limit total amount of requests and ignore table header - if($limit >= 10){ + if($limit >= 10) { break; } - if(is_object($element->find('th', 0))){ + if(is_object($element->find('th', 0))) { continue; } @@ -65,7 +65,7 @@ class T411Bridge extends BridgeAbstract { //Retrieve full description from torrent page $item_html = getSimpleHTMLDOM($item_uri); - if(!$item_html){ + if(!$item_html) { continue; } diff --git a/bridges/TagBoardBridge.php b/bridges/TagBoardBridge.php index d2f74bfe..b79847e6 100644 --- a/bridges/TagBoardBridge.php +++ b/bridges/TagBoardBridge.php @@ -21,12 +21,12 @@ class TagBoardBridge extends BridgeAbstract { or returnServerError('Could not request TagBoard for : ' . $link); $parsed_json = json_decode($html); - foreach($parsed_json->{'posts'} as $element){ + foreach($parsed_json->{'posts'} as $element) { $item = array(); $item['uri'] = $element->{'permalink'}; $item['title'] = $element->{'text'}; $thumbnailUri = $element->{'photos'}[0]->{'m'}; - if(isset($thumbnailUri)){ + if(isset($thumbnailUri)) { $item['content'] = '
getImageURI($tweet); - if(!$this->getInput('noimg') && !is_null($image)){ + if(!$this->getInput('noimg') && !is_null($image)) { // add enclosures $item['enclosures'] = array($image . ':orig'); @@ -182,7 +182,7 @@ EOD; // add quoted tweet $quotedTweet = $tweet->find('div.QuoteTweet', 0); - if($quotedTweet){ + if($quotedTweet) { // get tweet text $cleanedQuotedTweet = str_replace( 'href="/', @@ -196,7 +196,7 @@ EOD; // Add embeded image to content $quotedImage_html = ''; $quotedImage = $this->getQuotedImageURI($tweet); - if(!$this->getInput('noimg') && !is_null($quotedImage)){ + if(!$this->getInput('noimg') && !is_null($quotedImage)) { // add enclosures $item['enclosures'] = array($quotedImage . ':orig'); @@ -228,15 +228,15 @@ EOD; private function processEmojis($tweet){ // process emojis (reduce size) - foreach($tweet->find('img.Emoji') as $img){ + foreach($tweet->find('img.Emoji') as $img) { $img->style .= ' height: 1em;'; } } private function processContentLinks($tweet){ // processing content links - foreach($tweet->find('a') as $link){ - if($link->hasAttribute('data-expanded-url')){ + foreach($tweet->find('a') as $link) { + if($link->hasAttribute('data-expanded-url')) { $link->href = $link->getAttribute('data-expanded-url'); } $link->removeAttribute('data-expanded-url'); @@ -260,7 +260,7 @@ EOD; private function getImageURI($tweet){ // Find media in tweet $container = $tweet->find('div.AdaptiveMedia-container', 0); - if($container && $container->find('img', 0)){ + if($container && $container->find('img', 0)) { return $container->find('img', 0)->src; } @@ -270,7 +270,7 @@ EOD; private function getQuotedImageURI($tweet){ // Find media in tweet $container = $tweet->find('div.QuoteMedia-container', 0); - if($container && $container->find('img', 0)){ + if($container && $container->find('img', 0)) { return $container->find('img', 0)->src; } diff --git a/bridges/UnsplashBridge.php b/bridges/UnsplashBridge.php index 3a3514b1..ee1040a9 100644 --- a/bridges/UnsplashBridge.php +++ b/bridges/UnsplashBridge.php @@ -32,12 +32,12 @@ class UnsplashBridge extends BridgeAbstract { $quality = $this->getInput('q'); $lastpage = 1; - for($page = 1; $page <= $lastpage; $page++){ + for($page = 1; $page <= $lastpage; $page++) { $link = self::URI . '/grid?page=' . $page; $html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.'); - if($page === 1){ + if($page === 1) { preg_match( '/=(\d+)$/', $html->find('.pagination > a[!class]', -1)->href, @@ -47,7 +47,7 @@ class UnsplashBridge extends BridgeAbstract { $lastpage = min($matches[1], ceil($max / 40)); } - foreach($html->find('.photo') as $element){ + foreach($html->find('.photo') as $element) { $thumbnail = $element->find('img', 0); $thumbnail->src = str_replace('https://', 'http://', $thumbnail->src); diff --git a/bridges/UsbekEtRicaBridge.php b/bridges/UsbekEtRicaBridge.php index 27d847a9..4d5ba169 100644 --- a/bridges/UsbekEtRicaBridge.php +++ b/bridges/UsbekEtRicaBridge.php @@ -31,11 +31,11 @@ class UsbekEtRicaBridge extends BridgeAbstract { $articles = $html->find('div.details'); - foreach($articles as $article){ + foreach($articles as $article) { $item = array(); $title = $article->find('div.card-title', 0); - if($title){ + if($title) { $item['title'] = $title->plaintext; } else { // Sometimes we get rubbish, ignore. @@ -43,32 +43,32 @@ class UsbekEtRicaBridge extends BridgeAbstract { } $author = $article->find('div.author span', 0); - if($author){ + if($author) { $item['author'] = $author->plaintext; } $uri = $article->find('a.read', 0)->href; - if(substr($uri, 0, 1) === 'h'){ // absolute uri + if(substr($uri, 0, 1) === 'h') { // absolute uri $item['uri'] = $uri; } else { // relative uri $item['uri'] = $this->getURI() . $uri; } - if($fullarticle){ + if($fullarticle) { $content = $this->loadFullArticle($item['uri']); } - if($fullarticle && !is_null($content)){ + if($fullarticle && !is_null($content)) { $item['content'] = $content; } else { $excerpt = $article->find('div.card-excerpt', 0); - if($excerpt){ + if($excerpt) { $item['content'] = $excerpt->plaintext; } } $image = $article->find('div.card-img img', 0); - if($image){ + if($image) { $item['enclosures'] = array( $image->src ); @@ -76,7 +76,7 @@ class UsbekEtRicaBridge extends BridgeAbstract { $this->items[] = $item; - if($limit > 0 && count($this->items) >= $limit){ + if($limit > 0 && count($this->items) >= $limit) { break; } } @@ -91,7 +91,7 @@ class UsbekEtRicaBridge extends BridgeAbstract { $html = getSimpleHTMLDOMCached($uri); $content = $html->find('section.main', 0); - if($content){ + if($content) { return $this->replaceUriInHtmlElement($content); } diff --git a/bridges/ViadeoCompanyBridge.php b/bridges/ViadeoCompanyBridge.php index 127c64a7..3f761880 100644 --- a/bridges/ViadeoCompanyBridge.php +++ b/bridges/ViadeoCompanyBridge.php @@ -22,9 +22,9 @@ class ViadeoCompanyBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($link) or returnServerError('Could not request Viadeo.'); - foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element){ + foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) { $title = $element->find('p', 0)->innertext; - if($title){ + if($title) { $item = array(); $item['uri'] = $link; $item['title'] = mb_substr($element->find('p', 0)->innertext, 0, 100); diff --git a/bridges/VineBridge.php b/bridges/VineBridge.php index 52e1240a..61534a04 100644 --- a/bridges/VineBridge.php +++ b/bridges/VineBridge.php @@ -20,7 +20,7 @@ class VineBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($uri) or returnServerError('No results for this query.'); - foreach($html->find('.post') as $element){ + foreach($html->find('.post') as $element) { $a = $element->find('a', 0); $a->href = str_replace('https://', 'http://', $a->href); $time = strtotime(ltrim($element->find('p', 0)->plaintext, ' Uploaded at ')); diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php index 9c5d002a..9981da12 100644 --- a/bridges/VkBridge.php +++ b/bridges/VkBridge.php @@ -16,7 +16,7 @@ class VkBridge extends BridgeAbstract { ); public function getURI(){ - if(!is_null($this->getInput('u'))){ + if(!is_null($this->getInput('u'))) { return static::URI . urlencode($this->getInput('u')); } @@ -33,15 +33,15 @@ class VkBridge extends BridgeAbstract { $text_html = iconv('windows-1251', 'utf-8', $text_html); $html = str_get_html($text_html); - foreach($html->find('.post') as $post){ + foreach($html->find('.post') as $post) { - if(is_object($post->find('a.wall_post_more', 0))){ + if(is_object($post->find('a.wall_post_more', 0))) { //delete link "show full" in content $post->find('a.wall_post_more', 0)->outertext = ''; } $item = array(); $item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '
'); - if(is_object($post->find('a.page_media_link_title', 0))){ + if(is_object($post->find('a.page_media_link_title', 0))) { $link = $post->find('a.page_media_link_title', 0)->getAttribute('href'); //external link in the post @@ -50,7 +50,7 @@ class VkBridge extends BridgeAbstract { } //get video on post - if(is_object($post->find('span.post_video_title_content', 0))){ + if(is_object($post->find('span.post_video_title_content', 0))) { $titleVideo = $post->find('span.post_video_title_content', 0)->plaintext; $linkToVideo = self::URI . $post->find('a.page_post_thumb_video', 0)->getAttribute('href'); $item['content'] .= "\n\r {$titleVideo}: {$linkToVideo}"; diff --git a/bridges/WallpaperStopBridge.php b/bridges/WallpaperStopBridge.php index 87be0d15..3578e714 100644 --- a/bridges/WallpaperStopBridge.php +++ b/bridges/WallpaperStopBridge.php @@ -35,7 +35,7 @@ class WallpaperStopBridge extends BridgeAbstract { $max = $this->getInput('m'); $lastpage = 1; - for($page = 1; $page <= $lastpage; $page++){ + for($page = 1; $page <= $lastpage; $page++) { $link = self::URI . '/' . $category @@ -48,14 +48,14 @@ class WallpaperStopBridge extends BridgeAbstract { $html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.'); - if($page === 1){ + if($page === 1) { preg_match('/-(\d+)\.html$/', $html->find('.pagination > .last', 0)->href, $matches); $lastpage = min($matches[1], ceil($max / 20)); } - foreach($html->find('article.item') as $element){ + foreach($html->find('article.item') as $element) { $wplink = $element->getAttribute('data-permalink'); - if(preg_match('%^' . self::URI . '/(.+)/([^/]+)-(\d+)\.html$%', $wplink, $matches)){ + if(preg_match('%^' . self::URI . '/(.+)/([^/]+)-(\d+)\.html$%', $wplink, $matches)) { $thumbnail = $element->find('img', 0); $item = array(); @@ -92,7 +92,7 @@ class WallpaperStopBridge extends BridgeAbstract { } public function getName(){ - if(!is_null($this->getInput('s')) && !is_null($this->getInput('c')) && !is_null($this->getInput('r'))){ + if(!is_null($this->getInput('s')) && !is_null($this->getInput('c')) && !is_null($this->getInput('r'))) { $subcategory = $this->getInput('s'); return 'WallpaperStop - ' . $this->getInput('c') diff --git a/bridges/WeLiveSecurityBridge.php b/bridges/WeLiveSecurityBridge.php index c2e4308c..466a4b28 100644 --- a/bridges/WeLiveSecurityBridge.php +++ b/bridges/WeLiveSecurityBridge.php @@ -7,7 +7,7 @@ class WeLiveSecurityBridge extends FeedExpander { const DESCRIPTION = 'Returns the newest articles.'; private function stripWithDelimiters($string, $start, $end){ - while(strpos($string, $start) !== false){ + 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)); $string = str_replace($section_to_remove, '', $string); @@ -21,7 +21,7 @@ class WeLiveSecurityBridge extends FeedExpander { $item = parent::parseItem($item); $article_html = getSimpleHTMLDOMCached($item['uri']); - if(!$article_html){ + if(!$article_html) { $item['content'] .= '

Could not request ' . $this->getName() . ': ' . $item['uri'] . '

'; return $item; } diff --git a/bridges/WebfailBridge.php b/bridges/WebfailBridge.php index a1060f4f..2a637407 100644 --- a/bridges/WebfailBridge.php +++ b/bridges/WebfailBridge.php @@ -49,7 +49,7 @@ class WebfailBridge extends BridgeAbstract { $type = array_search($this->getInput('type'), self::PARAMETERS[$this->queriedContext]['type']['values']); - switch(strtolower($type)){ + switch(strtolower($type)) { case 'facebook': case 'videos': $this->extractNews($html, $type); @@ -65,14 +65,14 @@ class WebfailBridge extends BridgeAbstract { private function extractNews($html, $type){ $news = $html->find('#main', 0)->find('a.wf-list-news'); - foreach($news as $element){ + foreach($news as $element) { $item = array(); $item['title'] = $this->fixTitle($element->find('div.wf-news-title', 0)->innertext); $item['uri'] = $this->getURI() . $element->href; $img = $element->find('img.wf-image', 0)->src; // Load high resolution image for 'facebook' - switch(strtolower($type)){ + switch(strtolower($type)) { case 'facebook': $img = $this->getImageHiResUri($item['uri']); break; @@ -80,7 +80,7 @@ class WebfailBridge extends BridgeAbstract { } $description = ''; - if(!is_null($element->find('div.wf-news-description', 0))){ + if(!is_null($element->find('div.wf-news-description', 0))) { $description = $element->find('div.wf-news-description', 0)->innertext; } @@ -98,19 +98,19 @@ class WebfailBridge extends BridgeAbstract { private function extractArticle($html){ $articles = $html->find('article'); - foreach($articles as $article){ + foreach($articles as $article) { $item = array(); $item['title'] = $this->fixTitle($article->find('a', 1)->innertext); // Images, videos and gifs are provided in their own unique way - if(!is_null($article->find('img.wf-image', 0))){ // Image type + if(!is_null($article->find('img.wf-image', 0))) { // Image type $item['uri'] = $this->getURI() . $article->find('a', 2)->href; $item['content'] = '
'; - } elseif(!is_null($article->find('div.wf-video', 0))){ // Video type + } elseif(!is_null($article->find('div.wf-video', 0))) { // Video type $videoId = $this->getVideoId($article->find('div.wf-play', 0)->onclick); $item['uri'] = 'https://youtube.com/watch?v=' . $videoId; $item['content'] = ''; - } elseif(!is_null($article->find('video[id*=gif-]', 0))){ // Gif type + } elseif(!is_null($article->find('video[id*=gif-]', 0))) { // Gif type $item['uri'] = $this->getURI() . $article->find('a', 2)->href; $item['content'] = '