Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Debug.tpl XTML Compliance

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
p-munky
Smarty n00b


Joined: 04 Feb 2006
Posts: 2

PostPosted: Sat Feb 04, 2006 9:51 pm    Post subject: Debug.tpl XTML Compliance Reply with quote

The javascript code that generates the debug window is not XHTML compliant - for compliancy it is necessary to make the following changes to the debug.tpl file:

1. Escape all backslashes in closing HTML tags. within the javascript generation code. e.g. </table> becomes <\/table>
2. Make the <SCRIPT>, </BODY> etc tags in this file lower case.
3. Properly enclose the attributes for the <script> tags. e.g. <script type=javascript... becomes <script type="javascript"....
4. Escape special characters within the generated HTML file: Change the following text: "included templates &..." should become "included templates & amp;". (without the space between the & and amp - buggy forum code means you cant write it without it displaying as &!)
5. To be extra-compliant, add the DOCTYPE declaration at the top of the generated HTML. Depending on the doctype chosen, more characters may need to be escaped.

An updated copy can be found below - this took me just a couple of minutes to update and now the code generated comes back as valid, with only a warning about the lack of <!DOCTYPE> tag. I used the HTML Validator for Mozilla to work all this stuff out. /plug http://users.skynet.be/mgueury/mozilla/

Code:

{* Smarty *}

{* debug.tpl, last updated version 2.0.1 *}

{assign_debug_info}

{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
   <table border=0 width=100%>
   <tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>
   <tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>
   {section name=templates loop=$_debug_tpls}
      <tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth}&&&{/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html}</font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>
   {sectionelse}
      <tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>   
   {/section}
   <tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>
   {section name=vars loop=$_debug_keys}
      <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>
   {sectionelse}
      <tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>   
   {/section}
   <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}
      <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>
   {sectionelse}
      <tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>   
   {/section}
   </table>
</body></html>
{else}
<script type="text/javascript">
         //<![CDATA[
   if( self.name == '' ) {ldelim}
      var title = 'Console';
   {rdelim}
   else {ldelim}
      var title = 'Console_' + self.name;
   {rdelim}
   _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
   _smarty_console.document.write("<HTML><HEAD><TITLE>Smarty Debug Console_"+self.name+"<\/TITLE><\/HEAD><BODY bgcolor=#ffffff>");
   _smarty_console.document.write("<table border=0 width=100%>");
   _smarty_console.document.write("<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console<\/th><\/tr>");
   _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):<\/b><\/td><\/tr>");
   {section name=templates loop=$_debug_tpls}
      _smarty_console.document.write("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth}&&&{/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html|escape:javascript}<\/font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}<\/i><\/font>{/if}<\/tt><\/td><\/tr>");
   {sectionelse}
      _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included<\/i><\/tt><\/td><\/tr>");   
   {/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|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|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}
   _smarty_console.document.write("<\/table>");
   _smarty_console.document.write("<\/body><\/html>");
   _smarty_console.document.close();
      //]]>
</script>
{/if}
Back to top
View user's profile Send private message
b166-er
Smarty Rookie


Joined: 22 Oct 2004
Posts: 29
Location: Germany, Wiesbaden

PostPosted: Mon Feb 13, 2006 5:04 pm    Post subject: Reply with quote

jep, thats true.

i fix this bugs for long time ago, here my debug.tpl
Code:
{* Smarty *}

{* debug.tpl, last updated version 2.0.1 *}

{assign_debug_info}

{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
   <table border="0" width="100%">
   <tr bgcolor="#cccccc"><th colspan="2">Smarty Debug Console</th></tr>
   <tr bgcolor="#cccccc"><td colspan="2"><b>included templates &amp; config files (load time in seconds):</b></td></tr>
   {section name=templates loop=$_debug_tpls}
      <tr bgcolor="{if %templates.index% is even}#eeeeee{else}#fafafa{/if}"><td colspan="2"><tt>{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}<font color="{if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}">{$_debug_tpls[templates].filename|escape:html}</font>{if isset($_debug_tpls[templates].exec_time)} <font size="-1"><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>
   {sectionelse}
      <tr bgcolor="#eeeeee"><td colspan="2"><tt><i>no templates included</i></tt></td></tr>   
   {/section}
   <tr bgcolor="#cccccc"><td colspan="2"><b>assigned template variables:</b></td></tr>
   {section name=vars loop=$_debug_keys}
      <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="nowrap"><tt><font color="green">{$_debug_vals[vars]|@debug_print_var}</font></tt></td></tr>
   {sectionelse}
      <tr bgcolor="#eeeeee"><td colspan="2"><tt><i>no template variables assigned</i></tt></td></tr>   
   {/section}
   <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}
      <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>
   {sectionelse}
      <tr bgcolor="#eeeeee"><td colspan="2"><tt><i>no config vars assigned</i></tt></td></tr>   
   {/section}
   </table>
</body></html>
{else}
<script type="text/javascript">
         //<![CDATA[
   if( self.name == '' ) {ldelim}
      var title = 'Console';
   {rdelim}
   else {ldelim}
      var title = 'Console_' + self.name;
   {rdelim}
   _smarty_console = window.open('',title.value,'width=680,height=600,resizable,scrollbars=yes');
   _smarty_console.document.write('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.1\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml11/DTD\/xhtml11.dtd">');
   _smarty_console.document.write('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml" xml:lang="de">');
   _smarty_console.document.write('<html><head><title>Smarty Debug Console_'+self.name+'<\/title><\/head><body bgcolor="#ffffff">');
   _smarty_console.document.write('<table border="0" width="100%">');
   _smarty_console.document.write('<tr bgcolor="#cccccc"><th colspan="2">Smarty Debug Console<\/th><\/tr>');
   _smarty_console.document.write('<tr bgcolor="#cccccc"><td colspan="2"><b>included templates &amp; config files (load time in seconds):<\/b><\/td><\/tr>');
   {section name=templates loop=$_debug_tpls}
      _smarty_console.document.write('<tr bgcolor="{if %templates.index% is even}#eeeeee{else}#fafafa{/if}"><td colspan="2"><tt>{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}<font color="{if $_debug_tpls[templates].type eq 'template'}brown{elseif $_debug_tpls[templates].type eq 'insert'}black{else}green{/if}">{$_debug_tpls[templates].filename|escape:html|escape:javascript}<\/font>{if isset($_debug_tpls[templates].exec_time)} <font size="-1"><i>({$_debug_tpls[templates].exec_time|string_format:'%.5f'}){if %templates.index% eq 0} (total){/if}<\/i><\/font>{/if}<\/tt><\/td><\/tr>');
   {sectionelse}
      _smarty_console.document.write('<tr bgcolor="#eeeeee"><td colspan="2"><tt><i>no templates included<\/i><\/tt><\/td><\/tr>');   
   {/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="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|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}
   _smarty_console.document.write('<\/table>');
   _smarty_console.document.write('<\/body><\/html>');
   _smarty_console.document.close();
      //]]>
</script>
{/if}


have fun, and thanks for smarty! Smile
________
Alaska medical marijuana dispensary


Last edited by b166-er on Sun Feb 13, 2011 6:19 pm; edited 6 times in total
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Feb 13, 2006 5:07 pm    Post subject: Reply with quote

Hi guys.

Thanks for the code. In the future you may want to consider sending a patch (as a plain text attatchment) to the smarty-dev mailing list.

Best Regards.
Back to top
View user's profile Send private message
b166-er
Smarty Rookie


Joined: 22 Oct 2004
Posts: 29
Location: Germany, Wiesbaden

PostPosted: Tue Feb 14, 2006 9:38 am    Post subject: Reply with quote

yesterday i bugfix my template, now its XHTML 1.1 Conform, W3-Valid!
here my debug.tpl:

Code:
{* Smarty *}

{* debug.tpl, last updated version 2.0.1 *}

{assign_debug_info}

{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
   <table style="border:0px; width:100%;">
   <tr style="background-color:#ccc"><th colspan="2">Smarty Debug Console</th></tr>
   <tr style="background-color:#ccc"><td colspan="2"><b>included templates &amp; config files (load time in seconds):</b></td></tr>
   {section name=templates loop=$_debug_tpls}
      <tr style="background-color:{if %templates.index% is even}#eee{else}#fafafa{/if}"><td colspan="2"><tt style="color:{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}{if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}">{$_debug_tpls[templates].filename|escape:html}{if isset($_debug_tpls[templates].exec_time)} <i style="font:italic .5em Arial;color:000;">({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i>{/if}</tt></td></tr>
   {sectionelse}
      <tr style="background-color:#eee"><td colspan="2"><tt><i>no templates included</i></tt></td></tr>   
   {/section}
   <tr style="background-color:#ccc"><td colspan="2"><b>assigned template variables:</b></td></tr>
   {section name=vars loop=$_debug_keys}
      <tr style="background-color:{if %vars.index% is even}#eeeeee{else}#fafafa{/if}"><td valign="top"><tt style="color: green;">{ldelim}${$_debug_keys[vars]}{rdelim}</tt></td><td style="white-space:nowrap;"><tt style="color: green;">{$_debug_vals[vars]|@debug_print_var}</tt></td></tr>
   {sectionelse}
      <tr style="background-color:#eee"><td colspan="2"><tt><i>no template variables assigned</i></tt></td></tr>   
   {/section}
   <tr style="background-color:#ccc"><td colspan="2"><b>assigned config file variables (outer template scope):</b></td></tr>
   {section name=config_vars loop=$_debug_config_keys}
      <tr style="background-color:{if %config_vars.index% is even}#eee{else}#fafafa{/if}"><td valign="top"><tt style="color: maroon;">{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</tt></td><td><tt style="color: green;">{$_debug_config_vals[config_vars]|@debug_print_var}</tt></td></tr>
   {sectionelse}
      <tr style="background-color:#eee"><td colspan="2"><tt><i>no config vars assigned</i></tt></td></tr>   
   {/section}
   </table>
</body></html>
{else}
<script type="text/javascript">
   //<![CDATA[
   if( self.name == '' ) {ldelim}
      var title = 'Console';
   {rdelim}
   else {ldelim}
      var title = 'Console_' + self.name;
   {rdelim}
   _smarty_console = window.open('',title.value,'width=680,height=600,resizable,scrollbars=yes');
   _smarty_console.document.write('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.1\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml11/DTD\/xhtml11.dtd">');
   _smarty_console.document.write('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml" xml:lang="de">');
   _smarty_console.document.write('<head>');
   _smarty_console.document.write('<title>Smarty Debug Console_'+self.name+'<\/title>');
   _smarty_console.document.write('<style type="text\/css">');
   _smarty_console.document.write('body {literal}{{/literal}background-color: #FFF;{literal}}{/literal}');
   _smarty_console.document.write('table,tr {literal}{{/literal}line-height: .9em;{literal}}{/literal}');
   _smarty_console.document.write('tt {literal}{{/literal}font:normal .8em Verdena;{literal}}{/literal}');
   _smarty_console.document.write('i {literal}{{/literal}color:#000;font:italic .5em Arial;{literal}}{/literal}');
   _smarty_console.document.write('#content-box {literal}{{/literal}border:0px;{literal}}{/literal}');
   _smarty_console.document.write('.title {literal}{{/literal}line-height: 1.2em;background-color: #CCC;{literal}}{/literal}');
   _smarty_console.document.write('.node_1 {literal}{{/literal}background-color: #EEE;{literal}}{/literal}');
   _smarty_console.document.write('.node_2 {literal}{{/literal}background-color: #FAFAFA;{literal}}{/literal}');
   _smarty_console.document.write('.green {literal}{{/literal}color: green;{literal}}{/literal}');
   _smarty_console.document.write('.blue {literal}{{/literal}color: blue;{literal}}{/literal}');
   _smarty_console.document.write('.maroon {literal}{{/literal}color: maroon;{literal}}{/literal}');
   _smarty_console.document.write('.brown {literal}{{/literal}color: brown;{literal}}{/literal}');
   _smarty_console.document.write('.nowrap {literal}{{/literal}white-space:nowrap;{literal}}{/literal}');
   _smarty_console.document.write('<\/style>');
   _smarty_console.document.write('<\/head><body>');
   _smarty_console.document.write('<table id="content_box">');
   _smarty_console.document.write('<tr class="title"><th colspan="2">Smarty Debug Console<\/th><\/tr>');
   _smarty_console.document.write('<tr class="title"><td colspan="2"><b>included templates &amp; config files (load time in seconds):<\/b><\/td><\/tr>');
   {section name=templates loop=$_debug_tpls}
      _smarty_console.document.write('<tr class="{if %templates.index% is even}node_1{else}node_2{/if}"><td colspan="2"><tt class="{if $_debug_tpls[templates].type eq 'template'}brown{elseif $_debug_tpls[templates].type eq 'insert'}black{else}green{/if}">{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}{$_debug_tpls[templates].filename|escape:html|escape:javascript}{if isset($_debug_tpls[templates].exec_time)} <i>({$_debug_tpls[templates].exec_time|string_format:'%.5f'}){if %templates.index% eq 0} (total){/if}<\/i>{/if}<\/tt><\/td><\/tr>');
   {sectionelse}
      _smarty_console.document.write('<tr class="node_1"><td colspan="2"><tt><i>no templates included<\/i><\/tt><\/td><\/tr>');   
   {/section}
   _smarty_console.document.write('<tr class="title"><td colspan="2"><b>assigned template variables:<\/b><\/td><\/tr>');
   {section name=vars loop=$_debug_keys}
      _smarty_console.document.write('<tr class="{if %vars.index% is even}node_1{else}node_2{/if}"><td valign="top"><tt class="blue">{ldelim}${$_debug_keys[vars]}{rdelim}<\/tt><\/td><td class="nowrap"><tt class="green">{$_debug_vals[vars]|@debug_print_var|escape:javascript}<\/tt><\/td><\/tr>');
   {sectionelse}
      _smarty_console.document.write('<tr class="node_1"><td colspan="2"><tt><i>no template variables assigned<\/i><\/tt><\/td><\/tr>');   
   {/section}
   _smarty_console.document.write('<tr class="title"><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 class="{if %config_vars.index% is even}node_1{else}node_2{/if}"><td valign="top"><tt class="maroon">{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}<\/tt><\/td><td><tt class="green">{$_debug_config_vals[config_vars]|@debug_print_var|escape:javascript}<\/tt><\/td><\/tr>');
   {sectionelse}
      _smarty_console.document.write('<tr class="node_1"><td colspan="2"><tt><i>no config vars assigned<\/i><\/tt><\/td><\/tr>');   
   {/section}
   _smarty_console.document.write('<\/table>');
   _smarty_console.document.write('<\/body><\/html>');
   _smarty_console.document.close();
   //]]>
</script>
{/if}

and here my modifed smarty_modifier_debug_print_var()-function:
[php]function smarty_modifier_debug_print_var($var, $depth = 0, $length = 120)
{
$_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;
}
} 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;
}
} else if (is_resource($var)) {
$results = '<i class="green">'.(string)$var.'</i>';
} else if (empty($var) && $var != '0') {
$results = '<i class="green">empty</i>';
} else {
if (strlen($var) > $length ) {
$results = substr($var, 0, $length-3).'...';
} else {
$results = $var;
}
$results = htmlspecialchars($results);
$results = strtr($results, $_replace);
}
return $results;
}[/php] the modifying is in <br/>-tags,
<i>-tag have now class="green" formatting text,
remove double-quates from static-text (for small performance...),
str_repeat() have now 2 nbsp; for better view on different depth and
$length is increased to 120 (because my variables is bigger Smile)


have fun and good luck!
________
Ferrari 195 inter history


Last edited by b166-er on Sun Feb 13, 2011 6:19 pm; edited 6 times in total
Back to top
View user's profile Send private message
p-munky
Smarty n00b


Joined: 04 Feb 2006
Posts: 2

PostPosted: Tue Feb 14, 2006 9:48 am    Post subject: Patches Reply with quote

Good work - Ive had a quick look at it seems you nailed everything here.

If I get a chance this week I will take the changes and make a couple of patch files from this - its the least I can do Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Tue Feb 14, 2006 3:11 pm    Post subject: Reply with quote

Yes please send them to the dev list, phpbb tends to screw up html entities.

thanks
Back to top
View user's profile Send private message Visit poster's website
cybot
Smarty Regular


Joined: 20 Apr 2005
Posts: 83

PostPosted: Thu Nov 02, 2006 4:15 pm    Post subject: Reply with quote

this is mytry, to be XHTML 1.1 compliant and use correct sementic


Code:
{* Smarty *}

{* debug.tpl, last updated version 2.0.1 *}

{assign_debug_info}

{capture assign=debug_output}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Smarty Debug Console</title>
{literal}
<style type="text/css">
/* <![CDATA[ */
body, h1, h2, td, th, p {
    font-family: sans-serif;
    font-weight: normal;
    font-size: 1em;
}

h1, h2 {
    background-color: #dddddd;
    margin: 0;
    text-align: center;
}

p {
    margin: 0;
    font-style: italic;
    text-align: center;
}

table {
    width: 100%;
}

th, td {
    font-family: monospace;
    vertical-align: top;
    text-align: left;
    width: 50%;
}

td {
    color: green;
}

.odd {
    background-color: #eeeeee;
}

.even {
    background-color: #fafafa;
}

.exectime {
    font-size: 0.8em;
    font-style: italic;
}

#table_assigned_vars th {
    color: blue;
}

#table_config_vars th {
    color: maroon;
}


/* ]]> */
</style>
{/literal}
</head>
<body>

<h1>Smarty Debug Console</h1>

<h2>included templates &amp; config files (load time in seconds)</h2>

{section name=templates loop=$_debug_tpls}
    {section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}
    <font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>
        {$_debug_tpls[templates].filename|escape:html}</font>
    {if isset($_debug_tpls[templates].exec_time)}
        <span class="exectime">
        ({$_debug_tpls[templates].exec_time|string_format:"%.5f"})
        {if %templates.index% eq 0}(total){/if}
        </span>
    {/if}
    <br />
{sectionelse}
    <p>no templates included</p>
{/section}

<h2>assigned template variables</h2>

<table id="table_assigned_vars">
    {section name=vars loop=$_debug_keys}
        <tr class="{cycle values="odd,even"}">
            <th>{ldelim}${$_debug_keys[vars]|escape:'html'}{rdelim}</th>
            <td>{$_debug_vals[vars]|@debug_print_var}</td></tr>
    {sectionelse}
        <tr><td><p>no template variables assigned</p></td></tr>
    {/section}
</table>

<h2>assigned config file variables (outer template scope)</h2>

<table id="table_config_vars">
    {section name=config_vars loop=$_debug_config_keys}
        <tr class="{cycle values="odd,even"}">
            <th>{ldelim}#{$_debug_config_keys[config_vars]|escape:'html'}#{rdelim}</th>
            <td>{$_debug_config_vals[config_vars]|@debug_print_var}</td></tr>
    {sectionelse}
        <tr><td><p>no config vars assigned</p></td></tr>
    {/section}
</table>
</body>
</html>
{/capture}
{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
    {$debug_output}
{else}
<script type="text/javascript">
// <![CDATA[
    if ( self.name == '' ) {ldelim}
       var title = 'Console';
    {rdelim}
    else {ldelim}
       var title = 'Console_' + self.name;
    {rdelim}
    _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
    _smarty_console.document.write('{$debug_output|escape:'javascript'}');
    _smarty_console.document.close();
// ]]>
</script>
{/if}
Back to top
View user's profile Send private message
cybot
Smarty Regular


Joined: 20 Apr 2005
Posts: 83

PostPosted: Thu Nov 02, 2006 4:16 pm    Post subject: Reply with quote

there is no need for a patch file, as it just replaces the whole debug.tpl file
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Nov 07, 2006 8:59 pm    Post subject: Reply with quote

cybot, I committed a modified version of your template to CVS. The modified version also has some color/styling changes to try and match the Smarty color scheme.

This should also address http://www.phpinsider.com/smarty-forum/viewtopic.php?t=9282

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP