"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/class/templatestfilters.php" between
wacko.6.1.16.zip and wacko.6.1.17.zip

About: WackoWiki is a multilingual Wiki-engine that supports WYTIWYG-editing, page rights (ACLs), design themes (skins), file upload, email notification and much more.

templatestfilters.php  (wacko.6.1.16):templatestfilters.php  (wacko.6.1.17)
skipping to change at line 14 skipping to change at line 14
{ {
exit; exit;
} }
/* /*
- bytes -- 1.2MB - bytes -- 1.2MB
*/ */
class TemplatestFilters extends TemplatestEscaper class TemplatestFilters extends TemplatestEscaper
{ {
protected $filters; protected array $filters;
function __construct() function __construct()
{ {
$this->filters = []; $this->filters = [];
foreach (get_class_methods(self::class) as $meth) foreach (get_class_methods(self::class) as $meth)
{ {
if (preg_match('/^filter_(\w+?)(_also_(\w+?))?$/', $meth, $match)) if (preg_match('/^filter_(\w+?)(_also_(\w+?))?$/', $meth, $match))
{ {
$this->filters[$match[1]] = [$this, $meth]; $this->filters[$match[1]] = [$this, $meth];
skipping to change at line 40 skipping to change at line 40
} }
} }
} }
// add user filter function // add user filter function
function filter($id, $func) function filter($id, $func)
{ {
$this->filters[$id] = $func; $this->filters[$id] = $func;
} }
function getFilters() function getFilters(): array
{ {
$list = []; $list = [];
foreach ($this->filters as $id => $func) foreach ($this->filters as $id => $func)
{ {
if (!(is_array($func) && $func[0] === $this)) if (!(is_array($func) && $func[0] === $this))
{ {
$list[$id] = $func; $list[$id] = $func;
} }
} }
skipping to change at line 119 skipping to change at line 119
return $value; return $value;
} }
function filter_default($value, $default) function filter_default($value, $default)
{ {
($value === null || $value === false) && $value = $default; ($value === null || $value === false) && $value = $default;
return $value; return $value;
} }
function filter_format($value, $fmt) function filter_format($value, $fmt): string
{ {
return sprintf($fmt, $value); return sprintf($fmt, $value);
} }
function filter_stringify($value) function filter_stringify($value)
{ {
return Ut::stringify($value); return Ut::stringify($value);
} }
function filter_date($value, $fmt) function filter_date($value, $fmt): string
{ {
return date($fmt, $value); return date($fmt, $value);
} }
function filter_join($value, $glue = '') function filter_join($value, $glue = ''): string
{ {
return implode($glue, $value); return implode($glue, $value);
} }
function filter_lower($value) function filter_lower($value): string
{ {
return mb_strtolower($value); return mb_strtolower($value);
} }
function filter_upper($value) function filter_upper($value): string
{ {
return mb_strtoupper($value); return mb_strtoupper($value);
} }
// TODO: localize formatting // TODO: localize formatting
function filter_number($value, $decimals = 0, $dec_point = ',', $thousand s_sep = '.') function filter_number($value, $decimals = 0, $dec_point = ',', $thousand s_sep = '.'): string
{ {
return number_format($value, $decimals, $dec_point, $thousands_se p); return number_format($value, (int) $decimals, $dec_point, $thousa nds_sep);
} }
function filter_void($value) function filter_void($value)
{ {
return null; return null;
} }
function filter_index($value, $path) function filter_index($value, $path)
{ {
if (str_starts_with($path, '.')) if (str_starts_with($path, '.'))
skipping to change at line 251 skipping to change at line 251
} }
/*function filter_spaceless($value) /*function filter_spaceless($value)
{ {
return preg_replace_callback('/>\s+</', function ($m) return preg_replace_callback('/>\s+</', function ($m)
{ {
return strpos($m[0], "\n")? '><' : '> <'; return strpos($m[0], "\n")? '><' : '> <';
}, $value); }, $value);
}*/ }*/
function filter_spaceless($value) function filter_spaceless($value): string
{ {
if (preg_match_all( if (preg_match_all(
'@ '@
<(?<script>script).*?<\/script\s*>| <(?<script>script).*?<\/script\s*>|
<(?<style>style).*?<\/style\s*>| <(?<style>style).*?<\/style\s*>|
<!(?<comment>--).*?-->| <!(?<comment>--).*?-->|
<(?<tag>[\/\w.:-]*)(?:".*?"|\'.*?\'|[^\'">]+)*>| <(?<tag>[\/\w.:-]*)(?:".*?"|\'.*?\'|[^\'">]+)*>|
(?<text>((<[^!\/\w.:-])?[^<]*)+)|@xsi', (?<text>((<[^!\/\w.:-])?[^<]*)+)|@xsi',
$value, $matches, PREG_SET_ORDER) === false) $value, $matches, PREG_SET_ORDER) === false)
{ {
skipping to change at line 328 skipping to change at line 328
} }
$html .= $content; $html .= $content;
} }
return $html; return $html;
} }
function filter_regex($value, $re, $to, $limit = -1, $strict = false) function filter_regex($value, $re, $to, $limit = -1, $strict = false)
{ {
$value = preg_replace($re, $to, $value, $limit, $count); $value = preg_replace($re, $to, $value, (int) $limit, $count);
if ($value === null) if ($value === null)
{ {
trigger_error('regex ' . $re . ' failed at ' . $this->loc , E_USER_WARNING); trigger_error('regex ' . $re . ' failed at ' . $this->loc , E_USER_WARNING);
} }
else if ($strict && !$count) else if ($strict && !$count)
{ {
$value = null; $value = null;
} }
return $value; return $value;
} }
function filter_trim($value, $character_mask = " \t\n\r\0\x0B") function filter_trim($value, $character_mask = " \t\n\r\0\x0B"): string
{ {
return trim($value, $character_mask); return trim($value, $character_mask);
} }
function filter_url_encode($value) function filter_url_encode($value)
{ {
if (!is_array($value)) if (!is_array($value))
{ {
return rawurlencode((string) $value); return rawurlencode((string) $value);
} }
skipping to change at line 364 skipping to change at line 364
$list = []; $list = [];
foreach ($value as $id => $val) foreach ($value as $id => $val)
{ {
$list[] = Ut::qencode($id, $val); $list[] = Ut::qencode($id, $val);
} }
return implode('&', $list); return implode('&', $list);
} }
function filter_striptags($value, $allowable_tags = '') function filter_striptags($value, $allowable_tags = ''): string
{ {
return strip_tags($value, $allowable_tags); return strip_tags($value, $allowable_tags);
} }
function filter_nl2br($value) function filter_nl2br($value): string
{ {
$list = preg_split('/(?:\r\n|\r|\n){2,}/', $value, -1, PREG_SPLIT _NO_EMPTY); $list = preg_split('/(?:\r\n|\r|\n){2,}/', $value, -1, PREG_SPLIT _NO_EMPTY);
foreach ($list as &$p) foreach ($list as &$p)
{ {
$p = '<p>' . str_replace("\n", "<br>\n", $p) . '</p>'; $p = '<p>' . str_replace("\n", "<br>\n", $p) . '</p>';
} }
return implode("\n\n", $list); return implode("\n\n", $list);
} }
function filter_truncate($value, $limit, $ellipsis = '...') function filter_truncate($value, $limit, $ellipsis = '...')
{ {
if (strlen($value) > $limit) if (strlen($value) > $limit)
{ {
$split = explode(' ', substr($value, 0, $limit)); $split = explode(' ', substr($value, 0, (int) $limit));
$split1 = array_slice($split, 0, -1); $split1 = array_slice($split, 0, -1);
$value = implode(' ', $split1 ?: $split) . $ellipsis; $value = implode(' ', $split1 ?: $split) . $ellipsis;
} }
return $value; return $value;
} }
function filter_split($value, $delimiter, $limit = PHP_INT_MAX) function filter_split($value, $delimiter, $limit = PHP_INT_MAX): array
{ {
return Ut::isempty($delimiter)? str_split($value, $limit) : explo de($delimiter, $value, $limit); return Ut::isempty($delimiter)? str_split($value, $limit) : explo de($delimiter, $value, $limit);
} }
function filter_list() function filter_list()
{ {
$args = func_get_args(); $args = func_get_args();
$value = (int)array_shift($args); $value = (int)array_shift($args);
return ($value >= 0 && $value < count($args))? $args[$value] : ar ray_pop($args); return ($value >= 0 && $value < count($args))? $args[$value] : ar ray_pop($args);
} }
function filter_dbg($value) function filter_dbg($value)
{ {
// suppress ALL errors. templatest is meant to be used standalone , and this is LONE dependency on wacko // suppress ALL errors. templatest is meant to be used standalone , and this is LONE dependency on wacko
@Diag::dbg($this->loc, $value); @Diag::dbg($this->loc, $value);
return $value; return $value;
} }
function filter_enclose($value, $pref = '', $post = '') function filter_enclose($value, $pref = '', $post = ''): string
{ {
return $pref . $value . $post; return $pref . $value . $post;
} }
function filter_check($value, $on) function filter_check($value, $on): string
{ {
return ' value="' . (int) $on . '" ' . (((int) $value == (int) $o n)? 'checked ' : ''); return ' value="' . (int) $on . '" ' . (((int) $value == (int) $o n)? 'checked ' : '');
} }
function filter_checkbox($value) function filter_checkbox($value): string
{ {
return (((int) $value)? ' checked ' : ''); return (((int) $value)? ' checked ' : '');
} }
function filter_select($value, $on) function filter_select($value, $on): string
{ {
return (($value == $on)? ' selected ' : ''); return (($value == $on)? ' selected ' : '');
} }
// FIXME: workaround for pre and textarea // FIXME: workaround for pre and textarea
function filter_pre($value) function filter_pre($value)
{ {
// suppress line break stripping and auto-indent // suppress line break stripping and auto-indent
$this->pre = true; $this->pre = true;
 End of changes. 20 change blocks. 
20 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)