cvs: smarty / NEWS /libs/plugins modifier.truncate.php
[email protected] ("Messju Mohr") Wed, 17 Jan 2007 22:10:01 -0000
| Newsgroups | php.smarty.cvs |
|---|---|
| Message-ID | <cvsmessju1169071801@cvsserver> |
messju Wed Jan 17 22:10:01 2007 UTC
Modified files:
/smarty NEWS
/smarty/libs/plugins modifier.truncate.php
Log:
fixed handling of $etc in the truncate modifier when $etc is longer
than $length.
thanks to Sylvinus!
http://cvs.php.net/viewvc.cgi/smarty/NEWS?r1=1.548&r2=1.549&diff_format=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.548 smarty/NEWS:1.549
--- smarty/NEWS:1.548 Wed Jan 10 18:12:11 2007
+++ smarty/NEWS Wed Jan 17 22:10:01 2007
@@ -1,3 +1,5 @@
+- fix handling of $etc in the truncate modifier when $etc is longer
+ than $length (Sylvinus, messju)
- fix handling of %I with mysql timestamps in the date_format modifier
(Danilo Buerger, boots)
- update smarty_core_write_file() to better recognize Windows (boots)
http://cvs.php.net/viewvc.cgi/smarty/libs/plugins/modifier.truncate.php?r1=1.6&r2=1.7&diff_format=u
Index: smarty/libs/plugins/modifier.truncate.php
diff -u smarty/libs/plugins/modifier.truncate.php:1.6 smarty/libs/plugins/modifier.truncate.php:1.7
--- smarty/libs/plugins/modifier.truncate.php:1.6 Tue Oct 11 16:22:56 2005
+++ smarty/libs/plugins/modifier.truncate.php Wed Jan 17 22:10:01 2007
@@ -31,12 +31,12 @@
return '';
if (strlen($string) > $length) {
- $length -= strlen($etc);
+ $length -= min($length, strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
}
if(!$middle) {
- return substr($string, 0, $length).$etc;
+ return substr($string, 0, $length) . $etc;
} else {
return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
}