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
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])) {
* @param array $options Additional options:
* <pre>
* '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.
* </pre>
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';
}
/* 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');
}
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);