Example #1
0
 function replace_macros($s, $r)
 {
     global $t;
     $stamp1 = microtime(true);
     $a = get_app();
     if ($a->theme['template_engine'] === 'smarty3') {
         $template = '';
         if (gettype($s) === 'string') {
             $template = $s;
             $s = new FriendicaSmarty();
         }
         foreach ($r as $key => $value) {
             if ($key[0] === '$') {
                 $key = substr($key, 1);
             }
             $s->assign($key, $value);
         }
         $output = $s->parsed($template);
     } else {
         $r = $t->replace($s, $r);
         $output = template_unescape($r);
     }
     $a = get_app();
     $a->save_timestamp($stamp1, "rendering");
     return $output;
 }
Example #2
0
 function replace_macros($s, $r)
 {
     global $t;
     //$ts = microtime();
     $r = $t->replace($s, $r);
     //$tt = microtime() - $ts;
     //$a = get_app();
     //$a->page['debug'] .= "$tt <br>\n";
     return template_unescape($r);
 }
 public function replace_macros($s, $r)
 {
     $this->r = $r;
     // remove comments block
     $s = preg_replace('/{#(.*?\\s*?)*?#}/', "", $s);
     $s = $this->_build_nodes($s);
     $s = preg_replace_callback('/\\|\\|([0-9]+)\\|\\|/', array($this, "_replcb_node"), $s);
     if ($s == Null) {
         $this->_preg_error();
     }
     // replace strings recursively (limit to 10 loops)
     $os = "";
     $count = 0;
     while ($os != $s && $count < 10) {
         $os = $s;
         $count++;
         $s = $this->var_replace($s);
     }
     return template_unescape($s);
 }
 public function replace($s, $r)
 {
     $this->r = $r;
     $this->search = array();
     $this->replace = array();
     $this->_build_replace($r, "");
     #$s = str_replace(array("\n","\r"),array("§n§","§r§"),$s);
     $s = $this->_build_nodes($s);
     $s = preg_replace_callback('/\\|\\|([0-9]+)\\|\\|/', array($this, "_replcb_node"), $s);
     if ($s == Null) {
         $this->_preg_error();
     }
     // remove comments block
     $s = preg_replace('/{#[^#]*#}/', "", $s);
     // replace strings recursively (limit to 10 loops)
     $os = "";
     $count = 0;
     while ($os != $s && $count < 10) {
         $os = $s;
         $count++;
         $s = str_replace($this->search, $this->replace, $s);
     }
     return template_unescape($s);
 }