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');
$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);

View file

@ -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"
)))

View file

@ -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!');

View file

@ -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

View file

@ -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':

View file

@ -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 = '';

View file

@ -25,8 +25,8 @@ 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);
. '/simplehtmldom/',
500);
}
require_once $vendorLibSimpleHtmlDom;

View file

@ -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);
}
?>

View file

@ -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){

View file

@ -2,12 +2,12 @@
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);
}