aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2012-02-21 02:38:52 -0800
committerfabrixxm <fabrix.xm@gmail.com>2012-02-21 02:38:52 -0800
commit2904a3265a5aa17f968655487060f7f1817373c1 (patch)
tree885c6f7a3b3f73fd45fa1e372f335cd8756e6d30
parent5910fbf42023f36e69068c4ec09c772d997bbb72 (diff)
parent01a2791e3a83fba4da878cb094855819821a23d1 (diff)
downloadvolse-hubzilla-2904a3265a5aa17f968655487060f7f1817373c1.tar.gz
volse-hubzilla-2904a3265a5aa17f968655487060f7f1817373c1.tar.bz2
volse-hubzilla-2904a3265a5aa17f968655487060f7f1817373c1.zip
Merge pull request #43 from fabrixxm/master
Add support for variable filters in template
-rwxr-xr-xinclude/template_processor.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/include/template_processor.php b/include/template_processor.php
index 25f7703a2..0d476f0e6 100755
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -10,7 +10,7 @@
var $done = false;
var $d = false;
var $lang = null;
-
+ var $debug=false;
private function _preg_error(){
switch(preg_last_error()){
@@ -160,6 +160,30 @@
return $s;
}
+ private function _str_replace($str){
+ #$this->search,$this->replace,
+ $searchs = $this->search;
+ foreach($searchs as $search){
+ $search = "|".preg_quote($search)."(\|[a-zA-Z0-9_]*)*|";
+ $m = array();
+ if (preg_match_all($search, $str,$m)){
+ foreach ($m[0] as $match){
+ $toks = explode("|",$match);
+ $val = $this->_get_var($toks[0]);
+ for($k=1; $k<count($toks); $k++){
+ $func = $toks[$k];
+ if (function_exists($func)) $val = $func($val);
+ }
+ if (count($toks)>1){
+ $str = str_replace( $match, $val, $str);
+ }
+ }
+ }
+
+ }
+ return str_replace($this->search,$this->replace, $str);
+ }
+
public function replace($s, $r) {
$this->r = $r;
@@ -180,7 +204,7 @@
$os = ""; $count=0;
while($os!=$s && $count<10){
$os=$s; $count++;
- $s = str_replace($this->search,$this->replace, $s);
+ $s = $this->_str_replace($s);
}
return template_unescape($s);
}