aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-12-16 20:20:29 -0800
committerfriendica <info@friendica.com>2012-12-16 20:20:29 -0800
commite9b5b0f0b424930b87708080c4e6ce671016177b (patch)
tree436092bdee53c0e2a195bb0cc580c5cbc1c6e731 /include
parentfa8b4e98b727a2af58fea55e93546089fe9bea2b (diff)
downloadvolse-hubzilla-e9b5b0f0b424930b87708080c4e6ce671016177b.tar.gz
volse-hubzilla-e9b5b0f0b424930b87708080c4e6ce671016177b.tar.bz2
volse-hubzilla-e9b5b0f0b424930b87708080c4e6ce671016177b.zip
several small fixes and adjustments
Diffstat (limited to 'include')
-rw-r--r--include/ItemObject.php2
-rw-r--r--include/iquery.php4
-rw-r--r--include/template_processor.php51
3 files changed, 47 insertions, 10 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 09f5d1298..45ea6860a 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -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'])),
diff --git a/include/iquery.php b/include/iquery.php
index 03264de28..0d51134a4 100644
--- a/include/iquery.php
+++ b/include/iquery.php
@@ -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'])));
diff --git a/include/template_processor.php b/include/template_processor.php
index 89f03dfe0..61526e570 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -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);
+
+ }
}
}