From 11fe4cd222efe6bf9b5e2ae465d8620255962a99 Mon Sep 17 00:00:00 2001
From: Michael M Slusarz
+ * 'display_mask' - (integer) The mask of display view type to render
+ * inline (DEFAULT: IMP_Contents::RENDER_INLINE_AUTO).
+ * 'mask' - (integer) The mask needed for a IMP_Contents::getSummary()
+ * call.
+ * 'no_inline_all' - (boolean) If true, only display first inline part.
+ * Subsequent inline parts will be treated as
+ * attachments.
+ * 'part_info_display' - (array) The list of summary fields to display.
+ * 'show_parts' - (string) The value of the 'parts_display' pref.
+ *
*
* @return array An array with the following keys:
*
@@ -475,13 +483,26 @@ class IMP_Ui_Message
* 'msgtext' - (string) The rendered HTML code.
*
*/
- public function getInlineOutput($imp_contents, $contents_mask,
- $part_info_display, $show_parts)
+ public function getInlineOutput($imp_contents, $options = array())
{
$atc_parts = $display_ids = $js_onload = $wrap_ids = array();
$msgtext = '';
$parts_list = $imp_contents->getContentTypeMap();
+ $contents_mask = isset($options['mask'])
+ ? $options['mask']
+ : 0;
+ $display_mask = isset($options['display_mask'])
+ ? $options['display_mask']
+ : IMP_Contents::RENDER_INLINE_AUTO;
+ $no_inline_all = !empty($options['no_inline_all']);
+ $part_info_display = isset($options['part_info_display'])
+ ? $options['part_info_display']
+ : array();
+ $show_parts = isset($options['show_parts'])
+ ? $options['show_parts']
+ : $GLOBALS['prefs']->getValue('parts_display');
+
if ($show_parts == 'all') {
$atc_parts = array_keys($parts_list);
}
@@ -491,13 +512,15 @@ class IMP_Ui_Message
continue;
}
- if (!($render_mode = $imp_contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE | IMP_Contents::RENDER_INFO))) {
+ if (!($render_mode = $imp_contents->canDisplay($mime_id, $display_mask))) {
if ($imp_contents->isAttachment($mime_type)) {
if ($show_parts == 'atc') {
$atc_parts[] = $mime_id;
}
- $msgtext .= $this->formatSummary($imp_contents->getSummary($mime_id, $contents_mask), $part_info_display, true);
+ if ($contents_mask) {
+ $msgtext .= $this->formatSummary($imp_contents->getSummary($mime_id, $contents_mask), $part_info_display, true);
+ }
}
continue;
}
@@ -512,13 +535,20 @@ class IMP_Ui_Message
if (empty($render_part)) {
if ($imp_contents->isAttachment($mime_type)) {
- $msgtext .= $this->formatSummary($imp_contents->getSummary($mime_id, $contents_mask), $part_info_display, true);
+ if ($contents_mask) {
+ $msgtext .= $this->formatSummary($imp_contents->getSummary($mime_id, $contents_mask), $part_info_display, true);
+ }
}
continue;
}
reset($render_part);
while (list($id, $info) = each($render_part)) {
+ if ($no_inline_all === 1) {
+ $atc_parts[] = $id;
+ continue;
+ }
+
$display_ids[] = $id;
if (empty($info)) {
@@ -537,20 +567,33 @@ class IMP_Ui_Message
}
if (empty($info['attach'])) {
- $msgtext .= $this->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) .
- $this->formatStatusMsg($info['status']) .
- '
'
+));
- $body_shown = true;
- $msg_text = $info['data'];
- }
-}
+$msg_text = $inlineout['msgtext'];
/* Display the first 250 characters, or display the entire message? */
if ($prefs->getValue('mimp_preview_msg') &&
@@ -352,7 +328,7 @@ foreach ($display_headers as $head => $val) {
$t->set('hdrs', $hdrs);
$atc = array();
-foreach ($atc_parts as $key) {
+foreach ($inlineout['atc_parts'] as $key) {
$summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
$tmp = array(
@@ -365,10 +341,14 @@ foreach ($atc_parts as $key) {
/* Preference: if set, only show download confirmation screen if
* attachment over a certain size. */
$tmp['download'] = ($summary['bytes'] > $prefs->getValue('mimp_download_confirm'))
- ? $self_link->copy()->add(array('a' => 'c', 'atc' => $key))
+ ? $self_link->copy()->add(array('a' => 'pa', 'atc' => $key))
: $summary['download'];
}
+ if ($imp_contents->canDisplay($key, IMP_Contents::RENDER_INLINE_AUTO)) {
+ $tmp['view'] = $self_link->copy()->add(array('a' => 'pa', 'id' => $key));
+ }
+
$atc[] = $tmp;
}
$t->set('atc', $atc);
@@ -379,4 +359,3 @@ $t->set('title', ($status ? $status . ' | ' : '') . $display_headers['subject']
require IMP_TEMPLATES . '/common-header.inc';
IMP::status();
echo $t->fetch(IMP_TEMPLATES . '/message/message-mimp.html');
-
diff --git a/imp/message.php b/imp/message.php
index 28529eb2b..e7203bc85 100644
--- a/imp/message.php
+++ b/imp/message.php
@@ -598,7 +598,11 @@ if ($imp_ui->MDNCheck($imp_mbox['mailbox'], $uid, $mime_headers, $vars->mdn_conf
/* Build body text. This needs to be done before we build the attachment list
* that lives in the header. */
-$inlineout = $imp_ui->getInlineOutput($imp_contents, $contents_mask, $part_info_display, $show_parts);
+$inlineout = $imp_ui->getInlineOutput($imp_contents, array(
+ 'mask' => $contents_mask,
+ 'part_info_display' => $part_info_display,
+ 'show_parts' => $show_parts
+));
/* Build the Attachments menu. */
$a_template->set('atc', Horde::widget('#', _("Attachments"), 'widget hasmenu', '', '', _("Attachments"), true));
diff --git a/imp/templates/message/message-mimp.html b/imp/templates/message/message-mimp.html
index cb8453c57..fcf107342 100644
--- a/imp/templates/message/message-mimp.html
+++ b/imp/templates/message/message-mimp.html
@@ -5,7 +5,15 @@
diff --git a/imp/templates/message/download-mimp.html b/imp/templates/message/part-mimp.html
similarity index 59%
rename from imp/templates/message/download-mimp.html
rename to imp/templates/message/part-mimp.html
index 0975f1fd7..322349b80 100644
--- a/imp/templates/message/download-mimp.html
+++ b/imp/templates/message/part-mimp.html
@@ -1,8 +1,13 @@
+
-