From 8b225eb07261dc8720ec4adfbdbd05b90391bba9 Mon Sep 17 00:00:00 2001 From: andrey Date: Fri, 26 Oct 2001 19:16:06 +0000 Subject: [PATCH] Debug formatting. --- Smarty.addons.php | 32 ++++++++++++++++---------------- demo/templates/debug.tpl | 2 +- templates/debug.tpl | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Smarty.addons.php b/Smarty.addons.php index aeaae0ad..e698e621 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -686,21 +686,21 @@ function smarty_func_counter() { function smarty_func_assign_debug_info($args, &$smarty_obj) { $assigned_vars = $smarty_obj->_tpl_vars; ksort($assigned_vars); - if(is_array($smarty_obj->_config[0])) { + if (is_array($smarty_obj->_config[0])) { $config_vars = $smarty_obj->_config[0]; ksort($config_vars); - $smarty_obj->assign("_debug_config_keys",array_keys($config_vars)); - $smarty_obj->assign("_debug_config_vals",array_values($config_vars)); + $smarty_obj->assign("_debug_config_keys", array_keys($config_vars)); + $smarty_obj->assign("_debug_config_vals", array_values($config_vars)); } $included_templates = $smarty_obj->_smarty_debug_info; - $smarty_obj->assign("_debug_expand",$smarty_obj->_smarty_debug_expand); + $smarty_obj->assign("_debug_expand", $smarty_obj->_smarty_debug_expand); - $smarty_obj->assign("_debug_keys",array_keys($assigned_vars)); - $smarty_obj->assign("_debug_vals",array_values($assigned_vars)); + $smarty_obj->assign("_debug_keys", array_keys($assigned_vars)); + $smarty_obj->assign("_debug_vals", array_values($assigned_vars)); - $smarty_obj->assign("_debug_tpls",$included_templates); + $smarty_obj->assign("_debug_tpls", $included_templates); return true; } @@ -708,24 +708,24 @@ function smarty_func_assign_debug_info($args, &$smarty_obj) { Function: smarty_func_debug_print_var Purpose: prints variable (or array) contents to the console \*======================================================================*/ -function smarty_mod_debug_print_var($var,$depth=0,$length=40) { - if(is_array($var)) { - $results = "Array (".count($var).")".'
\r'.$results; +function smarty_mod_debug_print_var($var, $depth=0, $length=40) { + if (is_array($var)) { + $results = "Array (".count($var).")"; foreach ($var as $curr_key => $curr_val) { - $return = smarty_mod_debug_print_var($curr_val,$depth+1); - $results .= str_repeat(' ',$depth*2)."$curr_key => $return".'
\r'; + $return = smarty_mod_debug_print_var($curr_val, $depth+1); + $results .= '
\r'.str_repeat(' ', $depth*2)."$curr_key => $return"; } return $results; } else { - if(empty($var)) { + if (empty($var)) { return 'empty'; } - if( strlen($var) > $length ) { - $results = substr($var,0,$length-3).'...'; + if (strlen($var) > $length ) { + $results = substr($var, 0, $length-3).'...'; } else { $results = $var; } - $results = preg_replace("![\r\t\n]!"," ",$results); + $results = preg_replace("![\r\t\n]!", " ", $results); $results = htmlspecialchars($results); return $results; } diff --git a/demo/templates/debug.tpl b/demo/templates/debug.tpl index 0a7a42c2..e0aa1e95 100644 --- a/demo/templates/debug.tpl +++ b/demo/templates/debug.tpl @@ -15,7 +15,7 @@ {/section} _smarty_console.document.write("assigned template variables:"); {section name=vars loop=$_debug_keys} - _smarty_console.document.write("{ldelim}${$_debug_keys[vars]}{rdelim}{$_debug_vals[vars]|@debug_print_var}"); + _smarty_console.document.write("{ldelim}${$_debug_keys[vars]}{rdelim}{$_debug_vals[vars]|@debug_print_var}"); {sectionelse} _smarty_console.document.write("no template variables assigned"); {/section} diff --git a/templates/debug.tpl b/templates/debug.tpl index 0a7a42c2..e0aa1e95 100644 --- a/templates/debug.tpl +++ b/templates/debug.tpl @@ -15,7 +15,7 @@ {/section} _smarty_console.document.write("assigned template variables:"); {section name=vars loop=$_debug_keys} - _smarty_console.document.write("{ldelim}${$_debug_keys[vars]}{rdelim}{$_debug_vals[vars]|@debug_print_var}"); + _smarty_console.document.write("{ldelim}${$_debug_keys[vars]}{rdelim}{$_debug_vals[vars]|@debug_print_var}"); {sectionelse} _smarty_console.document.write("no template variables assigned"); {/section}