diff options
author | Fabio Comuni <fabrix.xm@gmail.com> | 2012-03-06 09:48:08 +0100 |
---|---|---|
committer | Fabio Comuni <fabrix.xm@gmail.com> | 2012-03-06 09:48:08 +0100 |
commit | be9985a3aed1bfbbc6964973e2f12d0bd7928c04 (patch) | |
tree | 4fc044f6200f010778363a8de72671f45c259eaa /include/template_processor.php | |
parent | 8a51e29824fc2569ac1d0def3070bee7c0552231 (diff) | |
parent | d04fba704861fa27184346d0cefe2069ec8cfa6d (diff) | |
download | volse-hubzilla-be9985a3aed1bfbbc6964973e2f12d0bd7928c04.tar.gz volse-hubzilla-be9985a3aed1bfbbc6964973e2f12d0bd7928c04.tar.bz2 volse-hubzilla-be9985a3aed1bfbbc6964973e2f12d0bd7928c04.zip |
Merge remote-tracking branch 'friendica/master'
Diffstat (limited to 'include/template_processor.php')
-rwxr-xr-x | include/template_processor.php | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/include/template_processor.php b/include/template_processor.php index 90c6b2e65..8671587fc 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -160,25 +160,24 @@ private function var_replace($s){ $m = array(); - if (preg_match_all('/(\$\[{0,1}([a-zA-Z0-9-_]+\.*)+)(\|[a-zA-Z0-9-_]+)*\]{0,1}/', $s,$m)){ - foreach($m[1] as $id=>$var){ - $var = str_replace("[", "", $var); - $val = $this->_get_var($var, true); - - // apply filters - if ($m[3][$id]!=""){ - $filters = explode("|",trim($m[3][$id],"|")); - foreach($filters as $filter) - if (function_exists($filter)) - $val=$filter($val); - } + /** regexp: + * \$ literal $ + * (\[)? optional open square bracket + * ([a-zA-Z0-9-_]+\.?)+ var name, followed by optional + * dot, repeated at least 1 time + * (?(1)\]) if there was opened square bracket + * (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($m[0][$id], $val, $s); + $s = str_replace($var, $val, $s); } } - - return $s; } |