From a4b9611e66d3095c943a5c63306965d4e4cbf839 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 29 Jul 2017 19:28:00 +0200 Subject: [PATCH] [phpcs] Add missing rules - Do not add spaces after opening or before closing parenthesis // Wrong if( !is_null($var) ) { ... } // Right if(!is_null($var)) { ... } - Add space after closing parenthesis // Wrong if(true){ ... } // Right if(true) { ... } - Add body into new line - Close body in new line // Wrong if(true) { ... } // Right if(true) { ... } Notice: Spaces after keywords are not detected: // Wrong (not detected) // -> space after 'if' and missing space after 'else' if (true) { ... } else{ ... } // Right if(true) { ... } else { ... } --- bridges/ABCTabsBridge.php | 3 +- bridges/AllocineFRBridge.php | 11 ++-- bridges/AmazonBridge.php | 2 +- bridges/AnimeUltimeBridge.php | 2 +- bridges/Arte7Bridge.php | 4 +- bridges/AskfmBridge.php | 8 +-- bridges/BandcampBridge.php | 6 +- bridges/BastaBridge.php | 4 +- bridges/BlaguesDeMerdeBridge.php | 4 +- bridges/BooruprojectBridge.php | 4 +- bridges/CADBridge.php | 2 +- bridges/CNETBridge.php | 12 ++-- bridges/CastorusBridge.php | 8 +-- bridges/CollegeDeFranceBridge.php | 4 +- bridges/CopieDoubleBridge.php | 6 +- bridges/CourrierInternationalBridge.php | 6 +- bridges/CpasbienBridge.php | 10 ++-- bridges/CryptomeBridge.php | 6 +- bridges/DailymotionBridge.php | 14 ++--- bridges/DansTonChatBridge.php | 2 +- bridges/DauphineLibereBridge.php | 2 +- bridges/DilbertBridge.php | 2 +- bridges/DuckDuckGoBridge.php | 2 +- bridges/EZTVBridge.php | 6 +- bridges/EliteDangerousGalnetBridge.php | 2 +- bridges/ElsevierBridge.php | 12 ++-- bridges/EstCeQuonMetEnProdBridge.php | 2 +- bridges/EtsyBridge.php | 8 +-- bridges/FB2Bridge.php | 16 +++--- bridges/FacebookBridge.php | 35 ++++++------ bridges/FeedExpanderExampleBridge.php | 4 +- bridges/FierPandaBridge.php | 2 +- bridges/FilterBridge.php | 8 +-- bridges/FlickrBridge.php | 12 ++-- bridges/FootitoBridge.php | 2 +- bridges/FourchanBridge.php | 12 ++-- bridges/FuturaSciencesBridge.php | 8 +-- bridges/GBAtempBridge.php | 18 +++--- bridges/GiphyBridge.php | 8 +-- bridges/GithubIssueBridge.php | 36 ++++++------ bridges/GithubSearchBridge.php | 7 +-- bridges/GizmodoBridge.php | 4 +- bridges/GoComicsBridge.php | 6 +- bridges/GooglePlusPostBridge.php | 12 ++-- bridges/GoogleSearchBridge.php | 8 +-- bridges/HDWallpapersBridge.php | 10 ++-- bridges/HentaiHavenBridge.php | 2 +- bridges/IdenticaBridge.php | 6 +- bridges/InstagramBridge.php | 16 +++--- bridges/IsoHuntBridge.php | 30 +++++----- bridges/JapanExpoBridge.php | 8 +-- bridges/KATBridge.php | 15 +++-- bridges/KernelBugTrackerBridge.php | 12 ++-- bridges/KununuBridge.php | 12 ++-- bridges/LWNprevBridge.php | 34 +++++------ bridges/LeBonCoinBridge.php | 8 +-- bridges/LeMondeInformatiqueBridge.php | 2 +- bridges/LegifranceJOBridge.php | 16 +++--- bridges/LesJoiesDuCodeBridge.php | 6 +- bridges/LinkedInCompanyBridge.php | 4 +- bridges/MangareaderBridge.php | 26 ++++----- bridges/MixCloudBridge.php | 6 +- bridges/MoebooruBridge.php | 2 +- bridges/MoinMoinBridge.php | 32 +++++------ bridges/MondeDiploBridge.php | 2 +- bridges/MsnMondeBridge.php | 4 +- bridges/NasaApodBridge.php | 2 +- bridges/NeuviemeArtBridge.php | 10 ++-- bridges/NextgovBridge.php | 4 +- bridges/NovelUpdatesBridge.php | 6 +- bridges/OpenClassroomsBridge.php | 4 +- bridges/ParuVenduImmoBridge.php | 22 +++---- bridges/PickyWallpapersBridge.php | 10 ++-- bridges/PinterestBridge.php | 12 ++-- bridges/PlanetLibreBridge.php | 4 +- bridges/RTBFBridge.php | 8 +-- bridges/RainbowSixSiegeBridge.php | 2 +- bridges/ReadComicsBridge.php | 4 +- bridges/Releases3DSBridge.php | 16 +++--- bridges/ReporterreBridge.php | 4 +- bridges/ScmbBridge.php | 2 +- bridges/ScoopItBridge.php | 2 +- bridges/SensCritiqueBridge.php | 10 ++-- bridges/SexactuBridge.php | 10 ++-- bridges/ShanaprojectBridge.php | 2 +- bridges/SoundcloudBridge.php | 4 +- bridges/StripeAPIChangeLogBridge.php | 2 +- bridges/SuperbWallpapersBridge.php | 6 +- bridges/T411Bridge.php | 10 ++-- bridges/TagBoardBridge.php | 6 +- bridges/TheCodingLoveBridge.php | 6 +- bridges/TheHackerNewsBridge.php | 10 ++-- bridges/ThePirateBayBridge.php | 18 +++--- bridges/TheTVDBBridge.php | 12 ++-- bridges/Torrent9Bridge.php | 12 ++-- bridges/TwitterBridge.php | 32 +++++------ bridges/UnsplashBridge.php | 6 +- bridges/UsbekEtRicaBridge.php | 20 +++---- bridges/ViadeoCompanyBridge.php | 4 +- bridges/VineBridge.php | 2 +- bridges/VkBridge.php | 10 ++-- bridges/WallpaperStopBridge.php | 10 ++-- bridges/WeLiveSecurityBridge.php | 4 +- bridges/WebfailBridge.php | 16 +++--- bridges/WhydBridge.php | 8 +-- bridges/WikiLeaksBridge.php | 18 +++--- bridges/WikipediaBridge.php | 24 ++++---- bridges/WordPressBridge.php | 10 ++-- bridges/WordPressPluginUpdateBridge.php | 2 +- bridges/WorldOfTanksBridge.php | 4 +- bridges/YoutubeBridge.php | 22 +++---- bridges/ZDNetBridge.php | 24 ++++---- caches/FileCache.php | 14 ++--- formats/AtomFormat.php | 6 +- formats/HtmlFormat.php | 10 ++-- formats/MrssFormat.php | 10 ++-- index.php | 42 +++++++------- lib/Bridge.php | 20 +++---- lib/BridgeAbstract.php | 76 ++++++++++++------------- lib/Cache.php | 10 ++-- lib/FeedExpander.php | 36 ++++++------ lib/Format.php | 16 +++--- lib/FormatAbstract.php | 8 +-- lib/RssBridge.php | 2 +- lib/contents.php | 18 +++--- lib/html.php | 48 ++++++++-------- lib/validation.php | 20 +++---- phpcs.xml | 9 +++ 128 files changed, 692 insertions(+), 694 deletions(-) diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index d44cba2..2e451e2 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 d5f2b7e..604199b 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 d7f77c5..cbc6119 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 caedba1..6c5427e 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 09a1ee4..3d7ae9d 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 4b1597d..e227461 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 28e9ba5..0527da0 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 11a31ac..17d3da7 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 12814a5..25c018a 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 1219b72..6815d37 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 761d77f..09e3e65 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 0abd02c..eefb705 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 119d353..3ed1331 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 { . '
' . $text . '
No updates available
Could not request ' . $this->getName() . ': ' . $item['uri'] . '
' diff --git a/bridges/WikipediaBridge.php b/bridges/WikipediaBridge.php index 17559b5..6b53440 100644 --- a/bridges/WikipediaBridge.php +++ b/bridges/WikipediaBridge.php @@ -43,7 +43,7 @@ class WikipediaBridge extends BridgeAbstract { )); public function getURI(){ - if(!is_null($this->getInput('language'))){ + if(!is_null($this->getInput('language'))) { return 'https://' . strtolower($this->getInput('language')) . '.wikipedia.org'; @@ -53,7 +53,7 @@ class WikipediaBridge extends BridgeAbstract { } public function getName(){ - switch($this->getInput('subject')){ + switch($this->getInput('subject')) { case 'tfa': $subject = WIKIPEDIA_SUBJECT_TFA; break; @@ -63,7 +63,7 @@ class WikipediaBridge extends BridgeAbstract { default: return parent::getName(); } - switch($subject){ + switch($subject) { case WIKIPEDIA_SUBJECT_TFA: $name = 'Today\'s featured article from ' . strtolower($this->getInput('language')) @@ -85,7 +85,7 @@ class WikipediaBridge extends BridgeAbstract { public function collectData(){ - switch($this->getInput('subject')){ + switch($this->getInput('subject')) { case 'tfa': $subject = WIKIPEDIA_SUBJECT_TFA; break; @@ -148,8 +148,8 @@ class WikipediaBridge extends BridgeAbstract { // The title and URI of the article can be found in an anchor containing // the string '...' in most wikis ('full article ...') $target = $element->find('p/a', $anchorFallbackIndex); - foreach($element->find('//a') as $anchor){ - if(strpos($anchor->innertext, $anchorText) !== false){ + foreach($element->find('//a') as $anchor) { + if(strpos($anchor->innertext, $anchorText) !== false) { $target = $anchor; break; } @@ -171,7 +171,7 @@ class WikipediaBridge extends BridgeAbstract { * Adds a new item to $items using a generic operation (should work for most (all?) wikis) */ private function addDidYouKnowGeneric($element, $fullArticle){ - foreach($element->find('ul', 0)->find('li') as $entry){ + foreach($element->find('ul', 0)->find('li') as $entry) { $item = array(); // We can only use the first anchor, there is no way of finding the 'correct' one if there are multiple @@ -216,7 +216,7 @@ class WikipediaBridge extends BridgeAbstract { * Implementation for de.wikipedia.org */ private function getContentsDe($html, $subject, $fullArticle){ - switch($subject){ + switch($subject) { case WIKIPEDIA_SUBJECT_TFA: $element = $html->find('div[id=mf-tfa]', 0); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle); @@ -234,7 +234,7 @@ class WikipediaBridge extends BridgeAbstract { * Implementation for fr.wikipedia.org */ private function getContentsFr($html, $subject, $fullArticle){ - switch($subject){ + switch($subject) { case WIKIPEDIA_SUBJECT_TFA: $element = $html->find('div[class=accueil_2017_cadre]', 0); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lire la suite'); @@ -252,7 +252,7 @@ class WikipediaBridge extends BridgeAbstract { * Implementation for en.wikipedia.org */ private function getContentsEn($html, $subject, $fullArticle){ - switch($subject){ + switch($subject) { case WIKIPEDIA_SUBJECT_TFA: $element = $html->find('div[id=mp-tfa]', 0); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle); @@ -270,7 +270,7 @@ class WikipediaBridge extends BridgeAbstract { * Implementation for eo.wikipedia.org */ private function getContentsEo($html, $subject, $fullArticle){ - switch($subject){ + switch($subject) { case WIKIPEDIA_SUBJECT_TFA: $element = $html->find('div[id=mf-artikolo-de-la-semajno]', 0); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle); @@ -288,7 +288,7 @@ class WikipediaBridge extends BridgeAbstract { * Implementation for nl.wikipedia.org */ private function getContentsNl($html, $subject, $fullArticle){ - switch($subject){ + switch($subject) { case WIKIPEDIA_SUBJECT_TFA: $element = $html->find('div[id=mf-uitgelicht]', 0); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lees meer'); diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index 954325e..b367adc 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -26,7 +26,7 @@ class WordPressBridge extends FeedExpander { $article_html = getSimpleHTMLDOMCached($item['uri']); $article = null; - switch(true){ + switch(true) { case !is_null($article_html->find('article', 0)): // most common content div $article = $article_html->find('article', 0); @@ -46,7 +46,7 @@ class WordPressBridge extends FeedExpander { break; } - if(!is_null($article)){ + if(!is_null($article)) { $item['content'] = $this->clearContent($article->innertext); } @@ -55,20 +55,20 @@ class WordPressBridge 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() . '/feed/atom/'); - }catch (HttpException $e){ + } catch (HttpException $e) { $this->collectExpandableDatas($this->getURI() . '/?feed=atom'); } diff --git a/bridges/WordPressPluginUpdateBridge.php b/bridges/WordPressPluginUpdateBridge.php index a57ba1c..cb57df8 100644 --- a/bridges/WordPressPluginUpdateBridge.php +++ b/bridges/WordPressPluginUpdateBridge.php @@ -66,7 +66,7 @@ class WordPressPluginUpdateBridge 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/WorldOfTanksBridge.php b/bridges/WorldOfTanksBridge.php index a894f6e..f783e29 100644 --- a/bridges/WorldOfTanksBridge.php +++ b/bridges/WorldOfTanksBridge.php @@ -29,7 +29,7 @@ class WorldOfTanksBridge extends BridgeAbstract { private $title = ''; public function getURI(){ - if(!is_null($this->getInput('lang'))){ + if(!is_null($this->getInput('lang'))) { $lang = $this->getInput('lang'); $uri = self::URI . $lang . '/news/'; if(!empty($this->getInput('category'))) { @@ -51,7 +51,7 @@ class WorldOfTanksBridge extends BridgeAbstract { debugMessage("loaded HTML from " . $this->getURI()); // customize name $this->title = $html->find('title', 0)->innertext; - foreach($html->find('.b-imgblock_ico') as $infoLink){ + foreach($html->find('.b-imgblock_ico') as $infoLink) { $this->parseLine($infoLink); } } diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 117b84a..dab3252 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -70,7 +70,7 @@ class YoutubeBridge extends BridgeAbstract { } private function ytBridgeParseXmlFeed($xml) { - foreach($xml->find('entry') as $element){ + foreach($xml->find('entry') as $element) { $title = $this->ytBridgeFixTitle($element->find('title', 0)->plaintext); $author = $element->find('name', 0)->plaintext; $desc = $element->find('media:description', 0)->innertext; @@ -92,14 +92,14 @@ class YoutubeBridge extends BridgeAbstract { private function ytBridgeParseHtmlListing($html, $element_selector, $title_selector){ $limit = 10; $count = 0; - foreach($html->find($element_selector) as $element){ - if($count < $limit){ + foreach($html->find($element_selector) as $element) { + if($count < $limit) { $author = ''; $desc = ''; $time = 0; $vid = str_replace('/watch?v=', '', $element->find('a', 0)->href); $title = $this->ytBridgeFixTitle($element->find($title_selector, 0)->plaintext); - if($title != '[Private Video]'){ + if($title != '[Private Video]') { $this->ytBridgeQueryVideoInfo($vid, $author, $desc, $time); $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); $count++; @@ -134,32 +134,32 @@ class YoutubeBridge extends BridgeAbstract { $url_feed = ''; $url_listing = ''; - if($this->getInput('u')){ /* User and Channel modes */ + if($this->getInput('u')) { /* User and Channel modes */ $this->request = $this->getInput('u'); $url_feed = self::URI . 'feeds/videos.xml?user=' . urlencode($this->request); $url_listing = self::URI . 'user/' . urlencode($this->request) . '/videos'; - } elseif($this->getInput('c')){ + } elseif($this->getInput('c')) { $this->request = $this->getInput('c'); $url_feed = self::URI . 'feeds/videos.xml?channel_id=' . urlencode($this->request); $url_listing = self::URI . 'channel/' . urlencode($this->request) . '/videos'; } - if(!empty($url_feed) && !empty($url_listing)){ - if($xml = $this->ytGetSimpleHTMLDOM($url_feed)){ + if(!empty($url_feed) && !empty($url_listing)) { + if($xml = $this->ytGetSimpleHTMLDOM($url_feed)) { $this->ytBridgeParseXmlFeed($xml); - } elseif($html = $this->ytGetSimpleHTMLDOM($url_listing)){ + } elseif($html = $this->ytGetSimpleHTMLDOM($url_listing)) { $this->ytBridgeParseHtmlListing($html, 'li.channels-content-item', 'h3'); } else { returnServerError("Could not request YouTube. Tried:\n - $url_feed\n - $url_listing"); } - } elseif($this->getInput('p')){ /* playlist mode */ + } elseif($this->getInput('p')) { /* playlist mode */ $this->request = $this->getInput('p'); $url_listing = self::URI . 'playlist?list=' . urlencode($this->request); $html = $this->ytGetSimpleHTMLDOM($url_listing) or returnServerError("Could not request YouTube. Tried:\n - $url_listing"); $this->ytBridgeParseHtmlListing($html, 'tr.pl-video', '.pl-video-title a'); $this->request = 'Playlist: ' . str_replace(' - YouTube', '', $html->find('title', 0)->plaintext); - } elseif($this->getInput('s')){ /* search mode */ + } elseif($this->getInput('s')) { /* search mode */ $this->request = $this->getInput('s'); $page = 1; if($this->getInput('pa')) diff --git a/bridges/ZDNetBridge.php b/bridges/ZDNetBridge.php index 5fb7e30..86e4b49 100644 --- a/bridges/ZDNetBridge.php +++ b/bridges/ZDNetBridge.php @@ -168,7 +168,7 @@ class ZDNetBridge extends BridgeAbstract { } 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; @@ -178,7 +178,7 @@ class ZDNetBridge extends BridgeAbstract { } 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); @@ -191,8 +191,8 @@ class ZDNetBridge extends BridgeAbstract { $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); @@ -218,7 +218,7 @@ class ZDNetBridge extends BridgeAbstract { $baseUri = self::URI; $feed = $this->getInput('feed'); - if(strpos($feed, 'downloads!') !== false){ + if(strpos($feed, 'downloads!') !== false) { $feed = str_replace('downloads!', '', $feed); $baseUri = str_replace('www.', 'downloads.', $baseUri); } @@ -227,8 +227,8 @@ class ZDNetBridge extends BridgeAbstract { or returnServerError('Could not request ZDNet: ' . $url); $limit = 0; - foreach($html->find('item') as $element){ - if($limit < 10){ + foreach($html->find('item') as $element) { + if($limit < 10) { $article_url = preg_replace( '/([^#]+)#ftag=.*/', '$1', @@ -242,11 +242,11 @@ class ZDNetBridge extends BridgeAbstract { $article = getSimpleHTMLDOM($article_url) or returnServerError('Could not request ZDNet: ' . $article_url); - if(!empty($article_author)){ + if(!empty($article_author)) { $author = $article_author; } else { $author = $article->find('meta[name=author]', 0); - if(is_object($author)){ + if(is_object($author)) { $author = $author->content; } else { $author = 'ZDNet'; @@ -254,7 +254,7 @@ class ZDNetBridge extends BridgeAbstract { } $thumbnail = $article->find('meta[itemprop=image]', 0); - if(is_object($thumbnail)){ + if(is_object($thumbnail)) { $thumbnail = $thumbnail->content; } else { $thumbnail = ''; @@ -269,14 +269,14 @@ class ZDNetBridge extends BridgeAbstract { '
by: ' . $item['author'] . '
Attachments: