Make sure truncated text isn't split on a space boundary.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 15 Sep 2010 22:08:23 +0000 (16:08 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 17 Sep 2010 21:14:51 +0000 (15:14 -0600)
framework/Util/lib/Horde/String.php

index 0019e4d..076cdc4 100644 (file)
@@ -606,7 +606,7 @@ class Horde_String
     static public function truncate($text, $length = 100)
     {
         return (self::length($text) > $length)
-            ? self::substr($text, 0, $length - 3) . ' ...'
+            ? rtrim(self::substr($text, 0, $length - 3)) . '...'
             : $text;
     }
 
@@ -622,7 +622,7 @@ class Horde_String
     static public function abbreviate($text, $length = 20)
     {
         return (self::length($text) > $length)
-            ? self::substr($text, 0, round(($length - 3) / 2)) . '...' . self::substr($text, (($length - 3) / 2) * -1)
+            ? rtrim(self::substr($text, 0, round(($length - 3) / 2))) . '...' . ltrim(self::substr($text, (($length - 3) / 2) * -1))
             : $text;
     }