Tweak output from render().
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 Nov 2008 23:41:52 +0000 (16:41 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 Nov 2008 23:41:52 +0000 (16:41 -0700)
Return data by ID - allows us to chain MIME drivers. Also, always return
all information by default, for ease of handling the return value
further down the chain.

31 files changed:
framework/Mime/lib/Horde/Mime/Viewer.php
framework/Mime/lib/Horde/Mime/Viewer/Driver.php
framework/Mime/lib/Horde/Mime/Viewer/audio.php
framework/Mime/lib/Horde/Mime/Viewer/css.php
framework/Mime/lib/Horde/Mime/Viewer/deb.php
framework/Mime/lib/Horde/Mime/Viewer/enriched.php
framework/Mime/lib/Horde/Mime/Viewer/enscript.php
framework/Mime/lib/Horde/Mime/Viewer/html.php
framework/Mime/lib/Horde/Mime/Viewer/images.php
framework/Mime/lib/Horde/Mime/Viewer/msexcel.php
framework/Mime/lib/Horde/Mime/Viewer/mspowerpoint.php
framework/Mime/lib/Horde/Mime/Viewer/msword.php
framework/Mime/lib/Horde/Mime/Viewer/ooo.php
framework/Mime/lib/Horde/Mime/Viewer/pdf.php
framework/Mime/lib/Horde/Mime/Viewer/php.php
framework/Mime/lib/Horde/Mime/Viewer/plain.php
framework/Mime/lib/Horde/Mime/Viewer/rar.php
framework/Mime/lib/Horde/Mime/Viewer/report.php
framework/Mime/lib/Horde/Mime/Viewer/rfc822.php
framework/Mime/lib/Horde/Mime/Viewer/richtext.php
framework/Mime/lib/Horde/Mime/Viewer/rpm.php
framework/Mime/lib/Horde/Mime/Viewer/rtf.php
framework/Mime/lib/Horde/Mime/Viewer/simple.php
framework/Mime/lib/Horde/Mime/Viewer/smil.php
framework/Mime/lib/Horde/Mime/Viewer/srchighlite.php
framework/Mime/lib/Horde/Mime/Viewer/tgz.php
framework/Mime/lib/Horde/Mime/Viewer/tnef.php
framework/Mime/lib/Horde/Mime/Viewer/vcard.php
framework/Mime/lib/Horde/Mime/Viewer/webcpp.php
framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php
framework/Mime/lib/Horde/Mime/Viewer/zip.php

index b2d5bae..9397a41 100644 (file)
@@ -54,7 +54,8 @@ class Horde_Mime_Viewer
         if (($ob = self::_getDriver($mime_type, $GLOBALS['registry']->getApp())) &&
             self::_resolveDriver($ob['driver'], $ob['app']) &&
             class_exists($ob['class'])) {
-            return new $ob['class']($mime_part, self::$_config['mime_drivers'][$ob['app']][$ob['driver']]);
+            $conf = array_merge(self::$_config['mime_drivers'][$ob['app']][$ob['driver']], array('_driver' => $ob['driver']));
+            return new $ob['class']($mime_part, $conf);
         }
 
         return false;
index dc46921..4cbd4f5 100644 (file)
@@ -100,12 +100,13 @@ class Horde_Mime_Viewer_Driver
      *          subparts may also independently be viewed inline.
      * </pre>
      *
-     * @return array  An array with the following elements:
+     * @return array  An array. The keys are the MIME parts that were handled
+     *                by the driver. The values are either null (which
+     *                indicates the driver is recommending that this
+     *                particular MIME ID should not be displayed) or an array
+     *                with the following keys:
      * <pre>
      * 'data' - (string) The rendered data.
-     * 'ids' - (array) The list of MIME IDs that the rendered data covers
-     *         (e.g. for multipart parts, the base multipart object may
-     *         render all the data needed to display all the subparts)
      * 'status' - (array) An array of status information to be displayed to
      *            the user.  Consists of arrays with the following keys:
      *            'img' - (string) An image to display.
@@ -116,33 +117,20 @@ class Horde_Mime_Viewer_Driver
      */
     public function render($mode)
     {
-        $charset = NLS::getCharset();
-        $default = array('data' => '', 'status' => array());
-        $default['type'] = ($mode == 'full')
-            ? 'text/plain; charset=' . $charset
-            : 'text/html; charset=' . $charset;
-
-        if (is_null($this->_mimepart) || !$this->canRender($mode)) {
-            return $default;
+        if (!$this->canRender($mode)) {
+            return array();
         }
 
-        $default['ids'] = array($this->_mimepart->getMIMEId());
-
         switch ($mode) {
         case 'full':
-            $ret = $this->_render();
-            break;
+            return $this->_render();
 
         case 'inline':
-            $ret = $this->_renderInline();
-            break;
+            return $this->_renderInline();
 
         case 'info':
-            $ret = $this->_renderInfo();
-            break;
+            return $this->_renderInfo();
         }
-
-        return array_merge($default, $ret);
     }
 
     /**
@@ -216,7 +204,7 @@ class Horde_Mime_Viewer_Driver
      */
     public function getEmbeddedMimeParts()
     {
-        return (!is_null($this->_mimepart) || $this->_embeddedMimeParts())
+        return $this->_embeddedMimeParts()
             ? $this->_getEmbeddedMimeParts()
             : null;
     }
@@ -245,4 +233,14 @@ class Horde_Mime_Viewer_Driver
     {
         return isset($this->_conf[$param]) ? $this->_conf[$param] : null;
     }
+
+    /**
+     * Returns the driver name for the current object.
+     *
+     * @return string  The driver name.
+     */
+    public function getDriver()
+    {
+        return $this->_conf['_driver'];
+    }
 }
index c9c2879..8a90570 100644 (file)
@@ -33,8 +33,11 @@ class Horde_Mime_Viewer_audio extends Horde_Mime_Viewer_Driver
     protected function _render()
     {
         return array(
-            'data' => $this->_mimepart->getContents(),
-            'type' => $this->_mimepart->getType()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_mimepart->getContents(),
+                'status' => array(),
+                'type' => $this->_mimepart->getType()
+            )
         );
     }
 }
index 35d247d..6404476 100644 (file)
@@ -74,8 +74,9 @@ class Horde_Mime_Viewer_css extends Horde_Mime_Viewer_source
         $ret = $this->_renderInline();
 
         // Need Horde headers for CSS tags.
-        $ret['data'] =  Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
-            $ret['data'] .
+        reset($ret);
+        $ret[key($ret)]['data'] =  Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
+            $ret[key($ret)]['data'] .
             Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc');
 
         return $ret;
@@ -92,8 +93,11 @@ class Horde_Mime_Viewer_css extends Horde_Mime_Viewer_source
         $css = preg_replace_callback('!{[^}]*}!s', array($this, '_attributes'), $css);
         $css = preg_replace_callback('!/\*.*?\*/!s', array($this, '_comments'), $css);
         return array(
-            'data' => $this->_lineNumber(trim($css)),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_lineNumber(trim($css)),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index 233f48a..59fe125 100644 (file)
@@ -34,7 +34,8 @@ class Horde_Mime_Viewer_deb extends Horde_Mime_Viewer_Driver
     {
         $ret = $this->_renderInline();
         if (!empty($ret)) {
-            $ret['data'] = '<html><body>' . $ret['data'] . '</body></html>';
+            reset($ret);
+            $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
         }
         return $ret;
     }
@@ -63,8 +64,11 @@ class Horde_Mime_Viewer_deb extends Horde_Mime_Viewer_Driver
         pclose($fh);
 
         return array(
-            'data' => '<pre>' . htmlspecialchars($data) . '</pre>',
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => '<pre>' . htmlspecialchars($data) . '</pre>',
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 1165c2e..b0912e4 100644 (file)
@@ -45,8 +45,11 @@ class Horde_Mime_Viewer_enriched extends Horde_Mime_Viewer_Driver
     protected function _render()
     {
         return array(
-            'data' => '<html><body>' . $this->_toHTML() . '</body></html>',
-            'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => '<html><body>' . $this->_toHTML() . '</body></html>',
+                'status' => array(),
+                'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
+            )
         );
     }
 
@@ -58,8 +61,11 @@ class Horde_Mime_Viewer_enriched extends Horde_Mime_Viewer_Driver
     protected function _renderInline()
     {
         return array(
-            'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index c63132d..a21d390 100644 (file)
@@ -36,8 +36,11 @@ class Horde_Mime_Viewer_enscript extends Horde_Mime_Viewer_source
     protected function _render()
     {
         return array(
-            'data' => $this->_toHTML(false),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_toHTML(false),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
@@ -49,8 +52,11 @@ class Horde_Mime_Viewer_enscript extends Horde_Mime_Viewer_source
     protected function _renderInline()
     {
         return array(
-            'data' => $this->_toHTML(true),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_toHTML(true),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index 7dd3f7c..ea7a246 100644 (file)
@@ -37,9 +37,11 @@ class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver
         $html = $this->_cleanHTML($this->_mimepart->getContents(), false);
 
         return array(
-            'data' => $html['data'],
-            'status' => $html['status'],
-            'type' => $this->_mimepart->getType(true)
+            $this->_mimepart->getMimeId() => array(
+                'data' => $html['data'],
+                'status' => $html['status'],
+                'type' => $this->_mimepart->getType(true)
+            )
         );
     }
 
@@ -53,8 +55,11 @@ class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver
         $html = $this->_cleanHTML($this->_mimepart->getContents(), true);
 
         return array(
-            'data' => String::convertCharset($html['data'], $this->_mimepart->getCharset()),
-            'status' => $html['status']
+            $this->_mimepart->getMimeId() => array(
+                'data' => String::convertCharset($html['data'], $this->_mimepart->getCharset()),
+                'status' => $html['status'],
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index cb72df3..ae8fc07 100644 (file)
@@ -32,8 +32,11 @@ class Horde_Mime_Viewer_images extends Horde_Mime_Viewer_Driver
     protected function _render()
     {
         return array(
-            'data' => $this->_mimepart->getContents(),
-            'type' => $this->_getType()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_mimepart->getContents(),
+                'status' => array(),
+                'type' => $this->_getType()
+            )
         );
     }
 
index 654bb52..4293447 100644 (file)
@@ -50,8 +50,11 @@ class Horde_Mime_Viewer_msexcel extends Horde_Mime_Viewer_Driver
         pclose($fh);
 
         return array(
-            'data' => $data,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $data,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 8a62308..1101c3e 100644 (file)
@@ -50,8 +50,11 @@ class Horde_Mime_Viewer_mspowerpoint extends Horde_Mime_Viewer_Driver
         pclose($fh);
 
         return array(
-            'data' => $data,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $data,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 6a98138..deeb511 100644 (file)
@@ -59,16 +59,22 @@ class Horde_Mime_Viewer_msword extends Horde_Mime_Viewer_Driver
 
         exec($this->_conf['location'] . $args);
 
-        if (!file_exists($tmp_output)) {
+        if (file_exists($tmp_output)) {
             return array(
-                'data' => _("Unable to translate this Word document"),
-                'type' => 'text/plain; charset=' . $charset
+                $this->_mimepart->getMimeId() => array(
+                    'data' => file_get_contents($tmp_output),
+                    'status' => array(),
+                    'type' => 'text/html; charset=' . $charset
+                )
             );
         }
 
         return array(
-            'data' => file_get_contents($tmp_output),
-            'type' => 'text/html; charset=' . $charset
+            $this->_mimepart->getMimeId() => array(
+                'data' => _("Unable to translate this Word document"),
+                'status' => array(),
+                'type' => 'text/plain; charset=' . $charset
+            )
         );
     }
 }
index 39feee3..b4b43e0 100644 (file)
@@ -63,13 +63,19 @@ class Horde_Mime_Viewer_ooo extends Horde_Mime_Viewer_Driver
                 if ($use_xslt) {
                     file_put_contents($tmpdir . $file['name'], $content);
                 } elseif ($file['name'] == 'content.xml') {
-                    return str_replace(array_keys($tags), array_values($tags), $content);
+                    return array(
+                        $this->_mimepart->getMimeId() => array(
+                            'data' => str_replace(array_keys($tags), array_values($tags), $content),
+                            'status' => array(),
+                            'type' => 'text/html; charset=UTF-8'
+                        )
+                    );
                 }
             }
         }
 
         if (!Util::extensionExists('xslt')) {
-            return;
+            return array();
         }
 
         $xsl_file = dirname(__FILE__) . '/ooo/main_html.xsl';
@@ -99,8 +105,11 @@ class Horde_Mime_Viewer_ooo extends Horde_Mime_Viewer_Driver
         }
 
         return array(
-            'data' => $result,
-            'type' => 'text/html; charset=UTF-8'
+            $this->_mimepart->getMimeId() => array(
+                'data' => $result,
+                'status' => array(),
+                'type' => 'text/html; charset=UTF-8'
+            )
         );
     }
 }
index f44506d..a38693b 100644 (file)
@@ -34,8 +34,11 @@ class Horde_Mime_Viewer_pdf extends Horde_Mime_Viewer_Driver
     protected function _render()
     {
         return array(
-            'data' => $this->_mimepart->getContents(),
-            'type' => 'application/pdf'
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_mimepart->getContents(),
+                'status' => array(),
+                'type' => 'application/pdf'
+            )
         );
     }
 }
index 8de75c2..2d10bd1 100644 (file)
@@ -35,8 +35,9 @@ class Horde_Mime_Viewer_php extends Horde_Mime_Viewer_Driver
         $ret = $this->_renderInline();
 
         // Need Horde headers for CSS tags.
-        $ret['data'] =  Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
-            $ret['data'] .
+        reset($ret);
+        $ret[key($ret)]['data'] =  Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
+            $ret[key($ret)]['data'] .
             Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc');
 
         return $ret;
@@ -61,8 +62,11 @@ class Horde_Mime_Viewer_php extends Horde_Mime_Viewer_Driver
             : $this->_lineNumber(highlight_string($code, true));
 
         return array(
-            'data' => $text,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $text,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index 0963a55..88a9eb7 100644 (file)
@@ -43,8 +43,11 @@ class Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_Driver
 
         require_once 'Horde/Text/Filter.php';
         return array(
-            'data' => '<html><body><tt>' . Text_Filter::filter($text, 'text2html', array('parselevel' => TEXT_HTML_MICRO, 'charset' => $charset, 'class' => null)) . '</tt></body></html>',
-            'type' => 'text/html; charset=' . $charset
+            $this->_mimepart->getMimeId() => array(
+                'data' => '<html><body><tt>' . Text_Filter::filter($text, 'text2html', array('parselevel' => TEXT_HTML_MICRO, 'charset' => $charset, 'class' => null)) . '</tt></body></html>',
+                'status' => array(),
+                'type' => 'text/html; charset=' . $charset
+            )
         );
     }
 
@@ -62,7 +65,13 @@ class Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_Driver
             ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'))
             : $text;
 
-        return array('data' => $data);
+        return array(
+            $this->_mimepart->getMimeId() => array(
+                'data' => $data,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
+        );
     }
 
     /**
index 96751ea..c4cb7ff 100644 (file)
@@ -35,7 +35,8 @@ class Horde_Mime_Viewer_rar extends Horde_Mime_Viewer_Driver
     {
         $ret = $this->_renderInline();
         if (!empty($ret)) {
-            $ret['data'] = '<html><body>' . $ret['data'] . '</body></html>';
+            reset($ret);
+            $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
         }
         return $ret;
     }
@@ -65,7 +66,6 @@ class Horde_Mime_Viewer_rar extends Horde_Mime_Viewer_Driver
             $name = _("unnamed");
         }
 
-
         $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':</strong>' . "\n" .
             '<table><tr><td align="left"><tt><span class="fixed">' .
             Text::htmlAllSpaces(_("Archive Name") . ':  ' . $name) . "\n" .
@@ -98,8 +98,11 @@ class Horde_Mime_Viewer_rar extends Horde_Mime_Viewer_Driver
         }
 
         return array(
-            'data' => nl2br($text . str_repeat('-', 106) . "\n" . '</span></tt></td></tr></table>'),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => nl2br($text . str_repeat('-', 106) . "\n" . '</span></tt></td></tr></table>'),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 2393f9e..5c5df06 100644 (file)
@@ -71,7 +71,7 @@ class Horde_Mime_Viewer_report extends Horde_Mime_Viewer_Driver
         $viewer = $this->_getViewer();
         return $viewer
             ? $viewer->render($inline ? 'inline' : 'full')
-            : false;
+            : array();
     }
 
     /**
index c1fdd79..d025b63 100644 (file)
@@ -33,8 +33,11 @@ class Horde_Mime_Viewer_rfc822 extends Horde_Mime_Viewer_Driver
     protected function _render()
     {
         return array(
-            'data' => $this->_mimepart->getContents(),
-            'type' => 'text/plain; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_mimepart->getContents(),
+                'status' => array(),
+                'type' => 'text/plain; charset=' . NLS::getCharset()
+            )
         );
     }
 
@@ -80,7 +83,11 @@ class Horde_Mime_Viewer_rfc822 extends Horde_Mime_Viewer_Driver
 
         require_once 'Horde/Text/Filter.php';
         return array(
-            'data' => '<div class="mimeHeaders">' . Text_Filter::filter(implode("<br />\n", $header_output), 'emails') . '</div>'
+            $this->_mimepart->getMimeId() => array(
+                'data' => '<div class="mimeHeaders">' . Text_Filter::filter(implode("<br />\n", $header_output), 'emails') . '</div>',
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index deb391c..1bd329c 100644 (file)
@@ -53,7 +53,13 @@ class Horde_Mime_Viewer_richtext extends Horde_Mime_Viewer_Driver
      */
     protected function _render()
     {
-        return $this->_toHTML(false);
+        return array(
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_toHTML(),
+                'status' => array(),
+                'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
+            )
+        );
     }
 
     /**
@@ -63,25 +69,27 @@ class Horde_Mime_Viewer_richtext extends Horde_Mime_Viewer_Driver
      */
     protected function _renderInline()
     {
-        return $this->_toHTML(true);
+        return array(
+            $this->_mimepart->getMimeId() => array(
+                'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
+        );
     }
 
     /**
      * Convert richtext to HTML.
      *
-     * @param boolean  View inline?
-     *
      * @return string  The converted HTML string.
      */
-    protected function _toHTML($inline)
+    protected function _toHTML()
     {
         $text = trim($this->_mimepart->getContents());
         if ($text == '') {
-            return $text;
+            return array();
         }
 
-        $charset = $this->_mimepart->_getCharset();
-
         /* We add space at the beginning and end of the string as it will
          * make some regular expression checks later much easier (so we
          * don't have to worry about start/end of line characters). */
@@ -100,7 +108,7 @@ class Horde_Mime_Viewer_richtext extends Horde_Mime_Viewer_Driver
         $text = str_ireplace(array('<lt>', "\r\n"), array('&lt;', ' '), $text);
 
         /* We try to protect against bad stuff here. */
-        $text = @htmlspecialchars($text, ENT_QUOTES, $charset);
+        $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset());
 
         /* <nl> becomes a newline (<br />);
          * <np> becomes a paragraph break (<p />). */
@@ -138,18 +146,6 @@ class Horde_Mime_Viewer_richtext extends Horde_Mime_Viewer_Driver
             $text = '&nbsp;' . substr($text, 1);
         }
 
-        $text = '<p style="font-size:100%;font-family:Lucida Console,Courier,Courier New;">' . nl2br($text) . '</p>';
-
-        if ($inline) {
-            return array(
-                'data' => String::convertCharset($text, $charset),
-                'type' => 'text/html; charset=' . NLS::getCharset()
-            );
-        } else {
-            return array(
-                'data' => $text,
-                'type' => 'text/html; charset=' . $charset
-            );
-        }
+        return '<p style="font-size:100%;font-family:Lucida Console,Courier,Courier New;">' . nl2br($text) . '</p>';
     }
 }
index fcebc89..6201d9a 100644 (file)
@@ -50,8 +50,11 @@ class Horde_Mime_Viewer_rpm extends Horde_Mime_Viewer_Driver
         pclose($fh);
 
         return array(
-            'data' => '<html><body><pre>' . htmlentities($data) . '</pre></body></html>',
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => '<html><body><pre>' . htmlentities($data) . '</pre></body></html>',
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index e6b7baa..129c172 100644 (file)
@@ -53,8 +53,11 @@ class Horde_Mime_Viewer_rtf extends Horde_Mime_Viewer_Driver
         }
 
         return array(
-            'data' => $data,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $data,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index c931be2..5d7779b 100644 (file)
@@ -33,8 +33,11 @@ class Horde_Mime_Viewer_simple extends Horde_Mime_Viewer_Driver
     protected function _render()
     {
         return array(
-            'data' => $this->_mimepart->getContents(),
-            'type' => 'text/plain; charset=' . $this->_mimepart->getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_mimepart->getContents(),
+                'status' => array(),
+                'type' => 'text/plain; charset=' . $this->_mimepart->getCharset()
+            )
         );
     }
 
@@ -46,8 +49,11 @@ class Horde_Mime_Viewer_simple extends Horde_Mime_Viewer_Driver
     protected function _renderInline()
     {
         return array(
-            'data' => String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset()),
-            'type' => 'text/plain; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset()),
+                'status' => array(),
+                'type' => 'text/plain; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 6138a5c..db0b466 100644 (file)
@@ -56,8 +56,11 @@ class Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_Driver
         xml_parser_free($this->_parser);
 
         return array(
-            'data' => $this->_content,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_content,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index 748ef69..f553089 100644 (file)
@@ -40,8 +40,9 @@ class Horde_Mime_Viewer_srchighlite extends Horde_Mime_Viewer_source
         $ret = $this->_renderInline();
 
         // Need Horde headers for CSS tags.
-        $ret['data'] =  Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
-            $ret['data'] .
+        reset($ret);
+        $ret[key($ret)]['data'] =  Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
+            $ret[key($ret)]['data'] .
             Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc');
 
         return $ret;
@@ -76,8 +77,11 @@ class Horde_Mime_Viewer_srchighlite extends Horde_Mime_Viewer_source
         unlink($tmpout);
 
         return array(
-            'data' => $this->_lineNumber($results),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $this->_lineNumber($results),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index 4c8d5c6..1bb1088 100644 (file)
@@ -43,7 +43,8 @@ class Horde_Mime_Viewer_tgz extends Horde_Mime_Viewer_Driver
     {
         $ret = $this->_renderInline();
         if (!empty($ret)) {
-            $ret['data'] = '<html><body>' . $ret['data'] . '</body></html>';
+            reset($ret);
+            $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
         }
         return $ret;
     }
@@ -107,8 +108,11 @@ class Horde_Mime_Viewer_tgz extends Horde_Mime_Viewer_Driver
         }
 
         return array(
-            'data' => nl2br($text . str_repeat('-', 106) . "\n" . '</span></tt></td></tr></table>'),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => nl2br($text . str_repeat('-', 106) . "\n" . '</span></tt></td></tr></table>'),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 224a557..101613c 100644 (file)
@@ -35,7 +35,8 @@ class Horde_Mime_Viewer_tnef extends Horde_Mime_Viewer_Driver
     {
         $ret = $this->_renderInline();
         if (!empty($ret)) {
-            $ret['data'] = '<html><body>' . $ret['data'] . '</body></html>';
+            reset($ret);
+            $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
         }
         return $ret;
     }
@@ -63,8 +64,11 @@ class Horde_Mime_Viewer_tnef extends Horde_Mime_Viewer_Driver
         $data .= '</table>';
 
         return array(
-            'data' => $data,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $data,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 659b764..d6e95e3 100644 (file)
@@ -33,8 +33,9 @@ class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver
     {
         $ret = $this->_renderInline();
         if (!empty($ret)) {
-            $ret['data'] = Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
-                $ret['data'] .
+            reset($ret);
+            $ret[key($ret)]['data'] = Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') .
+                $ret[key($ret)]['data'] .
                 Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc');
         }
         return $ret;
@@ -374,8 +375,11 @@ class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver
         $html .=  '</table>';
 
         return array(
-            'data' => Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')) . $html,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')) . $html,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 
index 0dad466..d878013 100644 (file)
@@ -38,7 +38,8 @@ class Horde_Mime_Viewer_webcpp extends Horde_Mime_Viewer_Driver
 
         /* The first 2 lines are the Content-Type line and a blank line so
          * remove them before outputting. */
-        $ret['data'] = preg_replace("/.*\n.*\n/", '', $ret['data'], 1);
+        reset($ret);
+        $ret[key($ret)]['data'] = preg_replace("/.*\n.*\n/", '', $ret[key($ret)]['data'], 1);
 
         return $ret;
     }
@@ -51,7 +52,8 @@ class Horde_Mime_Viewer_webcpp extends Horde_Mime_Viewer_Driver
     protected function _renderInline()
     {
         $ret = $this->_toHTML();
-        $data = $ret['data'];
+        reset($ret);
+        $data = $ret[key($ret)]['data'];
 
         /* Extract the style sheet, removing any global body formatting
          * if we're displaying inline. */
@@ -63,7 +65,7 @@ class Horde_Mime_Viewer_webcpp extends Horde_Mime_Viewer_Driver
         $res = preg_split('/\<\/?pre\>/', $data);
         $body = $res[1];
 
-        $ret['data'] = '<style>' . $style . '</style><div class="webcpp" style="white-space:pre;font-family:Lucida Console,Courier,monospace;">' . $body . '</div>';
+        $ret[key($ret)]['data'] = '<style>' . $style . '</style><div class="webcpp" style="white-space:pre;font-family:Lucida Console,Courier,monospace;">' . $body . '</div>';
 
         return $ret;
     }
@@ -98,8 +100,11 @@ class Horde_Mime_Viewer_webcpp extends Horde_Mime_Viewer_Driver
         $results = file_get_contents($tmpout);
 
         return array(
-            'data' => $results,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $results,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index 3090eb9..adaf447 100644 (file)
@@ -54,8 +54,11 @@ class Horde_Mime_Viewer_wordperfect extends Horde_Mime_Viewer_Driver
         }
 
         return array(
-            'data' => $data,
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => $data,
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }
index f7be978..d159822 100644 (file)
@@ -42,7 +42,8 @@ class Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Driver
     {
         $ret = $this->_toHTML();
         if (!empty($ret)) {
-            $ret['data'] = '<html><body>' . $ret['data'] . '</body></html>';
+            reset($ret);
+            $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
         }
         return $ret;
     }
@@ -136,8 +137,11 @@ class Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Driver
         }
 
         return array(
-            'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . '</span></tt></td></tr></table>'),
-            'type' => 'text/html; charset=' . NLS::getCharset()
+            $this->_mimepart->getMimeId() => array(
+                'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . '</span></tt></td></tr></table>'),
+                'status' => array(),
+                'type' => 'text/html; charset=' . NLS::getCharset()
+            )
         );
     }
 }