/**
* 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(' ', ' ', Text::htmlSpaces($subject));
+ $new_subject = str_replace(' ', ' ', Text::htmlSpaces($subject));
+ } elseif ($htmlspaces) {
+ require_once 'Horde/Text.php';
+ $new_subject = Text::htmlSpaces($subject);
}
- return $subject;
+
+ return empty($new_subject) ? $subject : $new_subject;
}
}
$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'])) {
}
/* 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 {
/* 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);