diff options
author | ctrlaltca@gmail.com <> | 2011-11-19 11:33:31 +0000 |
---|---|---|
committer | ctrlaltca@gmail.com <> | 2011-11-19 11:33:31 +0000 |
commit | 98dbe6f0d2edfff3a1f5785504504b4a6e5dd4eb (patch) | |
tree | 89f19120abb170cb37bb512c8c9535eb2b451da8 /buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.debug_print_var.php | |
parent | 1f09b786730956d01c48a82272617a0f8b2597f0 (diff) |
updating phpDocumentor, part 2: add new version
Diffstat (limited to 'buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.debug_print_var.php')
-rw-r--r-- | buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.debug_print_var.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.debug_print_var.php b/buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.debug_print_var.php new file mode 100644 index 00000000..35283113 --- /dev/null +++ b/buildscripts/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/modifier.debug_print_var.php @@ -0,0 +1,57 @@ +<?php +/** + * Smarty plugin + * @package Smarty + * @subpackage plugins + */ + + +/** + * Smarty debug_print_var modifier plugin + * + * Type: modifier<br> + * Name: debug_print_var<br> + * 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) + * @param array|object + * @param integer + * @param integer + * @return string + */ +function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) +{ + $_replace = array("\n"=>'<i>\n</i>', "\r"=>'<i>\r</i>', "\t"=>'<i>\t</i>'); + if (is_array($var)) { + $results = "<b>Array (".count($var).")</b>"; + foreach ($var as $curr_key => $curr_val) { + $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); + $results .= "<br>".str_repeat(' ', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> => $return"; + } + return $results; + } else if (is_object($var)) { + $object_vars = get_object_vars($var); + $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>"; + foreach ($object_vars as $curr_key => $curr_val) { + $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); + $results .= "<br>".str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return"; + } + return $results; + } else { + if (empty($var) && $var != "0") { + return '<i>empty</i>'; + } + if (strlen($var) > $length ) { + $results = substr($var, 0, $length-3).'...'; + } else { + $results = $var; + } + $results = htmlspecialchars($results); + $results = strtr($results, $_replace); + return $results; + } +} + +/* vim: set expandtab: */ + +?> |