X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Fsmarty%2Flibs%2Fplugins%2Fmodifier.truncate.php;h=35c89690a1556cc6dfa943bde00f40abb43dca15;hb=40428f53bc0696319dd9cbdbd2c0ab6ac37a887b;hp=93c3f510882d7111a915abcffb634f16873ddfbb;hpb=e034221efbc7970ec58be22d7517fd3c503dc903;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/smarty/libs/plugins/modifier.truncate.php b/wwwroot/smarty/libs/plugins/modifier.truncate.php index 93c3f51..35c8969 100644 --- a/wwwroot/smarty/libs/plugins/modifier.truncate.php +++ b/wwwroot/smarty/libs/plugins/modifier.truncate.php @@ -16,6 +16,7 @@ * appending the $etc string or inserting $etc into the middle. * @link http://smarty.php.net/manual/en/language.modifier.truncate.php * truncate (Smarty online manual) + * @author Monte Ohrt * @param string * @param integer * @param string @@ -30,12 +31,12 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', 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); }