Better formatStatusMsg() implementation
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Oct 2009 20:04:56 +0000 (14:04 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Oct 2009 20:05:16 +0000 (14:05 -0600)
imp/lib/UI/Message.php
imp/lib/Views/ShowMessage.php
imp/message.php

index 6894277..8f304eb 100644 (file)
@@ -435,28 +435,32 @@ class IMP_UI_Message
      */
     public function formatStatusMsg($data)
     {
-        if (empty($data)) {
-            return '';
-        }
+        $out = '';
 
-        $class = 'mimeStatusMessage';
+        foreach ($data as $val) {
+            if (empty($val)) {
+                continue;
+            }
 
-        $out = array('<div><table ' . (isset($data['id']) ? ('id="' . $data['id'] . '" ') : '') . 'class="' . $class . '">');
+            $out .= '<div><table ' . (isset($val['id']) ? ('id="' . $val['id'] . '" ') : '') . 'class="mimeStatusMessage">';
 
-        /* If no image, simply print out the message. */
-        if (empty($data['icon'])) {
-            foreach ($data['text'] as $val) {
-                $out[] = '<tr><td>' . $val . '</td></tr>';
-            }
-        } else {
-            $out[] = '<tr><td class="mimeStatusIcon">' . $data['icon'] . '</td><td><table>';
-            foreach ($data['text'] as $val) {
-                $out[] = '<tr><td>' . $val . '</td></tr>';
+            /* If no image, simply print out the message. */
+            if (empty($val['icon'])) {
+                foreach ($val['text'] as $val) {
+                    $out .= '<tr><td>' . $val . '</td></tr>';
+                }
+            } else {
+                $out .= '<tr><td class="mimeStatusIcon">' . $val['icon'] . '</td><td><table>';
+                foreach ($val['text'] as $val) {
+                    $out .= '<tr><td>' . $val . '</td></tr>';
+                }
+                $out .= '</table></td></tr>';
             }
-            $out[] = '</table></td></tr>';
+
+            $out .= '</table></div>';
         }
 
-        return implode("\n", $out) . "\n</table></div>\n";
+        return $out;
     }
 
     /**
index 58131f1..5df8379 100644 (file)
@@ -260,7 +260,7 @@ class IMP_Views_ShowMessage
 
         /* Do MDN processing now. */
         if ($imp_ui->MDNCheck($mailbox, $uid, $mime_headers)) {
-            $result['msgtext'] .= $imp_ui->formatStatusMsg(array('text' => array(_("The sender of this message is requesting a Message Disposition Notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link('', '', '', '', 'DimpCore.doAction(\'SendMDN\',{folder:\'' . $mailbox . '\',uid:' . $uid . '}); return false;', '', '') . _("HERE") . '</a>'))));
+            $result['msgtext'] .= $imp_ui->formatStatusMsg(array(array('text' => array(_("The sender of this message is requesting a Message Disposition Notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link('', '', '', '', 'DimpCore.doAction(\'SendMDN\',{folder:\'' . $mailbox . '\',uid:' . $uid . '}); return false;', '', '') . _("HERE") . '</a>')))));
         }
 
         /* Build body text. This needs to be done before we build the
@@ -296,13 +296,9 @@ class IMP_Views_ShowMessage
                     continue;
                 }
 
-                $tmp_status = array();
-
-                foreach ($info['status'] as $val) {
-                    $tmp_status[] = $imp_ui->formatStatusMsg($val);
-                }
-
-                $result['msgtext'] .= $imp_ui->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) . implode("\n", $tmp_status) . $info['data'];
+                $result['msgtext'] .= $imp_ui->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) .
+                    $imp_ui->formatStatusMsg($info['status']) .
+                    $info['data'];
 
                 if (isset($info['js'])) {
                     $result['js'] = array_merge($result['js'], $info['js']);
@@ -311,7 +307,7 @@ class IMP_Views_ShowMessage
         }
 
         if (!strlen($result['msgtext'])) {
-            $result['msgtext'] = $imp_ui->formatStatusMsg(array('text' => array(_("There are no parts that can be shown inline."))));
+            $result['msgtext'] = $imp_ui->formatStatusMsg(array(array('text' => array(_("There are no parts that can be shown inline.")))));
         }
 
         if (count($atc_parts) ||
index a45f866..826c76d 100644 (file)
@@ -575,7 +575,7 @@ $msgtext = '';
 
 /* Do MDN processing now. */
 if ($imp_ui->MDNCheck($imp_mbox['mailbox'], $uid, $mime_headers, Horde_Util::getFormData('mdn_confirm'))) {
-    $msgtext .= $imp_ui->formatStatusMsg(array('text' => array(_("The sender of this message is requesting a Message Disposition Notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link(htmlspecialchars(Horde_Util::addParameter($selfURL, 'mdn_confirm', 1))) . _("HERE") . '</a>'))));
+    $msgtext .= $imp_ui->formatStatusMsg(array(array('text' => array(_("The sender of this message is requesting a Message Disposition Notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link(htmlspecialchars(Horde_Util::addParameter($selfURL, 'mdn_confirm', 1))) . _("HERE") . '</a>')))));
 }
 
 $show_parts = Horde_Util::getFormData('show_parts', $prefs->getValue('parts_display'));
@@ -627,13 +627,8 @@ foreach ($parts_list as $mime_id => $mime_type) {
             continue;
         }
 
-        $tmp_status = array();
-        foreach ($info['status'] as $val) {
-            $tmp_status[] = $imp_ui->formatStatusMsg($val);
-        }
-
         $msgtext .= $imp_ui->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) .
-            implode("\n", $tmp_status) .
+            $imp_ui->formatStatusMsg($info['status']) .
             $info['data'];
 
         if (isset($info['js'])) {
@@ -643,7 +638,7 @@ foreach ($parts_list as $mime_id => $mime_type) {
 }
 
 if (!strlen($msgtext)) {
-    $msgtext = $imp_ui->formatStatusMsg(array('text' => array(_("There are no parts that can be shown inline."))));
+    $msgtext = $imp_ui->formatStatusMsg(array(array('text' => array(_("There are no parts that can be shown inline.")))));
 }
 
 /* Build the Attachments menu. */