Add IMP_UI_Message::formatSummary()
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 29 Oct 2009 06:31:10 +0000 (00:31 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Oct 2009 04:37:45 +0000 (22:37 -0600)
imp/lib/UI/Message.php
imp/lib/Views/ShowMessage.php
imp/message.php

index a4a19e0..6894277 100644 (file)
@@ -408,7 +408,25 @@ class IMP_UI_Message
     }
 
     /**
-     * Prints out a MIME status message.
+     * Prints out a MIME summary (in HTML).
+     *
+     * @param array $summary  Summary information from
+     *                        IMP_Summary::getSummary().
+     * @param array $display  The fields to display (in this order).
+     *
+     * @return string  The formatted summary string.
+     */
+    public function formatSummary($summary, $display)
+    {
+        $tmp_summary = array();
+        foreach ($display as $val) {
+            $tmp_summary[] = $summary[$val];
+        }
+        return '<div class="mimePartInfo"><span>' . implode(' ', $tmp_summary) . '</span></div>';
+    }
+
+    /**
+     * Prints out a MIME status message (in HTML).
      *
      * @param array $data  An array of information (as returned from
                            Horde_Mime_Viewer::render()).
index e8e2266..58131f1 100644 (file)
@@ -296,18 +296,13 @@ class IMP_Views_ShowMessage
                     continue;
                 }
 
-                $tmp_summary = $tmp_status = array();
-
-                $summary = $imp_contents->getSummary($id, $contents_mask);
-                foreach ($part_info_display as $val) {
-                    $tmp_summary[] = $summary[$val];
-                }
+                $tmp_status = array();
 
                 foreach ($info['status'] as $val) {
                     $tmp_status[] = $imp_ui->formatStatusMsg($val);
                 }
 
-                $result['msgtext'] .= '<div><span class="mimePartInfo">' . implode(' ', $tmp_summary) . '</span></div>' . implode("\n", $tmp_status) . $info['data'];
+                $result['msgtext'] .= $imp_ui->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) . implode("\n", $tmp_status) . $info['data'];
 
                 if (isset($info['js'])) {
                     $result['js'] = array_merge($result['js'], $info['js']);
index 718c277..a45f866 100644 (file)
@@ -627,18 +627,12 @@ foreach ($parts_list as $mime_id => $mime_type) {
             continue;
         }
 
-        $tmp_summary = $tmp_status = array();
-
-        $summary = $imp_contents->getSummary($id, $contents_mask);
-        foreach ($part_info_display as $val) {
-            $tmp_summary[] = $summary[$val];
-        }
-
+        $tmp_status = array();
         foreach ($info['status'] as $val) {
             $tmp_status[] = $imp_ui->formatStatusMsg($val);
         }
 
-        $msgtext .= '<div><span class="mimePartInfo">' . implode(' ', $tmp_summary) . '</span></div>' .
+        $msgtext .= $imp_ui->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) .
             implode("\n", $tmp_status) .
             $info['data'];