Small patches

From: Date: Fri, 27 Dec 2002 13:13:16 +0000
Subject: Small patches
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-495@lists.php.net to get a copy of this message
Hi! It seems, Monte doesn't recieve letters from my address, so if he will not reply, please somebody resend this to him. These are changes I had to make in my copy of Smarty. 1. count_words should take into account non-ascii characters ############# diff -urb cvs/plugins/modifier.count_words.php my/plugins/modifier.count_words.php --- cvs/plugins/modifier.count_words.php Thu Jan 31 23:49:40 2002 +++ my/plugins/modifier.count_words.php Thu Nov 21 15:08:44 2002 @@ -13,7 +13,7 @@ // split text by ' ',\r,\n,\f,\t $split_array = preg_split('/\s+/',$string); // count matches that contain alphanumerics - $word_count = preg_grep('/[a-zA-Z0-9]/', $split_array); + $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array); return count($word_count); } ############# 2. Removed E_NOTICE class warnings in debug.tpl (when exec_time is undefined) and modifier.escape.php ############# diff -urb cvs/debug.tpl my/debug.tpl --- cvs/debug.tpl Wed Jul 24 17:21:51 2002 +++ my/debug.tpl Wed Dec 25 14:34:25 2002 @@ -5,12 +5,11 @@ {assign_debug_info} {if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"} -<HTML><TITLE>Smarty Debug Console_"+self.name+"</TITLE><BODY bgcolor=#ffffff> <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}&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}</font> <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font></tt></td></tr> + <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}</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} @@ -42,7 +41,7 @@ _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}&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}</font> <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font></tt></td></tr>"); + _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}</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} diff -urb cvs/plugins/modifier.escape.php my/plugins/modifier.escape.php --- cvs/plugins/modifier.escape.php Fri Apr 5 00:34:44 2002 +++ my/plugins/modifier.escape.php Thu Nov 21 15:08:44 2002 @@ -25,6 +25,7 @@ return preg_replace("%(?<!\\\\)'%", "\\'", $string); case 'hex': + $return=''; // escape every character into hex for ($x=0; $x < strlen($string); $x++) { $return .= '%' . bin2hex($string[$x]); @@ -32,6 +33,7 @@ return $return; case 'hexentity': + $return=''; for ($x=0; $x < strlen($string); $x++) { $return .= '&#x' . bin2hex($string[$x]) . ';'; } ############# 3. count_characters modifier documentation says nothing about modifier parameter ($include_spaces = false by default). And its example is incorrect for this reason.

« previous php.smarty.dev (#495) next »