cvs: smarty / NEWS /libs/plugins modifier.truncate.php
| From: | Messju Mohr | Date: | Wed, 12 Mar 2003 21:56:32 +0000 |
| Subject: | cvs: smarty / NEWS /libs/plugins modifier.truncate.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-453@lists.php.net to get a copy of this message | ||
messju Wed Mar 12 16:56:32 2003 EDT
Modified files:
/smarty NEWS
/smarty/libs/plugins modifier.truncate.php
Log:
fixed length in modifier.truncate.php
Index: smarty/NEWS
diff -u smarty/NEWS:1.305 smarty/NEWS:1.306
--- smarty/NEWS:1.305 Wed Mar 12 11:26:55 2003
+++ smarty/NEWS Wed Mar 12 16:56:32 2003
@@ -1,3 +1,4 @@
+ - fixed length in modifier.truncate.php (messju)
- fixed handling of '$'-signs in trimwhitespace outputfilter (messju)
- fix bug that makes config files recompile every time
(Nagger, Monte)
Index: smarty/libs/plugins/modifier.truncate.php
diff -u smarty/libs/plugins/modifier.truncate.php:1.1 smarty/libs/plugins/modifier.truncate.php:1.2
--- smarty/libs/plugins/modifier.truncate.php:1.1 Thu Jan 31 15:49:40 2002
+++ smarty/libs/plugins/modifier.truncate.php Wed Mar 12 16:56:32 2003
@@ -17,13 +17,11 @@
return '';
if (strlen($string) > $length) {
- $length -= strlen($etc);
- $fragment = substr($string, 0, $length+1);
- if ($break_words)
- $fragment = substr($fragment, 0, -1);
- else
- $fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
- return $fragment.$etc;
+ $length -= strlen($etc);
+ if (!$break_words)
+ $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0,
$length+1));
+
+ return substr($string, 0, $length).$etc;
} else
return $string;
}