From: Michael M Slusarz Date: Mon, 31 Aug 2009 21:50:59 +0000 (-0600) Subject: Tweak some elements to ensure compose attach previews work in all cases X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=43d61f611dd079a7ec61fde2c05784a7f5a93e0b;p=horde.git Tweak some elements to ensure compose attach previews work in all cases --- diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index 5079d3671..1a1be0f66 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -49,6 +49,14 @@ class IMP_Contents static protected $_instances = array(); /** + * Internal counter for ensuring Horde_Mime_Part objects passed to + * singleton() are given unique objects. + * + * @var integer + */ + static protected $_mimepartid = 1; + + /** * The IMAP index of the message. * * @var integer @@ -92,7 +100,7 @@ class IMP_Contents static public function singleton($in) { $sig = ($in instanceof Horde_Mime_Part) - ? hash('md5', serialize($in)) + ? 'horde_mime_part_' . self::$_mimepartid++ : $in; if (empty(self::$_instances[$sig])) { @@ -358,7 +366,9 @@ class IMP_Contents * @param array $options Additional options: *
      * 'mime_part' - (Horde_Mime_Part) The MIME part to render.
-     * 'params' - (array) Additional params to set.
+     * 'params' - (array) Additional params to set. Special params:
+     *            'raw' - The calling code wants display of the raw data,
+     *            without any additional formatting.
      * 'type' - (string) Use this MIME type instead of the MIME type
      *          identified in the MIME part.
      * 
diff --git a/imp/lib/Mime/Viewer/Images.php b/imp/lib/Mime/Viewer/Images.php index b1929a66d..ce7d1796a 100644 --- a/imp/lib/Mime/Viewer/Images.php +++ b/imp/lib/Mime/Viewer/Images.php @@ -43,7 +43,8 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images protected function _render() { $view = Horde_Util::getFormData('imp_img_view'); - if (Horde_Util::getFormData('related_data')) { + if (Horde_Util::getFormData('related_data') || + !empty($this->_params['raw'])) { $view = 'data'; } diff --git a/imp/view.php b/imp/view.php index 6ce5e7b42..0e6d0d2eb 100644 --- a/imp/view.php +++ b/imp/view.php @@ -67,12 +67,11 @@ if ($actionID == 'compose_attach_preview') { /* Initialize the IMP_Compose:: object. */ $imp_compose = IMP_Compose::singleton(Horde_Util::getFormData('composeCache')); $mime = $imp_compose->buildAttachment($id); + $mime->setMimeId($id); /* Create a dummy IMP_Contents() object so we can use the view code below. * Then use the 'view_attach' handler to output. */ $contents = IMP_Contents::singleton($mime); - $actionID = 'view_attach'; - $id = $mime->getMimeId(); } else { $uid = Horde_Util::getFormData('uid'); $mailbox = Horde_Util::getFormData('mailbox'); @@ -158,8 +157,9 @@ case 'download_render': } exit; +case 'compose_attach_preview': case 'view_attach': - $render = $contents->renderMIMEPart($id, Horde_Util::getFormData('mode', IMP_Contents::RENDER_FULL), array('type' => $ctype)); + $render = $contents->renderMIMEPart($id, Horde_Util::getFormData('mode', IMP_Contents::RENDER_FULL), array('params' => array('raw' => ($actionID == 'compose_attach_preview'), 'type' => $ctype))); if (!empty($render)) { reset($render); $key = key($render);