]> git.mxchange.org Git - friendica.git/commitdiff
template proc: allow isolation of var name between [ and ]
authorFabio Comuni <fabrix.xm@gmail.com>
Fri, 2 Mar 2012 14:53:48 +0000 (15:53 +0100)
committerFabio Comuni <fabrix.xm@gmail.com>
Fri, 2 Mar 2012 14:53:48 +0000 (15:53 +0100)
$var.name -> $[var.name]

include/template_processor.php

index 9ac0a13131153ef9398bf2084c97755dd59f33b6..111fc5849a7b8af9041ffe465653722bfd3b464e 100755 (executable)
 
                private function var_replace($s){
                        $m = array();
-                       if (preg_match_all('/\$([a-zA-Z0-9-_]+\.*)+/', $s,$m)){
+                       if (preg_match_all('/\$\[{0,1}([a-zA-Z0-9-_]+\.*)+\]{0,1}/', $s,$m)){
                                foreach($m[0] as $var){
-                                       $val = $this->_get_var($var, true);
+                                       $varn = str_replace(array("[","]"), array("",""), $var);
+                                       $val = $this->_get_var($varn, true);
                                        if ($val!=KEY_NOT_EXISTS)
                                                $s = str_replace($var, $val, $s);
                                }
                        }
+                       
                        return $s;
                }