From 20457b0f110f4922b194c489b7eb40ab90a749f7 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 10 Nov 2008 16:42:05 -0700 Subject: [PATCH] Use new Horde_Mime_Viewer API. --- imp/lib/Contents.php | 28 ++++++---------------------- imp/lib/Mime/Viewer/html.php | 8 ++++++-- imp/lib/Mime/Viewer/plain.php | 19 ++++++------------- imp/message.php | 10 +++++----- imp/view.php | 4 ++-- 5 files changed, 25 insertions(+), 44 deletions(-) diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index d4bff5381..e4aa05726 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -275,29 +275,16 @@ class IMP_Contents * * @return */ - public function renderMIMEPart($mime_id, $options = array()) + public function renderMIMEPart($mime_id, $format, $options = array()) { $mime_part = $this->getMIMEPart($mime_id); $viewer = Horde_Mime_Viewer::factory(empty($options['type']) ? $mime_part->getType() : $options['type']); $viewer->setMIMEPart($mime_part); $viewer->setParams(array('contents' => &$this)); - switch($options['format']) { - case 'inline': - $data = $viewer->renderInline(); - break; - - case 'info': - $data = $viewer->renderInfo(); - break; - - case 'full': - $data = $viewer->render(); - return array('data' => $data['data'], 'name' => $mime_part->getName(true), 'type' => $data['type']); - break; - } - - return array('data' => $data, 'name' => $mime_part->getName(true), 'type' => null); + $ret = $viewer->render($format); + $ret['name'] => $mime_part->getName(true); + return $ret; } /** @@ -438,17 +425,14 @@ class IMP_Contents $last_id = null; $viewer = Horde_Mime_Viewer::factory($mime_type); - if ($viewer->canDisplayInline() && + if ($viewer->canRender('inline') && ($mime_part->getDisposition() == 'inline')) { $part['render_inline'] = true; $info['render'][$mime_id] = 'inline'; $last_id = $mime_id; - } elseif (is_null($last_id) && $viewer->canDisplayInfo()) { - // TODO - Need way to show info while allowing display of - // subparts. + } elseif (is_null($last_id) && $viewer->canRender('info')) { $part['render_info'] = true; $info['render'][$mime_id] = 'info'; - $last_id = $mime_id; } } diff --git a/imp/lib/Mime/Viewer/html.php b/imp/lib/Mime/Viewer/html.php index b98565cd4..72beb8db6 100644 --- a/imp/lib/Mime/Viewer/html.php +++ b/imp/lib/Mime/Viewer/html.php @@ -63,7 +63,9 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html /isx'; /** - * TODO + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). */ protected function _render() { @@ -77,7 +79,9 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html } /** - * TODO + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). */ protected function _renderInline() { diff --git a/imp/lib/Mime/Viewer/plain.php b/imp/lib/Mime/Viewer/plain.php index f5887b851..283715b72 100644 --- a/imp/lib/Mime/Viewer/plain.php +++ b/imp/lib/Mime/Viewer/plain.php @@ -15,7 +15,9 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain { /** - * TODO + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). */ protected function _renderInline() { @@ -24,10 +26,7 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain // Trim extra whitespace in the text. $text = rtrim($this->_mimepart->getContents()); if ($text == '') { - return array( - 'data' => '', - 'status' => array() - ); + return array(); } // If requested, scan the message for PGP data. @@ -37,10 +36,7 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain require_once IMP_BASE . '/lib/Crypt/PGP.php'; $imp_pgp = new IMP_PGP(); if (($out = $imp_pgp->parseMessageOutput($this->_mimepart, $this->_params['contents']))) { - return array( - 'data' => $out, - 'status' => array() - ); + return array('data' => $out); } } @@ -107,9 +103,6 @@ class IMP_Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_plain $text = ' ' . substr($text, 1); } - return array( - 'data' => '
' . "\n" . $text . '
', - 'status' => array() - ); + return array('data' => '
' . "\n" . $text . '
'); } } diff --git a/imp/message.php b/imp/message.php index 9592231fa..c63c00d00 100644 --- a/imp/message.php +++ b/imp/message.php @@ -633,9 +633,9 @@ if (!$printer_friendly) { $atc_display = $prefs->getValue('attachment_display'); $show_parts = (($atc_display == 'list') || ($atc_display == 'both')); -$downloadall_link = empty($summary['message']['download_all']) +$downloadall_link = empty($summary['info']['download_all']) ? false - : $imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all', array('params' => array('download_ids' => serialize($summary['message']['download_all'])))); + : $imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all', array('params' => array('download_ids' => serialize($summary['info']['download_all'])))); $hdrs = array(); $i = 1; @@ -660,8 +660,8 @@ if (!empty($summary['parts']) && $val = ''; if ($show_parts) { $part_info = array('icon', 'id', 'description', 'type', 'size'); - foreach (array('download_link', 'zip', 'img_save', 'strip') as $val) { - if ($summary['message']['has_' . $val]) { + foreach (array('download', 'download_zip', 'img_save', 'strip') as $val) { + if (isset($summary['info']['has'][$val])) { $part_info[] = $val; } } @@ -692,7 +692,7 @@ if ($printer_friendly && !empty($conf['print']['add_printedby'])) { $m_template->set('headers', $hdrs); // TODO -$m_template->set('msgtext', reset($inline_parts)); +//$m_template->set('msgtext', reset($inline_parts)); echo $m_template->fetch(IMP_TEMPLATES . '/message/message.html'); if (!$printer_friendly) { diff --git a/imp/view.php b/imp/view.php index f17a87740..3358cd7fd 100644 --- a/imp/view.php +++ b/imp/view.php @@ -108,7 +108,7 @@ case 'download_render': break; case 'download_render': - $render = $contents->renderMIMEPart($id, array('format' => 'full', 'type' => $ctype)); + $render = $contents->renderMIMEPart($id, 'full', array('type' => $ctype)); $body = $render['body']; $type = $render['type']; $name = $render['name']; @@ -131,7 +131,7 @@ case 'download_render': exit; case 'view_attach': - $render = $contents->renderMIMEPart($id, array('format' => 'full', 'type' => $ctype)); + $render = $contents->renderMIMEPart($id, 'full', array('type' => $ctype)); $browser->downloadHeaders($render['name'], $render['type'], true, strlen($render['data'])); echo $render['data']; exit; -- 2.11.0