style: Fix coding styles

This commit is contained in:
logmanoriginal 2017-02-14 17:28:07 +01:00
parent d8f5aa3c79
commit ff83410534
26 changed files with 109 additions and 114 deletions

View file

@ -22,7 +22,7 @@ class CopieDoubleBridge extends BridgeAbstract {
$pos = strpos($title, '<a'); $pos = strpos($title, '<a');
$title = substr($title, 0, $pos); $title = substr($title, 0, $pos);
$item['title'] = $title; $item['title'] = $title;
} elseif(strpos($element->innertext, "/images/suivant.gif") === false){ } elseif(strpos($element->innertext, '/images/suivant.gif') === false){
$a = $element->find('a', 0); $a = $element->find('a', 0);
$item['uri'] = self::URI . $a->href; $item['uri'] = self::URI . $a->href;
$content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext); $content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -25,8 +25,8 @@ if( !file_exists($vendorLibSimpleHtmlDom) ){
throw new \HttpException('"PHP Simple HTML DOM Parser" library is missing. 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 ' Get it from http://simplehtmldom.sourceforge.net and place the script "simple_html_dom.php" in '
. substr(PATH_VENDOR, 4) . substr(PATH_VENDOR, 4)
. '/simplehtmldom/' . '/simplehtmldom/',
, 500); 500);
} }
require_once $vendorLibSimpleHtmlDom; require_once $vendorLibSimpleHtmlDom;

View file

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

View file

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

View file

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