]> git.mxchange.org Git - friendica.git/blobdiff - include/template_processor.php
navbar fix
[friendica.git] / include / template_processor.php
index 0d476f0e6e63f54a15f88dc69ebd514f58a22934..28c3f07ddd1e46dfc477deb4f0fc9b7a1479d6c4 100755 (executable)
        
                        if(is_array($r) && count($r)) {
                                foreach ($r as $k => $v ) {
-                                       if (is_array($v))
+                                       if (is_array($v)) {
                                                $this->_build_replace($v, "$prefix$k.");
-                                       
-                                       $this->search[] =  $prefix . $k;
-                                       $this->replace[] = $v;
+                                       } else {
+                                               $this->search[] =  $prefix . $k;
+                                               $this->replace[] = $v;
+                                       }
                                }
                        }
                } 
@@ -53,7 +54,7 @@
                        $keys = array_map('trim',explode(".",$name));           
                        $val = $this->r;
                        foreach($keys as $k) {
-                               $val = $val[$k];
+                               $val = (isset($val[$k]) ? $val[$k] : null);
                        }
                        return $val;
                }
@@ -79,8 +80,8 @@
                        } else {
                                $val = $this->_get_var($args[2]);
                        }
-                       list($strue, $sfalse)= preg_split("|{{ *else *}}|", $args[3]);
-                       return ($val?$strue:$sfalse);
+                       $x = preg_split("|{{ *else *}}|", $args[3]);
+                       return ( $val ? $x[0] : (isset($x[1]) ? $x[1] : ""));
                }
                
                /**
                        krsort($this->nodes);
                        return $s;
                }
-
+               
+        /*
                private function _str_replace($str){
                        #$this->search,$this->replace,
                        $searchs = $this->search;
                                
                        }
                        return str_replace($this->search,$this->replace, $str);
-               }
+               }*/
 
        
                public function replace($s, $r) {
                        $os = ""; $count=0;
                        while($os!=$s && $count<10){
                                $os=$s; $count++;
-                               $s = $this->_str_replace($s);
+                               //$s = $this->_str_replace($s);
+                               $s = str_replace($this->search, $this->replace, $s);
                        }
                        return template_unescape($s);
                }