'column' => _("Other Options"),
'label' => _("Minimalist View Options"),
'desc' => _("Configure options for the minimalist view."),
- 'members' => array('mimp_preview_msg', 'mimp_download_confirm')
+ 'members' => array('mimp_preview_msg', 'mimp_download_confirm',
+ 'mimp_inline_all')
);
$prefGroups['standard'] = array(
$_prefs['mimp_download_confirm'] = array(
'value' => 0,
+ // Locked by default
'locked' => true,
'shared' => false,
'type' => 'number',
'desc' => _("Only show download confirmation page if message part is greater than this size, in bytes. Set to 0 to always require the confirmation page.")
);
+$_prefs['mimp_inline_all'] = array(
+ 'value' => 0,
+ // Locked by default
+ 'locked' => true,
+ 'shared' => false,
+ 'type' => 'checkbox',
+ 'desc' => _("Show all inline parts by default in message view? If unchecked, will treat all but the first viewable inline part as attachments.")
+);
+
// End Minimalist View Options
// Standard View Options
v5.0-git
--------
+[mms] Add preference to allow viewing of all inline parts by default (MIMP).
[mms] Add hook to alter composed message details before sending.
[mms] DIMP now honors the 'allow_resume_all' configuration option.
[mms] Remove 'sort_limit' configuration option.
}
/**
- * Output inline message display for the imp and dimp views.
+ * Generate inline message display.
*
- * @param object $imp_contents The IMP_Contents object containing the
- * message data.
- * @param integer $contents_mask The mask needed for a
- * IMP_Contents::getSummary() call.
- * @param array $part_info_display The list of summary fields to display.
- * @param string $show_parts The value of the 'parts_display' pref.
+ * @param object $imp_contents The IMP_Contents object containing the
+ * message data.
+ * @param array $options Additional options:
+ * <pre>
+ * '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.
+ * </pre>
*
* @return array An array with the following keys:
* <pre>
* 'msgtext' - (string) The rendered HTML code.
* </pre>
*/
- 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);
}
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;
}
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)) {
}
if (empty($info['attach'])) {
- $msgtext .= $this->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) .
- $this->formatStatusMsg($info['status']) .
- '<div class="mimePartData">' . $info['data'] . '</div>';
+ if ($contents_mask) {
+ $msgtext .= $this->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display) .
+ $this->formatStatusMsg($info['status']) .
+ '<div class="mimePartData">' . $info['data'] . '</div>';
+ } else {
+ if ($msgtext && !empty($options['sep'])) {
+ $msgtext .= $options['sep'];
+ }
+ $msgtext .= $info['data'];
+ }
} else {
if ($show_parts == 'atc') {
$atc_parts[] = $id;
}
- $msgtext .= $this->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display, true);
+ if ($contents_mask) {
+ $msgtext .= $this->formatSummary($imp_contents->getSummary($id, $contents_mask), $part_info_display, true);
+ }
}
if (isset($info['js'])) {
$js_onload = array_merge($js_onload, $info['js']);
}
+
+ if ($no_inline_all) {
+ $no_inline_all = 1;
+ }
}
}
/* Build body text. This needs to be done before we build the
* attachment list. */
- $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
+ ));
$result['js'] = array_merge($result['js'], $inlineout['js_onload']);
$result['msgtext'] .= $inlineout['msgtext'];
$msg_delete = (IMP_Spam::reportSpam(array($index_array['mailbox'] => array($index_array['uid'])), $vars->a == 'rs' ? 'spam' : 'innocent') === 1);
break;
-// 'c' = confirm download
+// 'pa' = part action
// Need to build message information, so don't do action until below.
}
$t = $injector->createInstance('Horde_Template');
$t->setOption('gettext', true);
-/* Output download confirmation screen. */
-if (($vars->a == 'c') && isset($vars->atc)) {
- $summary = $imp_contents->getSummary($vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
+/* Output part action screen. */
+if (($vars->a == 'pa') &&
+ (isset($vars->atc) || isset($vars->id))) {
+ if (isset($vars->atc)) {
+ $summary = $imp_contents->getSummary($vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
- $title = _("Verify Download");
+ $title = _("Download Attachment");
+
+ $t->set('descrip', $summary['description']);
+ $t->set('download', $summary['download']);
+ $t->set('size', $summary['size']);
+ $t->set('type', $summary['type']);
+ } else {
+ $title = _("View Attachment");
+
+ $data = $imp_contents->renderMIMEPart($vars->id, $imp_contents->canDisplay($vars->id, IMP_Contents::RENDER_INLINE | IMP_Contents::RENDER_INFO));
+ $t->set('view_data', $data ? $data : _("This part is empty."));
+ }
- $t->set('descrip', $summary['description']);
- $t->set('download', $summary['download']);
$t->set('self_link', $self_link);
- $t->set('size', $summary['size']);
- $t->set('type', $summary['type']);
require IMP_TEMPLATES . '/common-header.inc';
- echo $t->fetch(IMP_TEMPLATES . '/message/download-mimp.html');
+ echo $t->fetch(IMP_TEMPLATES . '/message/part-mimp.html');
exit;
}
}
/* Create the body of the message. */
-$parts_list = $imp_contents->getContentTypeMap();
-$atc_parts = $display_ids = array();
-$body_shown = false;
-$msg_text = '';
-
-foreach ($parts_list as $mime_id => $mime_type) {
- if (in_array($mime_id, $display_ids, true)) {
- continue;
- }
-
- if ($body_shown ||
- !($render_mode = $imp_contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE | IMP_Contents::RENDER_INFO))) {
- if ($imp_contents->isAttachment($mime_type)) {
- $atc_parts[] = $mime_id;
- }
- continue;
- }
-
- $render_part = $imp_contents->renderMIMEPart($mime_id, $render_mode);
- if (($render_mode & IMP_Contents::RENDER_INLINE) && empty($render_part)) {
- /* This meant that nothing was rendered - allow this part to appear
- * in the attachment list instead. */
- $atc_parts[] = $mime_id;
- continue;
- }
-
- while (list($id, $info) = each($render_part)) {
- if ($body_shown) {
- $atc_parts[] = $id;
- continue;
- }
-
- if (empty($info)) {
- continue;
- }
+$inlineout = $imp_ui->getInlineOutput($imp_contents, array(
+ 'display_mask' => IMP_Contents::RENDER_INLINE,
+ 'no_inline_all' => !$prefs->getValue('mimp_inline_all'),
+ 'sep' => '<br /><hr />'
+));
- $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') &&
$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(
/* 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);
require IMP_TEMPLATES . '/common-header.inc';
IMP::status();
echo $t->fetch(IMP_TEMPLATES . '/message/message-mimp.html');
-
/* 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));
+++ /dev/null
- <p>
- <gettext>Click to verify download of attachment</gettext>:
- <a href="<tag:download />"><tag:descrip /></a>
- [<tag:type />] <tag:size />
- </p>
- <p>
- <a href="<tag:self_link />"><gettext>Return to message view</gettext></a>
- </p>
- </body>
-</html>
<div><em><tag:hdrs.label />:</em> <tag:hdrs.val /><if:hdrs.all_to> [<a href="<tag:hdrs.all_to />"><gettext>Show All</gettext></a>]</if:hdrs.all_to></div>
</loop:hdrs>
<loop:atc>
- <div><em><gettext>Attachment</gettext>:</em> <if:atc.download><a href="<tag:atc.download />"><tag:atc.descrip /></a><else:atc.download><tag:atc.descrip /></else:atc.download></if:atc.download> [<tag:atc.type />] <tag:atc.size /></div>
+ <div>
+ <em><gettext>Attachment</gettext>:</em> <tag:atc.descrip /> (<tag:atc.type />) <tag:atc.size />
+<if:atc.view>
+ [<a href="<tag:atc.view />">View</a>]
+</if:atc.view>
+<if:atc.download>
+ [<a href="<tag:atc.download />">Download</a>]
+</if:atc.download>
+ </div>
</loop:atc>
</p>
<p>
--- /dev/null
+<if:view_data>
+ <tag:view_data />
+<else:view_data>
+ <p>
+ <gettext>Download attachment</gettext>:
+ <a href="<tag:download />"><tag:descrip /></a>
+ [<tag:type />] <tag:size />
+ </p>
+</else:view_data></if:view_data>
+ <hr />
+ <p>
+ <a href="<tag:self_link />"><gettext>Return to message view</gettext></a>
+ </p>
+ </body>
+</html>