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

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

View file

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

View file

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

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

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