cvs: smarty /libs debug.tpl /libs/plugins modifier.debug_print_var.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1060784130@cvsserver>
messju		Wed Aug 13 10:15:30 2003 EDT

  Modified files:              
    /smarty/libs	debug.tpl 
    /smarty/libs/plugins	modifier.debug_print_var.php 
  Log:
  removed '\r' from debug_print_vars' output
  properly escape vars in javascript-version of debug.tpl
  
  
Index: smarty/libs/debug.tpl
diff -u smarty/libs/debug.tpl:1.7 smarty/libs/debug.tpl:1.8
--- smarty/libs/debug.tpl:1.7	Fri Aug  8 16:31:05 2003
+++ smarty/libs/debug.tpl	Wed Aug 13 10:15:30 2003
@@ -47,13 +47,13 @@
 	{/section}
 	_smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>");
 	{section name=vars loop=$_debug_keys}
-		_smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var}</font></tt></td></tr>");
+		_smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
 	{sectionelse}
 		_smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>");	
 	{/section}
 	_smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outer template scope):</b></td></tr>");
 	{section name=config_vars loop=$_debug_config_keys}
-		_smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var}</font></tt></td></tr>");
+		_smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
 	{sectionelse}
 		_smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>");	
 	{/section}
Index: smarty/libs/plugins/modifier.debug_print_var.php
diff -u smarty/libs/plugins/modifier.debug_print_var.php:1.8 smarty/libs/plugins/modifier.debug_print_var.php:1.9
--- smarty/libs/plugins/modifier.debug_print_var.php:1.8	Mon Apr 21 12:53:03 2003
+++ smarty/libs/plugins/modifier.debug_print_var.php	Wed Aug 13 10:15:30 2003
@@ -21,13 +21,12 @@
  */
 function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
 {
-	$_search = array("!\n!", "!\r!", "!\t!");
-	$_replace = array('<i>&#92;n</i>', '<i>&#92;r</i>', '<i>&#92;t</i>');
+	$_replace = array("\n"=>'<i>&#92;n</i>', "\r"=>'<i>&#92;r</i>', "\t"=>'<i>&#92;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>\r'.str_repeat('&nbsp;', $depth*2)."<b>".preg_replace($_search, $_replace, $curr_key)."</b> =&gt; $return";
+            $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> =&gt; $return";
         }
         return $results;
     } else if (is_object($var)) {
@@ -35,7 +34,7 @@
         $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>\r'.str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
+            $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
         }
         return $results;
     } else {
@@ -48,7 +47,7 @@
             $results = $var;
         }
         $results = htmlspecialchars($results);
-        $results = preg_replace($_search, $_replace, $results);
+        $results = strtr($results, $_replace);
         return $results;
     }
 }



-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.