several small fixes and adjustments

This commit is contained in:
friendica
2012-12-16 20:20:29 -08:00
parent fa8b4e98b7
commit e9b5b0f0b4
10 changed files with 79 additions and 25 deletions

View File

@@ -209,7 +209,7 @@ class Item extends BaseObject {
'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
'tags' => $tags,
'body' => template_escape($body),
'body' => $body,
'text' => strip_tags(template_escape($body)),
'id' => $this->get_id(),
'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),

View File

@@ -9,8 +9,8 @@ function network_query($a,$arr) {
$ordering = (($arr['order'] === 'post') ? "`created`" : "`commented`") . " DESC ";
$itemspage = get_pconfig($arr['uid'],'system','itemspage_network');
$a->set_pager_itemspage(((intval($itemspage_network)) ? $itemspage_network : 40));
$itemspage = get_pconfig($arr['uid'],'system','itemspage');
$a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 40));
$pager_sql = ((intval($arr['update'])) ? '' : sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])));

View File

@@ -46,7 +46,7 @@
foreach($keys as $k) {
$val = (isset($val[$k]) ? $val[$k] : null);
}
return $val;
return template_escape($val);
}
/**
@@ -196,12 +196,49 @@
* (subgrup 1), match close bracket
*/
if (preg_match_all('/\$(\[)?([a-zA-Z0-9-_]+\.?)+(?(1)\])/', $s,$m)){
foreach($m[0] as $var){
$varn = str_replace(array("[","]"), array("",""), $var);
$val = $this->_get_var($varn, true);
if ($val!=KEY_NOT_EXISTS)
$s = str_replace($var, $val, $s);
foreach($m[0] as $var){
$exp = str_replace(array("[", "]"), array("", ""), $var);
$exptks = explode("|", $exp);
$varn = $exptks[0];
unset($exptks[0]);
$val = $this->_get_var($varn, true);
if ($val != KEY_NOT_EXISTS) {
/* run filters */
/*
* Filter are in form of:
* filtername:arg:arg:arg
*
* "filtername" is function name
* "arg"s are optional, var value is appended to the end
* if one "arg"==='x' , is replaced with var value
*
* examples:
* $item.body|htmlspecialchars // escape html chars
* $item.body|htmlspecialchars|strtoupper // escape html and uppercase result
* $item.created|date:%Y %M %j // format date (created is a timestamp)
* $item.body|str_replace:cat:dog // replace all "cat" with "dog"
* $item.body|str_replace:cat:dog:x:1 // replace one "cat" with "dog"
*/
foreach ($exptks as $filterstr) {
$filter = explode(":", $filterstr);
$filtername = $filter[0];
unset($filter[0]);
$valkey = array_search("x", $filter);
if ($valkey === false) {
$filter[] = $val;
} else {
$filter[$valkey] = $val;
}
if (function_exists($filtername)) {
$val = call_user_func_array($filtername, $filter);
}
}
$s = str_replace($var, $val, $s);
}
}
}