X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Fsmarty%2Flibs%2Fplugins%2Fmodifier.debug_print_var.php;h=e4f7bc0ccf7444a8bec01a90950b62be9c271e89;hb=38927c4d48865f73d1b965f1a07c76efe4339a9a;hp=b9bb1848802ef8884a6069d662d7402b0644b9f6;hpb=e034221efbc7970ec58be22d7517fd3c503dc903;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/smarty/libs/plugins/modifier.debug_print_var.php b/wwwroot/smarty/libs/plugins/modifier.debug_print_var.php index b9bb184..e4f7bc0 100644 --- a/wwwroot/smarty/libs/plugins/modifier.debug_print_var.php +++ b/wwwroot/smarty/libs/plugins/modifier.debug_print_var.php @@ -14,6 +14,7 @@ * Purpose: formats variable contents for display in the console * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php * debug_print_var (Smarty online manual) + * @author Monte Ohrt * @param array|object * @param integer * @param integer @@ -21,33 +22,66 @@ */ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) { - $_replace = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t'); - if (is_array($var)) { - $results = "Array (".count($var).")"; - foreach ($var as $curr_key => $curr_val) { - $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); - $results .= "
".str_repeat(' ', $depth*2)."".strtr($curr_key, $_replace)." => $return"; - } - } else if (is_object($var)) { - $object_vars = get_object_vars($var); - $results = "".get_class($var)." Object (".count($object_vars).")"; - foreach ($object_vars as $curr_key => $curr_val) { - $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); - $results .= "
".str_repeat(' ', $depth*2)."$curr_key => $return"; - } - } else if (is_resource($var)) { - $results = ''.(string)$var.''; - } else if (empty($var) && $var != "0") { - $results = 'empty'; - } else { - if (strlen($var) > $length ) { - $results = substr($var, 0, $length-3).'...'; - } else { - $results = $var; - } - $results = htmlspecialchars($results); - $results = strtr($results, $_replace); + $_replace = array( + "\n" => '\n', + "\r" => '\r', + "\t" => '\t' + ); + + switch (gettype($var)) { + case 'array' : + $results = 'Array (' . count($var) . ')'; + foreach ($var as $curr_key => $curr_val) { + $results .= '
' . str_repeat(' ', $depth * 2) + . '' . strtr($curr_key, $_replace) . ' => ' + . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + $depth--; + } + break; + case 'object' : + $object_vars = get_object_vars($var); + $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; + foreach ($object_vars as $curr_key => $curr_val) { + $results .= '
' . str_repeat(' ', $depth * 2) + . ' ->' . strtr($curr_key, $_replace) . ' = ' + . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); + $depth--; + } + break; + case 'boolean' : + case 'NULL' : + case 'resource' : + if (true === $var) { + $results = 'true'; + } elseif (false === $var) { + $results = 'false'; + } elseif (null === $var) { + $results = 'null'; + } else { + $results = htmlspecialchars((string) $var); + } + $results = '' . $results . ''; + break; + case 'integer' : + case 'float' : + $results = htmlspecialchars((string) $var); + break; + case 'string' : + $results = strtr($var, $_replace); + if (strlen($var) > $length ) { + $results = substr($var, 0, $length - 3) . '...'; + } + $results = htmlspecialchars('"' . $results . '"'); + break; + case 'unknown type' : + default : + $results = strtr((string) $var, $_replace); + if (strlen($results) > $length ) { + $results = substr($results, 0, $length - 3) . '...'; + } + $results = htmlspecialchars($results); } + return $results; }