Browse Source

style: Fix coding styles

logmanoriginal 7 years ago
parent
commit
ff83410534

+ 3 - 3
bridges/CopieDoubleBridge.php

@@ -22,11 +22,11 @@ class CopieDoubleBridge extends BridgeAbstract {
 				$pos = strpos($title, '<a');
 				$title = substr($title, 0, $pos);
 				$item['title'] = $title;
-			} elseif(strpos($element->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);
-				$content = str_replace('href="/', 'href="' . self::URI,$content);
+				$content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext);
+				$content = str_replace('href="/', 'href="' . self::URI, $content);
 				$item['content'] = $content;
 				$this->items[] = $item;
 			}

+ 1 - 1
bridges/CpasbienBridge.php

@@ -20,7 +20,7 @@ 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'){
 

+ 1 - 1
bridges/FourchanBridge.php

@@ -54,7 +54,7 @@ class FourchanBridge extends BridgeAbstract {
 				}
 
 			$content = $element->find('.postMessage', 0)->innertext;
-			$content = str_replace('href="#p','href="' . $this->getURI() . '#p', $content);
+			$content = str_replace('href="#p', 'href="' . $this->getURI() . '#p', $content);
 			$item['content'] = '<span id="' . $item['id'] . '">' . $content . '</span>';
 
 			if(isset($item['image'])){

+ 1 - 1
bridges/FuturaSciencesBridge.php

@@ -148,7 +148,7 @@ class FuturaSciencesBridge extends FeedExpander {
 			'<div id="forumcomments',
 			'<div ng-if="active"'
 		) as $div_start) {
-			$contents = $this->stripRecursiveHTMLSection($contents , 'div', $div_start);
+			$contents = $this->stripRecursiveHTMLSection($contents, 'div', $div_start);
 		}
 
 		$contents = $this->stripWithDelimiters($contents, '<hr ', '/>');

+ 1 - 1
bridges/GiphyBridge.php

@@ -52,7 +52,7 @@ class GiphyBridge extends BridgeAbstract {
 					$title = preg_replace('/\s+/', ' ', $title);
 					$title = str_replace('animated GIF', '', $title);
 					$title = str_replace($kw, '', $title);
-					$title = preg_replace('/\s+/', ' ',$title);
+					$title = preg_replace('/\s+/', ' ', $title);
 					$title = trim($title);
 					if(strlen($title) <= 0){
 						$title = $item['id'];

+ 4 - 4
bridges/GooglePlusPostBridge.php

@@ -19,11 +19,11 @@ class GooglePlusPostBridge extends BridgeAbstract{
 
 	public function collectData(){
 		// get content parsed
-		$html = getSimpleHTMLDOMCached(self::URI . urlencode($this->getInput('username')) . '/posts'
+		$html = getSimpleHTMLDOMCached(self::URI . urlencode($this->getInput('username')) . '/posts',
 			// force language
-			, 84600
-			, false
-			, stream_context_create(array(
+			84600,
+			false,
+			stream_context_create(array(
 				'http' => array(
 					'header' => 'Accept-Language: fr,fr-be,fr-fr;q=0.8,en;q=0.4,en-us;q=0.2;*' . "\r\n"
 			)))

+ 12 - 12
bridges/KernelBugTrackerBridge.php

@@ -43,18 +43,18 @@ class KernelBugTrackerBridge extends BridgeAbstract {
 		$sorting = $this->getInput('sorting');
 
 		// We use the print preview page for simplicity
-		$html = getSimpleHTMLDOMCached($this->getURI() . '&format=multiple'
-		, 86400
-		, false
-		, null
-		, 0
-		, null
-		, true
-		, true
-		, DEFAULT_TARGET_CHARSET
-		, false // Do NOT remove line breaks
-		, DEFAULT_BR_TEXT
-		, DEFAULT_SPAN_TEXT);
+		$html = getSimpleHTMLDOMCached($this->getURI() . '&format=multiple',
+		86400,
+		false,
+		null,
+		0,
+		null,
+		true,
+		true,
+		DEFAULT_TARGET_CHARSET,
+		false, // Do NOT remove line breaks
+		DEFAULT_BR_TEXT,
+		DEFAULT_SPAN_TEXT);
 
 		if($html === false)
 			returnServerError('Failed to load page!');

+ 1 - 1
bridges/LWNprevBridge.php

@@ -73,7 +73,7 @@ class LWNprevBridge extends BridgeAbstract{
 				break;
 			case 'GAByline':
 				$text = $h2NextSibling->textContent;
-				$item['author'] = substr($text,strpos($text, 'by '));
+				$item['author'] = substr($text, strpos($text, 'by '));
 				break;
 			default:
 				$item['author'] = 'LWN';

+ 1 - 1
bridges/NextInpactBridge.php

@@ -21,7 +21,7 @@ class NextInpactBridge extends FeedExpander {
 		$text = '<p><em>'
 		. $html2->find('span.sub_title', 0)->innertext
 		. '</em></p><p><img src="'
-		. $html2->find('div.container_main_image_article', 0)->find('img.dedicated',0)->src
+		. $html2->find('div.container_main_image_article', 0)->find('img.dedicated', 0)->src
 		. '" alt="-" /></p><div>'
 		. $html2->find('div[itemprop=articleBody]', 0)->innertext
 		. '</div>';

+ 2 - 2
bridges/RTBFBridge.php

@@ -37,9 +37,9 @@ class RTBFBridge extends BridgeAbstract {
 
 			$thumbnailUriLastSrc = end($thumbnailUriSrcSet);
 			$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
-			$item['title'] = trim($element->find('h3',0)->plaintext)
+			$item['title'] = trim($element->find('h3', 0)->plaintext)
 			. ' - '
-			. trim($element->find('h4',0)->plaintext);
+			. trim($element->find('h4', 0)->plaintext);
 
 			$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
 			$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';

+ 1 - 1
bridges/ScoopItBridge.php

@@ -27,7 +27,7 @@ class ScoopItBridge extends BridgeAbstract {
 			$item['title'] = preg_replace(
 				'~[[:cntrl:]]~',
 				'',
-				$element->find('div.tCustomization_post_title',0)->plaintext
+				$element->find('div.tCustomization_post_title', 0)->plaintext
 			);
 
 			$item['content'] = preg_replace(

+ 2 - 2
bridges/ThePirateBayBridge.php

@@ -41,7 +41,7 @@ class ThePirateBayBridge extends BridgeAbstract {
 	public function collectData(){
 
 		function parseDateTimestamp($element){
-				$guessedDate = $element->find('font',0)->plaintext;
+				$guessedDate = $element->find('font', 0)->plaintext;
 				$guessedDate = explode('Uploaded ', $guessedDate)[1];
 				$guessedDate = explode(',', $guessedDate)[0];
 
@@ -70,7 +70,7 @@ class ThePirateBayBridge extends BridgeAbstract {
 					);
 				} elseif(explode('&nbsp;', $guessedDate)[0] == 'Y-day'){
 					$guessedDate = strptime(
-						explode('&nbsp;',$guessedDate)[1], '%H:%M'
+						explode('&nbsp;', $guessedDate)[1], '%H:%M'
 					);
 
 					$timestamp = mktime(

+ 7 - 7
bridges/TheTVDBBridge.php

@@ -98,13 +98,13 @@ class TheTVDBBridge extends BridgeAbstract {
 		return $serie['data']->seriesName;
 	}
 
-	private function getSeasonEpisodes($token
-	, $serie_id
-	, $season
-	, $seriename
-	, &$episodelist
-	, $nbepisodemin
-	, $page = 1){
+	private function getSeasonEpisodes($token,
+	$serie_id,
+	$season,
+	$seriename,
+	&$episodelist,
+	$nbepisodemin,
+	$page = 1){
 		$url = $this->getApiUri()
 		. 'series/'
 		. $serie_id

+ 2 - 2
bridges/Torrent9Bridge.php

@@ -47,7 +47,7 @@ class Torrent9Bridge extends BridgeAbstract {
 		$html = getSimpleHTMLDOM($page)
 			or returnServerError('No results for this query.');
 
-		foreach($html->find('table',0)->find('tr') as $episode){
+		foreach($html->find('table', 0)->find('tr') as $episode){
 			if($episode->parent->tag == 'tbody'){
 
 				$urlepisode = self::URI . $episode->find('a', 0)->getAttribute('href');
@@ -72,7 +72,7 @@ class Torrent9Bridge extends BridgeAbstract {
 				}
 
 				$item['id'] = $episode->find('a', 0)->getAttribute('href');
-				$item['uri'] = self::URI . $htmlepisode->find('.download',0)->getAttribute('href');
+				$item['uri'] = self::URI . $htmlepisode->find('.download', 0)->getAttribute('href');
 
 				$this->items[] = $item;
 			}

+ 1 - 1
bridges/ViadeoCompanyBridge.php

@@ -27,7 +27,7 @@ class ViadeoCompanyBridge extends BridgeAbstract {
 			if($title){
 				$item = array();
 				$item['uri'] = $link;
-				$item['title'] = mb_substr($element->find('p', 0)->innertext, 0 , 100);
+				$item['title'] = mb_substr($element->find('p', 0)->innertext, 0, 100);
 				$item['content'] = $element->find('p', 0)->innertext;;
 				$this->items[] = $item;
 				$i++;

+ 2 - 2
bridges/WebfailBridge.php

@@ -43,8 +43,8 @@ class WebfailBridge extends BridgeAbstract {
 	public function collectData(){
 		$html = getSimpleHTMLDOM($this->getURI() . $this->getInput('type'));
 
-		$type = array_search($this->getInput('type')
-		, self::PARAMETERS[$this->queriedContext]['type']['values']);
+		$type = array_search($this->getInput('type'),
+			self::PARAMETERS[$this->queriedContext]['type']['values']);
 
 		switch(strtolower($type)){
 		case 'facebook':

+ 1 - 1
bridges/WhydBridge.php

@@ -29,7 +29,7 @@ class WhydBridge extends BridgeAbstract {
 			) or returnServerError('No results for this query.');
 
 			for($j = 0; $j < 5; $j++){
-				if(strtolower($html->find('div.user', $j)->find('a',0)->plaintext) == strtolower($this->getInput('u'))){
+				if(strtolower($html->find('div.user', $j)->find('a', 0)->plaintext) == strtolower($this->getInput('u'))){
 					$html = getSimpleHTMLDOM(
 						self::URI . $html->find('div.user', $j)->find('a', 0)->getAttribute('href')
 					) or returnServerError('No results for this query');

+ 4 - 4
bridges/WikipediaBridge.php

@@ -135,10 +135,10 @@ class WikipediaBridge extends BridgeAbstract {
 	* used to specify a different fallback link than the first
 	* (e.g., -1 for the last)
 	*/
-	private function addTodaysFeaturedArticleGeneric($element
-	, $fullArticle
-	, $anchorText = '...'
-	, $anchorFallbackIndex = 0){
+	private function addTodaysFeaturedArticleGeneric($element,
+	$fullArticle,
+	$anchorText = '...',
+	$anchorFallbackIndex = 0){
 		// Clean the bottom of the featured article
 		if ($element->find('div', -1))
 			$element->find('div', -1)->outertext = '';

+ 1 - 1
bridges/ZDNetBridge.php

@@ -270,7 +270,7 @@ class ZDNetBridge extends BridgeAbstract {
 					'<div id="sharethrough',
 					'<div id="inpage-video'
 				) as $div_start){
-					$contents = stripRecursiveHtmlSection($contents , 'div', $div_start);
+					$contents = stripRecursiveHtmlSection($contents, 'div', $div_start);
 				}
 				$contents = stripWithDelimiters($contents, '<script', '</script>');
 				$contents = stripWithDelimiters($contents, '<meta itemprop="image"', '>');

+ 1 - 1
index.php

@@ -136,7 +136,7 @@ try {
 
 		$noproxy = filter_input(INPUT_GET, '_noproxy', FILTER_VALIDATE_BOOLEAN);
 		if(defined('PROXY_URL') && PROXY_BYBRIDGE && $noproxy){
-			define('NOPROXY',true);
+			define('NOPROXY', true);
 		}
 
 		$params = $_GET;

+ 1 - 1
lib/FeedExpander.php

@@ -149,7 +149,7 @@ abstract class FeedExpander extends BridgeAbstract {
 		if(isset($feedItem->guid)){
 			foreach($feedItem->guid->attributes() as $attribute => $value){
 				if($attribute === 'isPermaLink'
-				&& ($value === 'true' || filter_var($feedItem->guid,FILTER_VALIDATE_URL))){
+				&& ($value === 'true' || filter_var($feedItem->guid, FILTER_VALIDATE_URL))){
 					$item['uri'] = (string)$feedItem->guid;
 					break;
 				}

+ 3 - 3
lib/FormatAbstract.php

@@ -89,9 +89,9 @@ abstract class FormatAbstract implements FormatInterface {
 	 */
 	protected function sanitizeHtml($html)
 	{
-		$html = str_replace('<script','<&zwnj;script',$html); // Disable scripts, but leave them visible.
-		$html = str_replace('<iframe','<&zwnj;iframe',$html);
-		$html = str_replace('<link','<&zwnj;link',$html);
+		$html = str_replace('<script', '<&zwnj;script', $html); // Disable scripts, but leave them visible.
+		$html = str_replace('<iframe', '<&zwnj;iframe', $html);
+		$html = str_replace('<link', '<&zwnj;link', $html);
 		// We leave alone object and embed so that videos can play in RSS readers.
 		return $html;
 	}

+ 4 - 4
lib/RssBridge.php

@@ -21,12 +21,12 @@ require __DIR__ . '/error.php';
 require __DIR__ . '/contents.php';
 
 $vendorLibSimpleHtmlDom = __DIR__ . PATH_VENDOR . '/simplehtmldom/simple_html_dom.php';
-if( !file_exists($vendorLibSimpleHtmlDom) ){
+if(!file_exists($vendorLibSimpleHtmlDom)){
 	throw new \HttpException('"PHP Simple HTML DOM Parser" library is missing.
  Get it from http://simplehtmldom.sourceforge.net and place the script "simple_html_dom.php" in '
-		. substr(PATH_VENDOR,4)
-		. '/simplehtmldom/'
-	, 500);
+		. substr(PATH_VENDOR, 4)
+		. '/simplehtmldom/',
+	500);
 }
 require_once $vendorLibSimpleHtmlDom;
 

+ 42 - 47
lib/contents.php

@@ -1,10 +1,9 @@
 <?php
-function getContents($url
-, $use_include_path = false
-, $context = null
-, $offset = 0
-, $maxlen = null
-){
+function getContents($url,
+$use_include_path = false,
+$context = null,
+$offset = 0,
+$maxlen = null){
 	$contextOptions = array(
 		'http' => array(
 			'user_agent' => ini_get('user_agent'),
@@ -61,26 +60,25 @@ function getContents($url
 	return $content;
 }
 
-function getSimpleHTMLDOM($url
-	, $use_include_path = false
-	, $context = null
-	, $offset = 0
-	, $maxLen = null
-	, $lowercase = true
-	, $forceTagsClosed = true
-	, $target_charset = DEFAULT_TARGET_CHARSET
-	, $stripRN = true
-	, $defaultBRText = DEFAULT_BR_TEXT
-	, $defaultSpanText = DEFAULT_SPAN_TEXT
-){
+function getSimpleHTMLDOM($url,
+$use_include_path = false,
+$context = null,
+$offset = 0,
+$maxLen = null,
+$lowercase = true,
+$forceTagsClosed = true,
+$target_charset = DEFAULT_TARGET_CHARSET,
+$stripRN = true,
+$defaultBRText = DEFAULT_BR_TEXT,
+$defaultSpanText = DEFAULT_SPAN_TEXT){
 	$content = getContents($url, $use_include_path, $context, $offset, $maxLen);
-	return str_get_html($content
-		, $lowercase
-		, $forceTagsClosed
-		, $target_charset
-		, $stripRN
-		, $defaultBRText
-		, $defaultSpanText);
+	return str_get_html($content,
+	$lowercase,
+	$forceTagsClosed,
+	$target_charset,
+	$stripRN,
+	$defaultBRText,
+	$defaultSpanText);
 }
 
 /**
@@ -89,19 +87,18 @@ function getSimpleHTMLDOM($url
  * @param duration duration of the cache file in seconds (default: 24h/86400s)
  * @return content of the file as string
  */
-function getSimpleHTMLDOMCached($url
-	, $duration = 86400
-	, $use_include_path = false
-	, $context = null
-	, $offset = 0
-	, $maxLen = null
-	, $lowercase = true
-	, $forceTagsClosed = true
-	, $target_charset = DEFAULT_TARGET_CHARSET
-	, $stripRN = true
-	, $defaultBRText = DEFAULT_BR_TEXT
-	, $defaultSpanText = DEFAULT_SPAN_TEXT
-){
+function getSimpleHTMLDOMCached($url,
+$duration = 86400,
+$use_include_path = false,
+$context = null,
+$offset = 0,
+$maxLen = null,
+$lowercase = true,
+$forceTagsClosed = true,
+$target_charset = DEFAULT_TARGET_CHARSET,
+$stripRN = true,
+$defaultBRText = DEFAULT_BR_TEXT,
+$defaultSpanText = DEFAULT_SPAN_TEXT){
 	debugMessage('Caching url ' . $url . ', duration ' . $duration);
 
 	// Initialize cache
@@ -125,13 +122,11 @@ function getSimpleHTMLDOMCached($url
 		}
 	}
 
-	return str_get_html($content
-		, $lowercase
-		, $forceTagsClosed
-		, $target_charset
-		, $stripRN
-		, $defaultBRText
-		, $defaultSpanText);
+	return str_get_html($content,
+	$lowercase,
+	$forceTagsClosed,
+	$target_charset,
+	$stripRN,
+	$defaultBRText,
+	$defaultSpanText);
 }
-
-?>

+ 4 - 4
lib/html.php

@@ -257,10 +257,10 @@ CARD;
 	return $card;
 }
 
-function sanitize($textToSanitize
-	,$removedTags=array('script','iframe','input','form')
-	,$keptAttributes=array('title','href','src')
-	,$keptText=array()){
+function sanitize($textToSanitize,
+$removedTags = array('script', 'iframe', 'input', 'form'),
+$keptAttributes = array('title', 'href', 'src'),
+$keptText = array()){
 	$htmlContent = str_get_html($textToSanitize);
 
 	foreach($htmlContent->find('*[!b38fd2b1fe7f4747d6b1c1254ccd055e]') as $element){

+ 6 - 6
lib/validation.php

@@ -1,13 +1,13 @@
 <?php
-function validateData(&$data,$parameters){
+function validateData(&$data, $parameters){
 	$validateTextValue = function($value, $pattern = null){
 		if(!is_null($pattern)){
-			$filteredValue = filter_var($value
-				, FILTER_VALIDATE_REGEXP
-				, array('options' => array(
+			$filteredValue = filter_var($value,
+			FILTER_VALIDATE_REGEXP,
+			array('options' => array(
 					'regexp' => '/^' . $pattern . '$/'
-				))
-			);
+				)
+			));
 		} else {
 			$filteredValue = filter_var($value);
 		}