Use Horde_String::truncate()
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 00:51:20 +0000 (17:51 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 07:40:00 +0000 (00:40 -0700)
imp/mailbox.php
imp/message.php

index 7b292f8..16f4816 100644 (file)
@@ -779,7 +779,7 @@ while (list(,$ob) = each($mbox_info['overview'])) {
 
             $maxlen = $prefs->getValue('preview_maxlen');
             if (Horde_String::length($ptext) > $maxlen) {
-                $ptext = Horde_String::substr($ptext, 0, $maxlen) . ' ...';
+                $ptext = Horde_String::truncate($ptext, $maxlen);
             } elseif (empty($ob['previewcut'])) {
                 $ptext .= '[[' . _("END") . ']]';
             }
@@ -814,10 +814,7 @@ while (list(,$ob) = each($mbox_info['overview'])) {
 
     /* Add subject flags. */
     foreach ($subject_flags as $val) {
-        $flag_label = $val['label'];
-        if (Horde_String::length($val['label']) > 12) {
-            $flag_label = Horde_String::substr($val['label'], 0, 10) . '...';
-        }
+        $flag_label = Horde_String::truncate($val['label'], 12);
 
         $msg['subject'] = '<span class="' . $val['classname'] . '" style="background:' . htmlspecialchars($val['bg']) . ';color:' . htmlspecialchars($val['fg']) . '" title="' . htmlspecialchars($val['label']) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject'];
     }
index e1d5272..7b6f749 100644 (file)
@@ -281,10 +281,7 @@ foreach (array('to', 'cc', 'bcc') as $val) {
 if ($subject = $mime_headers->getValue('subject')) {
     $display_headers['subject'] = $imp_ui->getDisplaySubject($subject);
     $title = sprintf(_("%s: %s"), $page_label, $subject);
-    $shortsub = htmlspecialchars($subject);
-    if (strlen($shortsub) > 97) {
-        $shortsub = substr($shortsub, 0, 97) . '...';
-    }
+    $shortsub = htmlspecialchars(Horde_String::truncate($subject, 100));
 } else {
     $display_headers['subject'] = $shortsub = _("[No Subject]");
     $title = sprintf(_("%s: %s"), $page_label, $shortsub);