Fixes re: subject display
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 10 Dec 2008 09:02:40 +0000 (02:02 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 10 Dec 2008 09:09:45 +0000 (02:09 -0700)
imp/lib/UI/Mailbox.php
imp/mailbox.php
imp/message.php

index 114449b..2c46670 100644 (file)
@@ -221,21 +221,28 @@ class IMP_UI_Mailbox
     /**
      * Formats the subject header.
      *
-     * @param string $subject  The MIME encoded subject header.
+     * @param string $subject     The MIME encoded subject header.
+     * @param string $htmlspaces  Run through Text::htmlSpaces()?
      *
      * @return string  The formatted subject header.
      */
-    public function getSubject($subject)
+    public function getSubject($subject, $htmlspaces = false)
     {
         $subject = Horde_Mime::decode($subject);
-        $subject = empty($subject)
-            ? _("[No Subject]")
-            : IMP::filterText(preg_replace("/\s+/", ' ', $subject));
+        if (empty($subject)) {
+            return _("[No Subject]");
+        }
+
+        $new_subject = $subject = IMP::filterText(preg_replace("/\s+/", ' ', $subject));
         if ($_SESSION['imp']['view'] == 'dimp') {
             require_once 'Horde/Text.php';
-            $subject = str_replace('&nbsp;', '&#160;', Text::htmlSpaces($subject));
+            $new_subject = str_replace('&nbsp;', '&#160;', Text::htmlSpaces($subject));
+        } elseif ($htmlspaces) {
+            require_once 'Horde/Text.php';
+            $new_subject = Text::htmlSpaces($subject);
         }
-        return $subject;
+
+        return empty($new_subject) ? $subject : $new_subject;
     }
 
 }
index 024279f..1776984 100644 (file)
@@ -679,7 +679,6 @@ $fromlinkstyle = $prefs->getValue('from_link');
 $imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox']);
 
 /* Display message information. */
-require_once 'Horde/Text.php';
 $ids = $msgs = array();
 $search_template = null;
 while (list($seq, $ob) = each($mbox_info['overview'])) {
@@ -818,7 +817,7 @@ while (list($seq, $ob) = each($mbox_info['overview'])) {
     }
 
     /* Format the Subject: Header. */
-    $msg['subject'] = Text::htmlSpaces($imp_ui->getSubject($ob['envelope']['subject']));
+    $msg['subject'] = $imp_ui->getSubject($ob['envelope']['subject'], true);
     if ($preview_tooltip) {
         $msg['subject'] = substr(Horde::linkTooltip($target, $msg['preview'], '', '', '', $msg['preview']), 0, -1) . ' id="subject' . $msg['id'] . '">' . $msg['subject'] . '</a>';
     } else {
index 668611e..05fe754 100644 (file)
@@ -305,7 +305,8 @@ if (($subject = $mime_headers->getValue('subject'))) {
     /* Filter the subject text, if requested. */
     require_once 'Horde/Text.php';
     $subject = IMP::filterText($subject);
-    $display_headers['subject'] = Text::htmlSpaces($subject);
+    $disp_subject = Text::htmlSpaces($subject);
+    $display_headers['subject'] = $disp_subject ? $disp_subject : $subject;
 
     $title = sprintf(_("%s: %s"), $page_label, $subject);
     $shortsub = htmlspecialchars($subject);