X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftemplate_processor.php;h=4088ddab60840864c6b111c81c81615b1371cc94;hb=429870015fc9b1d94b24234152ad236f433e7f5a;hp=4c317efe1fd466975545dd3a4ac64bfa344f23b5;hpb=355c42cb309eb1313097411067ca999b699aa620;p=friendica.git diff --git a/include/template_processor.php b/include/template_processor.php index 4c317efe1f..4088ddab60 100644 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -13,12 +13,14 @@ var $debug=false; private function _preg_error(){ + switch(preg_last_error()){ case PREG_INTERNAL_ERROR: echo('PREG_INTERNAL_ERROR'); break; case PREG_BACKTRACK_LIMIT_ERROR: echo('PREG_BACKTRACK_LIMIT_ERROR'); break; case PREG_RECURSION_LIMIT_ERROR: echo('PREG_RECURSION_LIMIT_ERROR'); break; case PREG_BAD_UTF8_ERROR: echo('PREG_BAD_UTF8_ERROR'); break; - case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break; +// This is only valid for php > 5.3, not certain how to code around it for unit tests +// case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break; default: //die("Unknown preg error."); return; @@ -61,7 +63,7 @@ if ($b[0]=="$") $b = $this->_get_var($b); $val = ($a == $b); } else if (strpos($args[2],"!=")>0){ - list($a,$b) = explode("!=",$args[2]); + list($a,$b) = array_map("trim", explode("!=",$args[2])); $a = $this->_get_var($a); if ($b[0]=="$") $b = $this->_get_var($b); $val = ($a != $b); @@ -131,6 +133,26 @@ return $ret; } + + /** + * DEBUG node + * + * {{ debug $var [$var [$var [...]]] }}{{ enddebug }} + * + * replace node with
var_dump($var, $var, ...);
+ */ + private function _replcb_debug($args){ + $vars = array_map('trim', explode(" ",$args[2])); + $vars[] = $args[1]; + + $ret = "
";
+			foreach ($vars as $var){
+				$ret .= htmlspecialchars(var_export( $this->_get_var($var), true ));
+				$ret .= "\n";
+			}
+			$ret .= "
"; + return $ret; + } private function _replcb_node($m) { $node = $this->nodes[$m[1]];