-
- private function _build_nodes($s){
- $this->done = false;
- while (!$this->done){
- $this->done=true;
- $s = preg_replace_callback('|{{ *([a-z]*) *([^}]*)}}([^{]*({{ *else *}}[^{]*)?){{ *end\1 *}}|', array($this, "_replcb"), $s);
- if ($s==Null) $this->_preg_error();
- }
- //({{ *else *}}[^{]*)?
- krsort($this->nodes);
- return $s;
+ $this->nodes = Array();
+ $tpl = get_markup_template($tplfile);
+ $ret = $this->replace($tpl, $r);
+ $this->_pop_stack();
+ return $ret;
+ }
+
+ /**
+ * DEBUG node
+ *
+ * {{ debug $var [$var [$var [...]]] }}{{ enddebug }}
+ *
+ * replace node with <pre>var_dump($var, $var, ...);</pre>
+ */
+ private function _replcb_debug($args) {
+ $vars = array_map('trim', explode(" ", $args[2]));
+ $vars[] = $args[1];
+
+ $ret = "<pre>";
+ foreach ($vars as $var) {
+ $ret .= htmlspecialchars(var_export($this->_get_var($var), true));
+ $ret .= "\n";
+ }
+ $ret .= "</pre>";
+ return $ret;
+ }
+
+ private function _replcb_node($m) {
+ $node = $this->nodes[$m[1]];
+ if (method_exists($this, "_replcb_" . $node[1])) {
+ $s = call_user_func(array($this, "_replcb_" . $node[1]), $node);
+ } else {
+ $s = "";
+ }
+ $s = preg_replace_callback('/\|\|([0-9]+)\|\|/', array($this, "_replcb_node"), $s);
+ return $s;
+ }
+
+ private function _replcb($m) {
+ //var_dump(array_map('htmlspecialchars', $m));
+ $this->done = false;
+ $this->nodes[] = (array) $m;
+ return "||" . (count($this->nodes) - 1) . "||";
+ }
+
+ private function _build_nodes($s) {
+ $this->done = false;
+ while (!$this->done) {
+ $this->done = true;
+ $s = preg_replace_callback('|{{ *([a-z]*) *([^}]*)}}([^{]*({{ *else *}}[^{]*)?){{ *end\1 *}}|', array($this, "_replcb"), $s);
+ if ($s == Null)
+ $this->_preg_error();