Load Mime_Viewer through an injector.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Aug 2010 18:30:09 +0000 (12:30 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Aug 2010 20:38:19 +0000 (14:38 -0600)
NOTE: THE FORMAT OF config/mime_drivers.php HAS CHANGED. YOU MUST UPDATE
YOUR MIME CONFIGURATION.

This change has removed a bunch of complexity from the mime_drivers
configuration files (no need to explicit identify the application in the
files anymore; removed the 'registered' and 'override' options since
they can be handled solely within driver config; made the enable/inline
config parameters optional).

85 files changed:
agora/lib/Messages.php
chora/browsedir.php
chora/config/mime_drivers.php.dist
chora/lib/Chora.php
framework/Core/lib/Horde/Core/Binder/MimeViewer.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Factory/MimeViewer.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Mime/Viewer/Css.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php [new file with mode: 0644]
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml
framework/Mime_Viewer/lib/Horde/Mime/Viewer.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Base.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Css.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Deb.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Enriched.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Html.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Images.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Msexcel.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Mspowerpoint.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Msword.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Ooo.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Php.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Plain.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rar.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Report.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rfc822.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Richtext.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rpm.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rtf.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Security.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Smil.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Srchighlite.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Tgz.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Tnef.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php [deleted file]
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Wordperfect.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Zip.php
framework/Mime_Viewer/package.xml
gollem/config/mime_drivers.php.dist
gollem/lib/Mime/Viewer/Images.php
gollem/manager.php
horde/admin/phpshell.php
horde/config/mime_drivers.php.dist
horde/docs/UPGRADING
imp/compose.php
imp/config/mime_drivers.php.dist
imp/lib/Application.php
imp/lib/Contents.php
imp/lib/Injector/Binder/MimeViewer.php [new file with mode: 0644]
imp/lib/Injector/Factory/MimeViewer.php [new file with mode: 0644]
imp/lib/Mime/Viewer/Alternative.php
imp/lib/Mime/Viewer/Appledouble.php
imp/lib/Mime/Viewer/Enriched.php
imp/lib/Mime/Viewer/Html.php
imp/lib/Mime/Viewer/Images.php
imp/lib/Mime/Viewer/Itip.php
imp/lib/Mime/Viewer/Mdn.php
imp/lib/Mime/Viewer/Partial.php
imp/lib/Mime/Viewer/Pdf.php
imp/lib/Mime/Viewer/Pgp.php
imp/lib/Mime/Viewer/Plain.php
imp/lib/Mime/Viewer/Related.php
imp/lib/Mime/Viewer/Rfc822.php
imp/lib/Mime/Viewer/Smil.php
imp/lib/Mime/Viewer/Smime.php
imp/lib/Mime/Viewer/Status.php
imp/lib/Mime/Viewer/Tnef.php
imp/lib/Mime/Viewer/Vcard.php
imp/lib/Mime/Viewer/Zip.php
imp/lib/Prefs/Ui.php
imp/lib/Ui/Message.php
imp/view.php
luxor/config/mime_drivers.php.dist
luxor/lib/Luxor.php
luxor/source.php
news/files.php
news/lib/News.php
turba/config/mime_drivers.php.dist
turba/lib/Object.php
turba/view.php
whups/config/mime_drivers.php.dist
whups/lib/Mime/Viewer/Zip.php
whups/lib/Whups.php
whups/view.php
wicked/templates/display/standard.inc

index c08dcaf..c0c02f5 100644 (file)
@@ -1648,7 +1648,7 @@ class Agora_Messages {
         $html = '<br />';
         $view_url = Horde::applicationUrl('view.php');
         foreach ($files as $file_id => $file) {
-            $mime_icon = Horde_Mime_Viewer::getIcon($file['file_type']);
+            $mime_icon = $GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getIcon($file['file_type']);
             $title = _("download") . ': ' . $file['file_name'];
             $tooltip = $title . "\n" . sprintf(_("size: %s"), $this->formatSize($file['file_size'])) . "\n" . sprintf(_("type: %s"), $file['file_type']);
             $url = Horde_Util::addParameter($view_url, array('forum_id' => $this->_forum_id,
index b0de3f2..b749242 100644 (file)
@@ -107,7 +107,7 @@ if ($fileList) {
         $realname = $currFile->queryName();
         $mimeType = Horde_Mime_Magic::filenameToMIME($realname);
 
-        $icon = Horde_Mime_Viewer::getIcon($mimeType);
+        $icon = $injector->getInstance('Horde_Mime_Viewer')->getIcon($mimeType);
 
         $author = Chora::showAuthorName($lg->queryAuthor());
         $filerev = $lg->queryRevision();
index ad3d5d4..e4f9d1a 100644 (file)
@@ -1,25 +1,13 @@
 <?php
 /**
- * $Id$
+ * MIME Viewer configuration for Chora.
  *
- * Decide which output drivers you want to activate for the Chora application.
+ * Settings in this file override settings in horde/config/mime_drivers.php.
+ * All drivers configured in that file, but not configured here, will also
+ * be used to display MIME content.
  *
- * The avilable drivers are:
- * -------------------------
- * NO CHORA SPECIFIC DRIVERS
- */
-$mime_drivers_map['chora']['registered'] = array();
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here. Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
+ * $Id$
  */
-$mime_drivers_map['chora']['overrides'] = array();
 
-/**
- * Driver specific settings. See horde/config/mime_drivers.php for
- * the format.
- */
-$mime_drivers['horde']['enscript']['handles'][] = 'text/html';
+/* By default, Chora uses the default Horde-wide settings contained in
+ * horde/config/mime_drivers.php. */
index 2801038..55b0efd 100644 (file)
@@ -243,7 +243,7 @@ class Chora
         $mime->setType($mime_type);
         $mime->setContents($lns);
 
-        return Horde_Mime_Viewer::factory($mime);
+        return $GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getViewer($mime);
     }
 
     /**
diff --git a/framework/Core/lib/Horde/Core/Binder/MimeViewer.php b/framework/Core/lib/Horde/Core/Binder/MimeViewer.php
new file mode 100644 (file)
index 0000000..b87b1b5
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * @category Horde
+ * @package  Core
+ */
+class Horde_Core_Binder_MimeViewer implements Horde_Injector_Binder
+{
+    public function create(Horde_Injector $injector)
+    {
+        return new Horde_Core_Factory_MimeViewer($injector);
+    }
+
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+}
diff --git a/framework/Core/lib/Horde/Core/Factory/MimeViewer.php b/framework/Core/lib/Horde/Core/Factory/MimeViewer.php
new file mode 100644 (file)
index 0000000..61e7b21
--- /dev/null
@@ -0,0 +1,333 @@
+<?php
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+class Horde_Core_Factory_MimeViewer
+{
+    /**
+     * Driver configuration.
+     *
+     * @var array
+     */
+    private $_config = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Attempts to return a concrete Horde_Mime_Viewer object based on the
+     * MIME type.
+     *
+     * @param Horde_Mime_Part $mime  An object with the data to be rendered.
+     * @param array $opts            Additional options:
+     * <pre>
+     * 'app' - (string) The Horde application to search for drivers in.
+     *         DEFAULT: current app
+     * 'type' - (string) The MIME type to use for loading.
+     *          DEFAULT: Uses MIME type in $mime.
+     * </pre>
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created instance.
+     * @throws Horde_Mime_Viewer_Exception
+     */
+    public function getViewer(Horde_Mime_Part $mime, array $opts = array())
+    {
+        $app = isset($opts['app'])
+            ? $opts['app']
+            : $GLOBALS['registry']->getApp();
+
+        $type = isset($opts['type'])
+            ? $opts['type']
+            : $mime->getType();
+
+        list($driver, $params) = $this->getViewerConfig($type, $app);
+
+        return Horde_Mime_Viewer::factory($driver, $mime, $params);
+    }
+
+    /**
+     * Gets the configuration for a MIME type.
+     *
+     * @param string $type  The MIME type.
+     * @param string $app   The current Horde application.
+     *
+     * @return array  The driver and a list of configuration parameters.
+     */
+    public function getViewerConfig($type, $app)
+    {
+        $config = $this->_getDriver($type, $app);
+
+        $config['driver'] = ucfirst($config['driver']);
+        $driver = ($config['app'] == 'horde')
+            ? $config['driver']
+            : $config['app'] . '_Mime_Viewer_' . $config['driver'];
+
+        $params = array_merge($config, array(
+            'charset' => $GLOBALS['registry']->getCharset(),
+            // TODO: Logging
+            // 'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
+            'temp_file' => array('Horde', 'getTempFile'),
+            'text_filter' => array($this->_injector->getInstance('Horde_Text_Filter'), 'filter')
+        ));
+
+        switch ($config['driver']) {
+        case 'Css':
+            if ($config['app'] == 'horde') {
+                $driver = 'Horde_Core_Mime_Viewer_Css';
+            }
+            $params['registry'] = $GLOBALS['registry'];
+            break;
+
+        case 'Deb':
+        case 'Rpm':
+            $params['monospace'] = 'fixed';
+            break;
+
+        case 'Html':
+            $params['browser'] = $GLOBALS['browser'];
+            break;
+
+        case 'Ooo':
+            $params['zip'] = Horde_Compress::factory('Zip');
+            break;
+
+        case 'Rar':
+            $params['monospace'] = 'fixed';
+            $params['rar'] = Horde_Compress::factory('Rar');
+            break;
+
+        case 'Report':
+        case 'Security':
+            $params['viewer_callback'] = array($this, 'getViewerCallback');
+            break;
+
+        case 'Tgz':
+            $params['gzip'] = Horde_Compress::factory('Gzip');
+            $params['monospace'] = 'fixed';
+            $params['tar'] = Horde_Compress::factory('Tar');
+            break;
+
+        case 'Tnef':
+            $params['tnef'] = Horde_Compress::factory('Tnef');
+            break;
+
+        case 'Vcard':
+            if ($config['app'] == 'horde') {
+                $driver = 'Horde_Core_Mime_Viewer_Vcard';
+            }
+            $params['browser'] = $GLOBALS['browser'];
+            $params['notification'] = $GLOBALS['notification'];
+            $params['prefs'] = $GLOBALS['prefs'];
+            $params['registry'] = $GLOBALS['registry'];
+            break;
+
+        case 'Zip':
+            $params['monospace'] = 'fixed';
+            $params['zip'] = Horde_Compress::factory('Zip');
+            break;
+        }
+
+        return array($driver, $params);
+    }
+
+    /**
+     * Callback used to return a MIME Viewer object from within certain
+     * Viewer drivers.
+     *
+     * @param Horde_Mime_Viewer_Base $viewer  The MIME Viewer driver
+     *                                        requesting the new object.
+     * @param Horde_Mime_Part $mime           An object with the data to be
+     *                                        rendered.
+     * @param string $type                    The MIME type to use for
+     *                                        rendering.
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created instance.
+     * @throws Horde_Mime_Viewer_Exception
+     */
+    public function getViewerCallback(Horde_Mime_Viewer_Base $viewer,
+                                      Horde_Mime_Part $mime, $type)
+    {
+        return $this->getViewer($mime, array('type' => $type));
+    }
+
+    /**
+     * Return the appropriate icon for a MIME object/MIME type.
+     *
+     * @param Horde_Mime_Part|string $mime  The MIME object or type to query.
+     * @param array $opts                   Additional options:
+     * <pre>
+     * 'app' - (string) The Horde application to search for drivers in.
+     *         DEFAULT: current app
+     * </pre>
+     *
+     * @return Horde_Themes_Image  An object which contains the URI
+     *                             and filesystem location of the image.
+     */
+    public function getIcon($mime, array $opts = array())
+    {
+        $app = isset($opts['app'])
+            ? $opts['app']
+            : $GLOBALS['registry']->getApp();
+
+        $type = ($mime instanceof Horde_Mime_Part)
+            ? $mime->getType()
+            : $mime;
+
+        $config = $this->_getDriver($type, $app);
+
+        if (!isset($config['icon'])) {
+            $config['icon'] = array(
+                'app' => 'horde',
+                'icon' => 'text.png'
+            );
+        }
+
+        return Horde_Themes::img('mime/' . $config['icon']['icon'], $config['icon']['app']);
+    }
+
+    /**
+     * Create the driver configuration for an application.
+     *
+     * @param string $app  The Horde application to search for drivers in.
+     */
+    private function _loadConfig($app)
+    {
+        if ($app != 'horde') {
+            $this->_loadConfig('horde');
+        }
+
+        /* Make sure app's config is loaded. There is no requirement that
+         * an app have a config, so ignore any errors. */
+        if (isset($this->_config[$app])) {
+            return;
+        }
+
+        try {
+            $aconfig = Horde::loadConfiguration('mime_drivers.php', 'mime_drivers', $app);
+        } catch (Horde_Exception $e) {
+            $aconfig = array();
+        }
+
+        $config = array(
+            'config' => array(),
+            'handles' => array()
+        );
+
+        foreach ($aconfig as $key => $val) {
+            if (empty($val['disable'])) {
+                if (!empty($val['handles'])) {
+                    $config['handles'] = array_merge($config['handles'], array_fill_keys(array_values($val['handles']), $key));
+                    unset($val['handles']);
+                }
+
+                $config['config'][$key] = $val;
+            }
+        }
+
+        /* Make sure there is a default entry. */
+        if (($app == 'horde') && !isset($config['config']['default'])) {
+            $config['config']['default'] = array();
+        }
+
+        $this->_config[$app] = $config;
+    }
+
+    /**
+     * Get the driver config for a MIME type.
+     *
+     * @param string $type  The MIME type query.
+     * @param string $app   The Horde application to search for drivers in.
+     *
+     * @return array  The driver config.
+     */
+    private function _getDriver($type, $app)
+    {
+        $this->_loadConfig($app);
+
+        /* Start with default driver, and then merge in wildcard and exact
+         * match configs. */
+        $config = array();
+        list($ptype,) = explode('/', $type, 2);
+        $wild = $ptype . '/*';
+
+        $app_list = array(
+            array('horde', 'default', 'config'),
+            array($app, 'default', 'config'),
+            array('horde', $wild, 'handles'),
+            array($app, $wild, 'handles'),
+            array('horde', $type, 'handles'),
+            array($app, $type, 'handles')
+        );
+        if ($app == 'horde') {
+            unset($app_list[1], $app_list[3], $app_list[5]);
+        }
+
+        foreach ($app_list as $val) {
+            $driver = isset($this->_config[$val[0]][$val[2]][$val[1]])
+                ? (($val[1] == 'default') ? 'default' : $this->_config[$val[0]][$val[2]][$val[1]])
+                : null;
+
+            if ($driver) {
+                $tmp = $this->_config[$val[0]]['config'][$driver];
+                if (isset($tmp['icons'])) {
+                    foreach (array($type, $wild, 'default') as $val2) {
+                        if (isset($tmp['icons'][$val2])) {
+                            $tmp['icon'] = array(
+                                'app' => $val[0],
+                                'icon' => $tmp['icons'][$val2]
+                            );
+                            break;
+                        }
+                    }
+                    unset($tmp['icons']);
+                }
+
+                $config = array_merge(Horde_Array::array_merge_recursive_overwrite($config, $tmp), array(
+                    'app' => $val[0],
+                    'driver' => $driver
+                ));
+
+            }
+        }
+
+        return $config;
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Mime/Viewer/Css.php b/framework/Core/lib/Horde/Core/Mime/Viewer/Css.php
new file mode 100644 (file)
index 0000000..4cf8850
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * The Horde_Core_Mime_Viewer_Css class extends the base CSS driver by adding
+ * the necessary stylesheets to the full rendered version.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Mime_Viewer_Css extends Horde_Mime_Viewer_Css
+{
+    /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'registry' - (Horde_Registry) Registry object.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'registry'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
+     * Return the full rendered version of the Horde_Mime_Part object.
+     *
+     * @return array  See parent::render().
+     */
+    protected function _render()
+    {
+        $ret = $this->_renderInline();
+
+        // Need Horde headers for CSS tags.
+        if (!empty($ret)) {
+            $templates = $this->getConfigParam('registry')->get('templates', 'horde');
+
+            reset($ret);
+            Horde::startBuffer();
+            require $templates . '/common-header.inc';
+            echo $ret[key($ret)]['data'];
+            require $templates . '/common-footer.inc';
+            $ret[key($ret)]['data'] = Horde::endBuffer();
+        }
+
+        return $ret;
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php b/framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php
new file mode 100644 (file)
index 0000000..4ce4f55
--- /dev/null
@@ -0,0 +1,454 @@
+<?php
+/**
+ * The Horde_Core_Mime_Viewer_Vcard class renders out vCards in HTML format.
+ *
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Jan Schneider <jan@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
+{
+    /**
+     * This driver's display capabilities.
+     *
+     * @var array
+     */
+    protected $_capability = array(
+        'full' => true,
+        'info' => false,
+        'inline' => true,
+        'raw' => false
+    );
+
+    /**
+     * URL that can be used as a callback for displaying images.
+     *
+     * @var Horde_Url
+     */
+    protected $_imageUrl;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'browser' - (Horde_Browser) Browser object.
+     * 'notification' - (Horde_Notification_Base) Notification object.
+     * 'prefs' - (Horde_Prefs) Prefs object.
+     * 'registry' - (Horde_Registry) Registry object.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'browser',
+            'notification',
+            'prefs',
+            'registry'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
+     * Return the full rendered version of the Horde_Mime_Part object.
+     *
+     * @return array  See parent::render().
+     */
+    protected function _render()
+    {
+        $ret = $this->_renderInline();
+
+        if (!empty($ret)) {
+            $templates = $this->getConfigParam('registry')->get('templates', 'horde');
+
+            reset($ret);
+            Horde::startBuffer();
+            include $templates . '/common-header.inc';
+            echo $ret[key($ret)]['data'];
+            include $templates . '/common-footer.inc';
+            $ret[key($ret)]['data'] = Horde::endBuffer();
+        }
+
+        return $ret;
+    }
+
+    /**
+     * Return the rendered inline version of the Horde_Mime_Part object.
+     *
+     * @return array  See parent::render().
+     */
+    protected function _renderInline()
+    {
+        $browser = $this->getConfigParam('browser');
+        $notification = $this->getConfigParam('notification');
+        $prefs = $this->getConfigParam('prefs');
+        $registry = $this->getConfigParam('registry');
+
+        $app = false;
+        $data = $this->_mimepart->getContents();
+        $html = '';
+        $import_msg = null;
+        $title = _("vCard");
+
+        $iCal = new Horde_Icalendar();
+        if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
+            $notification->push(_("There was an error reading the contact data."), 'horde.error');
+        }
+
+        if (Horde_Util::getFormData('import') &&
+            Horde_Util::getFormData('source') &&
+            $registry->hasMethod('contacts/import')) {
+            $source = Horde_Util::getFormData('source');
+            $count = 0;
+            foreach ($iCal->getComponents() as $c) {
+                if ($c->getType() == 'vcard') {
+                    try {
+                        $contacts = $registry->call('contacts/import', array($c, null, $source));
+                        ++$count;
+                    } catch (Horde_Exception $e) {
+                        $notification->push(_("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
+                    }
+                }
+            }
+            $notification->push(sprintf(ngettext(
+                "%d contact was successfully added to your address book.",
+                "%d contacts were successfully added to your address book.",
+                $count),
+                                        $count),
+                                'horde.success');
+        }
+
+        $html .= '<table cellspacing="1" border="0" cellpadding="1">';
+
+        foreach ($iCal->getComponents() as $i => $vc) {
+            if ($i > 0) {
+                $html .= '<tr><td colspan="2">&nbsp;</td></tr>';
+            }
+
+            $html .= '<tr><td colspan="2" class="header">';
+            $fullname = $vc->getAttributeDefault('FN', false);
+            if ($fullname !== false) {
+                $html .= $fullname;
+            }
+            $html .= '</td></tr>';
+
+            $n = $vc->printableName();
+            if (!empty($n)) {
+                $html .= $this->_row(_("Name"), $n);
+            }
+
+            try {
+                $html .= $this->_row(_("Alias"), implode("\n", $vc->getAttributeValues('ALIAS'));
+            } catch (Horde_Icalendar_Exception $e) {}
+
+            try {
+                $birthdays = $vc->getAttributeValues('BDAY');
+                $birthday = new Horde_Date($birthdays[0]);
+                $html .= $this->_row(
+                    _("Birthday"),
+                    $birthday->strftime($prefs->getValue('date_format')));
+            } catch (Horde_Icalendar_Exception $e) {}
+
+            $photos = $vc->getAllAttributes('PHOTO');
+            foreach ($photos as $p => $photo) {
+                if (isset($photo['params']['VALUE']) &&
+                    Horde_String::upper($photo['params']['VALUE']) == 'URI') {
+                    $html .= $this->_row(_("Photo"),
+                                         '<img src="' . htmlspecialchars($photo['value']) . '" />',
+                                         false);
+                } elseif (isset($photo['params']['ENCODING']) &&
+                          Horde_String::upper($photo['params']['ENCODING']) == 'B' &&
+                          isset($photo['params']['TYPE'])) {
+                    if ($browser->hasFeature('datauri') === true ||
+                        $browser->hasFeature('datauri') >= strlen($photo['value'])) {
+                        $html .= $this->_row(_("Photo"),
+                                             '<img src="data:' . htmlspecialchars($photo['params']['TYPE'] . ';base64,' . $photo['value']) . '" />',
+                                             false);
+                    } elseif ($this->_imageUrl) {
+                        $html .= $this->_row(_("Photo"),
+                                             '<img src="' . htmlspecialchars($this->_imageUrl->add(array('c' => $i, 'p' => $p))) . '" />',
+                                             false);
+                    }
+                }
+            }
+
+            $labels = $vc->getAllAttributes('LABEL');
+            foreach ($labels as $label) {
+                if (isset($label['params']['TYPE'])) {
+                    if (!is_array($label['params']['TYPE'])) {
+                        $label['params']['TYPE'] = array($label['params']['TYPE']);
+                    }
+                } else {
+                    $label['params']['TYPE'] = array_keys($label['params']);
+                }
+                $types = array();
+                foreach ($label['params']['TYPE'] as $type) {
+                    switch(Horde_String::upper($type)) {
+                    case 'HOME':
+                        $types[] = _("Home Address");
+                        break;
+
+                    case 'WORK':
+                        $types[] = _("Work Address");
+                        break;
+
+                    case 'DOM':
+                        $types[] = _("Domestic Address");
+                        break;
+
+                    case 'INTL':
+                        $types[] = _("International Address");
+                        break;
+
+                    case 'POSTAL':
+                        $types[] = _("Postal Address");
+                        break;
+
+                    case 'PARCEL':
+                        $types[] = _("Parcel Address");
+                        break;
+
+                    case 'PREF':
+                        $types[] = _("Preferred Address");
+                        break;
+                    }
+                }
+                if (!count($types)) {
+                    $types = array(_("Address"));
+                }
+                $html .= $this->_row(implode('/', $types), $label['value']);
+            }
+
+            $adrs = $vc->getAllAttributes('ADR');
+            foreach ($adrs as $item) {
+                if (isset($item['params']['TYPE'])) {
+                    if (!is_array($item['params']['TYPE'])) {
+                        $item['params']['TYPE'] = array($item['params']['TYPE']);
+                    }
+                } else {
+                    $item['params']['TYPE'] = array_keys($item['params']);
+                }
+
+                $address = $item['values'];
+                $a = array();
+                $a_list = array(
+                    Horde_Icalendar_Vcard::ADR_STREET,
+                    Horde_Icalendar_Vcard::ADR_LOCALITY,
+                    Horde_Icalendar_Vcard::ADR_REGION,
+                    Horde_Icalendar_Vcard::ADR_POSTCODE,
+                    Horde_Icalendar_Vcard::ADR_COUNTRY
+                );
+
+                foreach ($a_list as $val) {
+                    if (isset($address[$val])) {
+                        $a[] = $address[$val];
+                    }
+                }
+
+                $types = array();
+                foreach ($item['params']['TYPE'] as $type) {
+                    switch(Horde_String::upper($type)) {
+                    case 'HOME':
+                        $types[] = _("Home Address");
+                        break;
+
+                    case 'WORK':
+                        $types[] = _("Work Address");
+                        break;
+
+                    case 'DOM':
+                        $types[] = _("Domestic Address");
+                        break;
+
+                    case 'INTL':
+                        $types[] = _("International Address");
+                        break;
+
+                    case 'POSTAL':
+                        $types[] = _("Postal Address");
+                        break;
+
+                    case 'PARCEL':
+                        $types[] = _("Parcel Address");
+                        break;
+
+                    case 'PREF':
+                        $types[] = _("Preferred Address");
+                        break;
+                    }
+                }
+                if (!count($types)) {
+                    $types = array(_("Address"));
+                }
+                $html .= $this->_row(implode('/', $types), implode("\n", $a));
+            }
+
+            $numbers = $vc->getAllAttributes('TEL');
+
+            foreach ($numbers as $number) {
+                if (isset($number['params']['TYPE'])) {
+                    if (!is_array($number['params']['TYPE'])) {
+                        $number['params']['TYPE'] = array($number['params']['TYPE']);
+                    }
+                    foreach ($number['params']['TYPE'] as $type) {
+                        $number['params'][Horde_String::upper($type)] = true;
+                    }
+                }
+                if (isset($number['params']['FAX'])) {
+                    $html .= $this->_row(_("Fax"), $number['value']);
+                } else {
+                    if (isset($number['params']['HOME'])) {
+                        $html .= $this->_row(_("Home Phone"),
+                                             $number['value']);
+                    } elseif (isset($number['params']['WORK'])) {
+                        $html .= $this->_row(_("Work Phone"),
+                                             $number['value']);
+                    } elseif (isset($number['params']['CELL'])) {
+                        $html .= $this->_row(_("Cell Phone"),
+                                             $number['value']);
+                    } else {
+                        $html .= $this->_row(_("Phone"),
+                                             $number['value']);
+                    }
+                }
+            }
+
+            $addresses = $vc->getAllAttributes('EMAIL');
+            $emails = array();
+            foreach ($addresses as $address) {
+                if (isset($address['params']['TYPE'])) {
+                    if (!is_array($address['params']['TYPE'])) {
+                        $address['params']['TYPE'] = array($address['params']['TYPE']);
+                    }
+                    foreach ($address['params']['TYPE'] as $type) {
+                        $address['params'][Horde_String::upper($type)] = true;
+                    }
+                }
+                $email = '<a href="';
+                if ($registry->hasMethod('mail/compose')) {
+                    $email .= $registry->call(
+                        'mail/compose',
+                        array(array('to' => $address['value'])));
+                } else {
+                    $email .= 'mailto:' . htmlspecialchars($address['value']);
+                }
+                $email .= '">' . htmlspecialchars($address['value']) . '</a>';
+                if (isset($address['params']['PREF'])) {
+                    array_unshift($emails, $email);
+                } else {
+                    $emails[] = $email;
+                }
+            }
+
+            if (count($emails)) {
+                $html .= $this->_row(_("Email"), implode("\n", $emails), false);
+            }
+
+            try {
+                $title = $vc->getAttributeValues('TITLE');
+                $html .= $this->_row(_("Title"), $title[0]);
+            } catch (Horde_Icalendar_Exception $e) {}
+
+            try {
+                $role = $vc->getAttributeValues('ROLE');
+                $html .= $this->_row(_("Role"), $role[0]);
+            } catch (Horde_Icalendar_Exception $e) {}
+
+            try {
+                $org = $vc->getAttributeValues('ORG');
+                $html .= $this->_row(_("Company"), $org[0]);
+                if (isset($org[1])) {
+                    $html .= $this->_row(_("Department"), $org[1]);
+                }
+            } catch (Horde_Icalendar_Exception $e) {}
+
+            try {
+                $notes = $vc->getAttributeValues('NOTE');
+                $html .= $this->_row(_("Notes"), $notes[0]);
+            } catch (Horde_Icalendar_Exception $e) {}
+
+            try {
+                $url = $vc->getAttributeValues('URL');
+                $html .= $this->_row(
+                    _("URL"),
+                    '<a href="' . htmlspecialchars($url[0])
+                        . '" target="_blank">' . htmlspecialchars($url[0])
+                        . '</a>',
+                    false);
+            } catch (Horde_Icalendar_Exception $e) {}
+        }
+
+        if ($registry->hasMethod('contacts/import') &&
+            $registry->hasMethod('contacts/sources')) {
+            $html .= '<tr><td colspan="2" class="smallheader"><form action="'
+                . Horde::selfUrl() . '" method="get" name="vcard_import">'
+                . Horde_Util::formInput();
+            foreach ($_GET as $key => $val) {
+                $html .= '<input type="hidden" name="' . htmlspecialchars($key)
+                    . '" value="' . htmlspecialchars($val) . '" />';
+            }
+
+            $sources = $registry->call('contacts/sources', array(true));
+            if (count($sources) > 1) {
+                $html .=
+                    '<input type="submit" class="button" name="import" value="'
+                    . _("Add to address book:") . '" />'
+                    . '<label for="add_source" class="hidden">'
+                    . _("Address Book") . '</label>'
+                    . '<select id="add_source" name="source">';
+                foreach ($sources as $key => $label) {
+                    $selected = ($key == $prefs->getValue('add_source'))
+                        ? ' selected="selected"' : '';
+                    $html .= '<option value="' . htmlspecialchars($key) . '"'
+                        . $selected . '>' . htmlspecialchars($label)
+                        . '</option>';
+                }
+            } else {
+                reset($sources);
+                $html .=
+                    '<input type="submit" class="button" name="import" value="'
+                    . _("Add to my address book") . '" />'
+                    . '<input type="hidden" name="source" value="'
+                    . htmlspecialchars(key($sources)) . '" />';
+            }
+
+            $html .= '</form></td></tr><tr><td>&nbsp;</td></tr>';
+        }
+
+        $html .=  '</table>';
+
+        Horde::startBuffer();
+        $notification->notify(array('listeners' => 'status'));
+
+        return $this->_renderReturn(
+            Horde::endBuffer() . $html,
+            'text/html; charset=' . $this->getConfigParam('charset')
+        );
+    }
+
+    /**
+     * TODO
+     */
+    protected function _row($label, $value, $encode = true)
+    {
+        if ($encode) {
+            $label = htmlspecialchars($label);
+            $value = htmlspecialchars($value);
+        }
+        return '<tr><td class="item" valign="top">' . $label .
+            '</td><td class="item" valign="top">' . nl2br($value) .
+            "</td></tr>\n";
+    }
+
+}
index f8d92d1..3ef8f0a 100644 (file)
@@ -280,6 +280,7 @@ class Horde_Registry
             'Horde_LoginTasks' => new Horde_Core_Binder_LoginTasks(),
             'Horde_Mail' => new Horde_Core_Binder_Mail(),
             'Horde_Memcache' => new Horde_Core_Binder_Memcache(),
+            'Horde_Mime_Viewer' => new Horde_Core_Binder_MimeViewer(),
             'Horde_Notification' => new Horde_Core_Binder_Notification(),
             'Horde_Perms' => new Horde_Core_Binder_Perms(),
             'Horde_Prefs' => new Horde_Core_Binder_Prefs(),
index 0c864b0..c4d43d3 100644 (file)
@@ -116,6 +116,7 @@ Application Framework.</description>
        <file name="LoginTasks.php" role="php" />
        <file name="Mail.php" role="php" />
        <file name="Memcache.php" role="php" />
+       <file name="MimeViewer.php" role="php" />
        <file name="Notification.php" role="php" />
        <file name="Perms.php" role="php" />
        <file name="Prefs.php" role="php" />
@@ -151,6 +152,7 @@ Application Framework.</description>
        <file name="KolabStorage.php" role="php" />
        <file name="Ldap.php" role="php" />
        <file name="LoginTasks.php" role="php" />
+       <file name="MimeViewer.php" role="php" />
        <file name="Prefs.php" role="php" />
        <file name="Request.php" role="php" />
        <file name="Share.php" role="php" />
@@ -166,6 +168,12 @@ Application Framework.</description>
         <file name="Horde.php" role="php" />
        </dir> <!-- /lib/Horde/Core/LoginTasks/Backend -->
       </dir> <!-- /lib/Horde/Core/LoginTasks -->
+      <dir name="Mime">
+       <dir name="Viewer">
+        <file name="Css.php" role="php" />
+        <file name="Vcard.php" role="php" />
+       </dir> <!-- /lib/Horde/Core/Mime/Viewer -->
+      </dir> <!-- /lib/Horde/Core/Mime -->
       <dir name="Notification">
        <file name="Hordelog.php" role="php" />
        <file name="Status.php" role="php" />
@@ -289,6 +297,10 @@ Application Framework.</description>
     <channel>pear.horde.org</channel>
    </package>
    <package>
+    <name>Mime</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Prefs</name>
     <channel>pear.horde.org</channel>
    </package>
@@ -331,6 +343,10 @@ Application Framework.</description>
     <channel>pear.horde.org</channel>
    </package>
    <package>
+    <name>Icalendar</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Kolab_Server</name>
     <channel>pear.horde.org</channel>
    </package>
@@ -403,6 +419,7 @@ Application Framework.</description>
    <install as="Horde/Core/Binder/LoginTasks.php" name="lib/Horde/Core/Binder/LoginTasks.php" />
    <install as="Horde/Core/Binder/Mail.php" name="lib/Horde/Core/Binder/Mail.php" />
    <install as="Horde/Core/Binder/Memcache.php" name="lib/Horde/Core/Binder/Memcache.php" />
+   <install as="Horde/Core/Binder/MimeViewer.php" name="lib/Horde/Core/Binder/MimeViewer.php" />
    <install as="Horde/Core/Binder/Notification.php" name="lib/Horde/Core/Binder/Notification.php" />
    <install as="Horde/Core/Binder/Perms.php" name="lib/Horde/Core/Binder/Perms.php" />
    <install as="Horde/Core/Binder/Prefs.php" name="lib/Horde/Core/Binder/Prefs.php" />
@@ -434,6 +451,7 @@ Application Framework.</description>
    <install as="Horde/Core/Factory/KolabStorage.php" name="lib/Horde/Core/Factory/KolabStorage.php" />
    <install as="Horde/Core/Factory/Ldap.php" name="lib/Horde/Core/Factory/Ldap.php" />
    <install as="Horde/Core/Factory/LoginTasks.php" name="lib/Horde/Core/Factory/LoginTasks.php" />
+   <install as="Horde/Core/Factory/MimeViewer.php" name="lib/Horde/Core/Factory/MimeViewer.php" />
    <install as="Horde/Core/Factory/Prefs.php" name="lib/Horde/Core/Factory/Prefs.php" />
    <install as="Horde/Core/Factory/Request.php" name="lib/Horde/Core/Factory/Request.php" />
    <install as="Horde/Core/Factory/Share.php" name="lib/Horde/Core/Factory/Share.php" />
@@ -442,6 +460,8 @@ Application Framework.</description>
    <install as="Horde/Core/Factory/Vfs.php" name="lib/Horde/Core/Factory/Vfs.php" />
    <install as="Horde/Core/Log/Logger.php" name="lib/Horde/Core/Log/Logger.php" />
    <install as="Horde/Core/LoginTasks/Backend/Horde.php" name="lib/Horde/Core/LoginTasks/Backend/Horde.php" />
+   <install as="Horde/Core/Mime/Viewer/Css.php" name="lib/Horde/Core/Mime/Viewer/Css.php" />
+   <install as="Horde/Core/Mime/Viewer/Vcard.php" name="lib/Horde/Core/Mime/Viewer/Vcard.php" />
    <install as="Horde/Core/Notification/Hordelog.php" name="lib/Horde/Core/Notification/Hordelog.php" />
    <install as="Horde/Core/Notification/Status.php" name="lib/Horde/Core/Notification/Status.php" />
    <install as="Horde/Core/Perms/Ui.php" name="lib/Horde/Core/Perms/Ui.php" />
index cf6323f..fe26afa 100644 (file)
 class Horde_Mime_Viewer
 {
     /**
-     * The config array. This array is shared between all instances of
-     * Horde_Mime_Viewer.
-     *
-     * @var array
-     */
-    static protected $_config = array();
-
-    /**
-     * The driver cache array. This array is shared between all instances of
-     * Horde_Mime_Viewer.
-     *
-     * @var array
-     */
-    static protected $_drivercache = array();
-
-    /**
-     * Attempts to return a concrete Horde_Mime_Viewer_* object based on the
-     * MIME type.
-     *
-     * @param Horde_Mime_Part $mime_part  An object with the information to be
-     *                                    rendered.
-     * @param string $mime_type           The MIME type (overrides the value
-     *                                    in the MIME part).
-     *
-     * @return Horde_Mime_Viewer  The Horde_Mime_Viewer object, or false on
-     *                            error.
-     */
-    static final public function factory($mime_part, $mime_type = null)
-    {
-        if (is_null($mime_type)) {
-            $mime_type = $mime_part->getType();
-        }
-
-        /* Spawn the relevant driver, and return it (or false on failure). */
-        if (($ob = self::_getDriver($mime_type, $GLOBALS['registry']->getApp())) &&
-            self::_resolveDriver($ob['driver'], $ob['app']) &&
-            class_exists($ob['class'])) {
-            $conf = array_merge(self::$_config['mime_drivers'][$ob['app']][$ob['driver']], array('_driver' => $ob['driver']));
-            return new $ob['class']($mime_part, $conf);
-        }
-
-        return false;
-    }
-
-    /**
-     * Given a MIME type, this function will return an appropriate icon.
-     *
-     * @param string $mime_type  The MIME type that we need an icon for.
-     *
-     * @return string  The URL to the appropriate icon.
+     * Attempts to return a concrete Horde_Mime_Viewer_Base instance based on
+     * $driver.
+     *
+     * @param string $driver         Either a driver name, or the full class
+     *                               name to use (class must extend
+     *                               Horde_Mime_Viewer_Base).
+     * @param Horde_Mime_Part $part  The MIME part object to display.
+     * @param array $params          A hash containing any additional
+     *                               configuration or parameters a subclass
+     *                               might need.
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created concrete instance.
+     * @throws Horde_Mime_Viewer_Exception
      */
-    static final public function getIcon($mime_type)
+    static public function factory($driver, $part, array $params = array())
     {
-        $app = $GLOBALS['registry']->getApp();
-        $ob = self::_getIcon($mime_type, $app);
-
-        if (is_null($ob)) {
-            if ($app == 'horde') {
-                return null;
-            }
-
-            $obHorde = self::_getIcon($mime_type, 'horde');
-            return is_null($obHorde) ? null : $obHorde['url'];
-        } elseif (($ob['match'] !== 0) && ($app != 'horde')) {
-            $obHorde = self::_getIcon($mime_type, 'horde');
-            if (!is_null($ob['match']) &&
-                ($obHorde['match'] < $ob['match'])) {
-                return $obHorde['url'];
-            }
-        }
-
-        return $ob['url'];
-    }
-
-    /**
-     * Given a MIME type and an app name, determine which driver can best
-     * handle the data.
-     *
-     * @param string $mime_type  MIME type to resolve.
-     * @param string $app        App in which to search for the driver.
-     *
-     * @return mixed  Returns false if driver could not be found. Otherwise,
-     *                an array with the following elements:
-     * <pre>
-     * 'app' - (string) The app containing the driver (e.g. 'horde')
-     * 'driver' - (string) Name of driver (e.g. 'enscript')
-     * 'exact' - (boolean) Was the driver and exact match?
-     * </pre>
-     */
-    static final protected function _getDriver($mime_type, $app = 'horde')
-    {
-        $sig = $mime_type . '|' . $app;
-        if (isset(self::$_drivercache[$sig])) {
-            return self::$_drivercache[$sig];
-        }
-
-        /* Make sure horde config is loaded. */
-        if (empty(self::$_config['mime_drivers']['horde'])) {
-            try {
-                self::$_config = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde');
-            } catch (Horde_Exception $e) {
-                return false;
-            }
-        }
-
-        /* Make sure app's config is loaded. There is no requirement that
-         * an app have a separate config, so ignore any errors. */
-        if (($app != 'horde') && empty(self::$_config['mime_drivers'][$app])) {
-            try {
-                self::$_config = Horde_Array::array_merge_recursive_overwrite(self::$_config, Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), $app));
-            } catch (Horde_Exception $e) {}
-        }
-
-        $driver = '';
-        $exact = false;
-
-        list($primary_type,) = explode('/', $mime_type, 2);
-        $allSub = $primary_type . '/*';
-
-        /* If the app doesn't exist in $mime_drivers_map, check for Horde-wide
-         * viewers. */
-        if (!isset(self::$_config['mime_drivers_map'][$app]) &&
-            ($app != 'horde')) {
-            return self::_getDriver($mime_type, 'horde');
-        }
-
-        $dr = isset(self::$_config['mime_drivers'][$app]) ? self::$_config['mime_drivers'][$app] : array();
-        $map = self::$_config['mime_drivers_map'][$app];
-
-        /* If an override exists for this MIME type, then use that */
-        if (isset($map['overrides'][$mime_type])) {
-            $driver = $map['overrides'][$mime_type];
-            $exact = true;
-        } elseif (isset($map['overrides'][$allSub])) {
-            $driver = $map['overrides'][$allSub];
-            $exact = true;
-        } elseif (isset($map['registered'])) {
-            /* Iterate through the list of registered drivers, and see if
-             * this MIME type exists in the MIME types that they claim to
-             * handle. If the driver handles it, then assign it as the
-             * rendering driver. If we find a generic handler, keep iterating
-             * to see if we can find a specific handler. */
-            foreach ($map['registered'] as $val) {
-                if (in_array($mime_type, $dr[$val]['handles'])) {
-                    $driver = $val;
-                    $exact = true;
-                    break;
-                } elseif (in_array($allSub, $dr[$val]['handles'])) {
-                    $driver = $val;
-                }
-            }
-        }
-
-        /* If this is an application specific app, and an exact match was
-           not found, search for a Horde-wide specific driver. Only use the
-           Horde-specific driver if it is NOT the 'default' driver AND the
-           Horde driver is an exact match. */
-        if (!$exact && ($app != 'horde')) {
-            $ob = self::_getDriver($mime_type, 'horde');
-            if (empty($driver) ||
-                (($ob['driver'] != 'default') && $ob['exact'])) {
-                $driver = $ob['driver'];
-                $app = 'horde';
-            }
-        }
-
-        /* If the 'default' driver exists in this app, fall back to that. */
-        if (empty($driver) && self::_resolveDriver('default', $app)) {
-            $driver = 'default';
-        }
-
-        if (empty($driver)) {
-            return false;
-        }
-
-        self::$_drivercache[$sig] = array(
-            'app' => $app,
-            'class' => (($app == 'horde') ? '' : $app . '_') . 'Horde_Mime_Viewer_' . $driver,
-            'driver' => $driver,
-            'exact' => $exact,
-        );
-
-        return self::$_drivercache[$sig];
-    }
-
-    /**
-     * Given a driver and an application, attempts to load the library file.
-     *
-     * @param string $driver  Driver name.
-     * @param string $app     Application name.
-     *
-     * @return boolean  True if library file was loaded.
-     */
-    static final protected function _resolveDriver($driver = 'default',
-                                                   $app = 'horde')
-    {
-        $driver = ucfirst($driver);
-
-        $file = ($app == 'horde')
-            ? dirname(__FILE__) . '/Viewer/' . $driver . '.php'
-            : $GLOBALS['registry']->applications[$app]['fileroot'] . '/lib/Mime/Viewer/' . $driver . '.php';
-
-        return require_once $file;
-    }
-
-    /**
-     * Given an input MIME type and app, this function returns the URL of an
-     * icon that can be associated with it
-     *
-     * @param string $mime_type  MIME type to get the icon for.
-     *
-     * @return mixed  Null if not found, or an array with the following keys:
-     * <pre>
-     * 'exact' - (integer) How exact the match is. Null if no match.
-     *           0 - 'exact'
-     *           1 - 'primary'
-     *           2 - 'driver',
-     *           3 - 'default'
-     * 'url' - (string) URL to an icon, or null if none could be found.
-     * </pre>
-     */
-    static final protected function _getIcon($mime_type, $app = 'horde')
-    {
-        if (!($ob = self::_getDriver($mime_type, $app))) {
-            return null;
-        }
-        $driver = $ob['driver'];
-
-        list($primary_type,) = explode('/', $mime_type, 2);
-        $allSub = $primary_type . '/*';
-        $ret = null;
-
-        /* If the app doesn't exist in $mime_drivers, return now. */
-        if (!isset(self::$_config['mime_drivers'][$app])) {
-            return null;
-        }
-
-        $dr = self::$_config['mime_drivers'][$app];
-
-        /* If a specific icon for this driver and mimetype is defined,
-           then use that. */
-        if (isset($dr[$driver]['icons'])) {
-            $icondr = $dr[$driver]['icons'];
-            $iconList = array($mime_type => 0, $allSub => 1, 'default' => 2);
-            foreach ($iconList as $key => $val) {
-                if (isset($icondr[$key])) {
-                    $ret = array('match' => $val, 'url' => $icondr[$key]);
-                    break;
-                }
-            }
-        }
+        $params['_driver'] = $driver;
 
-        /* Try to use a default icon if none already obtained. */
-        if (is_null($ret['url']) &&
-            isset($dr['default']['icons']['default'])) {
-            $ret = array('match' => 3, 'url' => $dr['default']['icons']['default']);
+        /* Base drivers (in Viewer/ directory). */
+        $class = __CLASS__ . '_' . $driver;
+        if (class_exists($class)) {
+            return new $class($part, $params);
         }
 
-        if (!is_null($ret)) {
-            $ret['url'] = Horde_Themes::img('mime/' . $ret['url'], $app);
+        /* Explicit class name, */
+        $class = $driver;
+        if (class_exists($class)) {
+            return new $class($part, $params);
         }
 
-        return $ret;
+        throw new Horde_Mime_Viewer_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
     }
 
 }
index 6b540c5..92641a9 100644 (file)
@@ -30,11 +30,13 @@ class Horde_Mime_Viewer_Base
     protected $_mimepart = null;
 
     /**
-     * Viewer parameters.
+     * Required configuration parameters.
      *
      * @var array
      */
-    protected $_params = array();
+    protected $_required = array(
+        'charset'
+    );
 
     /**
      * This driver's display capabilities.
@@ -67,13 +69,28 @@ class Horde_Mime_Viewer_Base
      *
      * @param Horde_Mime_Part $mime_part  The object with the data to be
      *                                    rendered.
-     * @param array $conf                 Configuration specific to the
-     *                                    driver.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'charset' - (string) The local UI charset. [REQUIRED]
+     * 'temp_file' - (callback) A callback function that returns a temporary
+     *               filename.  Is passed one parameter: a prefix string.
+     *                DEFAULT: Uses Horde_Util::getTempFile().
+     * 'text_filter' - (callback) A callback function used to filter text.
+     *                 Is called the same as Horde_Text_Filter::filter().
+     *                 DEFAULT: Uses Horde_Text_Filter::filter().
+     * </pre>
+     *
+     * @throws InvalidArgumentException
      */
-    public function __construct(Horde_Mime_Part $mime_part,
-                                array $conf = array())
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
     {
-        $this->_mimepart = $mime_part;
+        foreach ($this->_required as $val) {
+            if (!isset($conf[$val])) {
+                throw new InvalidArgumentException(__CLASS__ . ': Missing configuration value (' . $val . ')');
+            }
+        }
+
+        $this->_mimepart = $part;
         $this->_conf = $conf;
     }
 
@@ -89,17 +106,6 @@ class Horde_Mime_Viewer_Base
     }
 
     /**
-     * Set parameters for use with this object.
-     *
-     * @param array $params  An array of params to add to the internal
-     *                       params list.
-     */
-    public function setParams(array $params = array())
-    {
-        $this->_params = array_merge($this->_params, $params);
-    }
-
-    /**
      * Return the rendered version of the Horde_Mime_Part object.
      *
      * @param string $mode  The mode:
@@ -313,7 +319,20 @@ class Horde_Mime_Viewer_Base
      */
     public function getConfigParam($param)
     {
-        return isset($this->_conf[$param]) ? $this->_conf[$param] : null;
+        return isset($this->_conf[$param])
+            ? $this->_conf[$param]
+            : null;
+    }
+
+    /**
+     * Sets a configuration parameter for the current viewer.
+     *
+     * @param string $param  The parameter name.
+     * @param mixed $value   The parameter value.
+     */
+    public function setConfigParam($param, $value)
+    {
+        $this->_conf[$param] = $value;
     }
 
     /**
@@ -323,7 +342,7 @@ class Horde_Mime_Viewer_Base
      */
     public function getDriver()
     {
-        return $this->_conf['_driver'];
+        return $this->getConfigParam('_driver');
     }
 
     /**
@@ -391,4 +410,32 @@ class Horde_Mime_Viewer_Base
         return $data;
     }
 
+    /**
+     * Returns a temporary file name.
+     *
+     * @return string  A temp filename.
+     */
+    protected function _getTempFile()
+    {
+        return ($temp_file = $this->getConfigParam('temp_file'))
+            ? call_user_func($temp_file, __CLASS__)
+            : Horde_Util::getTempFile(__CLASS__);
+    }
+
+    /**
+     * Filter text.
+     *
+     * @param string $text    TODO
+     * @param mixed  $driver  TODO
+     * @param array  $params  TODO
+     *
+     * @return string  The filtered text.
+     */
+    protected function _textFilter($text, $driver, array $params = array())
+    {
+        return ($text_filter = $this->getConfigParam('text_filter'))
+            ? call_user_func($text_filter, $text, $driver, $params)
+            : Horde_Text_Filter::filter($text, $driver, $params);
+    }
+
 }
index 87754c7..e58c5ff 100644 (file)
@@ -70,17 +70,7 @@ class Horde_Mime_Viewer_Css extends Horde_Mime_Viewer_Source
      */
     protected function _render()
     {
-        $ret = $this->_renderInline();
-
-        // Need Horde headers for CSS tags.
-        reset($ret);
-        Horde::startBuffer();
-        require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
-        echo $ret[key($ret)]['data'];
-        require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
-        $ret[key($ret)]['data'] = Horde::endBuffer();
-
-        return $ret;
+        return $this->_renderFullReturn($this->_renderInline());
     }
 
     /**
index 00b2b1c..154d086 100644 (file)
@@ -39,6 +39,29 @@ class Horde_Mime_Viewer_Deb extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the dpkg binary [REQUIRED].
+     * 'monospace' - (string) A class to use to display monospace text inline.
+     *               DEFAULT: Uses style="font-family:monospace"
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -56,25 +79,28 @@ class Horde_Mime_Viewer_Deb extends Horde_Mime_Viewer_Base
     protected function _renderInfo()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
         $data = '';
 
-        $tmpin = Horde::getTempFile('horde_deb');
         file_put_contents($tmp_deb, $this->_mimepart->getContents());
 
-        $fh = popen($this->_conf['location'] . " -f $tmpin 2>&1", 'r');
+        $fh = popen($location . ' -f ' . $this->_getTempFile() . ' 2>&1', 'r');
         while ($rc = fgets($fh, 8192)) {
             $data .= $rc;
         }
         pclose($fh);
 
+        $monospace = $this->getConfigParam('monospace');
+
         return $this->_renderReturn(
-            '<pre>' . htmlspecialchars($data) . '</pre>',
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            '<span ' .
+            ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
+            htmlspecialchars($data) . '</span>',
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index e6f137f..954dded 100644 (file)
@@ -60,8 +60,8 @@ class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Base
     protected function _renderInline()
     {
         return $this->_renderReturn(
-            Horde_String::convertCharset($this->_toHTML(true), $this->_mimepart->getCharset()),
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            Horde_String::convertCharset($this->_toHTML(true), $this->_mimepart->getCharset(), $this->getConfigParam('charset')),
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
@@ -168,9 +168,7 @@ class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Base
         $text = preg_replace('/^ (.*) $/s', '\1', $text);
 
         // Make URLs clickable.
-        $text = Horde_Text_Filter::filter($text, 'linkurls', array(
-            'callback' => 'Horde::externalUrl'
-        ));
+        $text = $this->_textFilter($text, 'linkurls');
 
         /* Wordwrap -- note this could impact on our above RFC compliance *IF*
          * we honored nofill tags (which we don't yet). */
index 157a868..6bf1b1e 100644 (file)
@@ -51,6 +51,27 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Base
     protected $_tmp = array();
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'browser' - (Horde_Browser) A browser object.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'browser'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -76,9 +97,9 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Base
 
         return array(
             $this->_mimepart->getMimeId() => array(
-                'data' => Horde_String::convertCharset($html['data'], $this->_mimepart->getCharset()),
+                'data' => Horde_String::convertCharset($html['data'], $this->_mimepart->getCharset(), $this->getConfigParam('charset')),
                 'status' => $html['status'],
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
@@ -108,17 +129,17 @@ class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Base
      */
     protected function _cleanHTML($data, $options = array())
     {
-        global $browser;
-
+        $browser = $this->getConfigParam('browser');
         $charset = isset($options['charset'])
             ? $options['charset']
             : $this->_mimepart->getCharset();
-        $strip_style_attributes = (!empty($options['inline']) &&
-                                   (($browser->isBrowser('mozilla') &&
-                                    ($browser->getMajor() == 4)) ||
-                                    $browser->isBrowser('msie')));
+        $strip_style_attributes =
+            (!empty($options['inline']) &&
+             (($browser->isBrowser('mozilla') &&
+              ($browser->getMajor() == 4)) ||
+              $browser->isBrowser('msie')));
 
-        $data = Horde_Text_Filter::filter($data, array('cleanhtml', 'xss'), array(
+        $data = $this->_textFilter($data, array('cleanhtml', 'xss'), array(
             array(
                 'charset' => $charset
             ),
index 6f67663..505c672 100644 (file)
@@ -29,14 +29,13 @@ class Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Base
     /**
      * Constructor.
      *
-     * @param Horde_Mime_Part $mime_part  Reference to an object with the
-     *                                    information to be rendered.
-     * @param array $conf                 Configuration specific to the
-     *                                    driver.
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration.
      */
-    public function __construct($mime_part, $conf = array())
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
     {
-        parent::__construct($mime_part, $conf);
+        parent::__construct($part, $conf);
 
         /* TODO: Are there other image types that are compressed? */
         $this->_metadata['compressed'] = in_array($this->_getType(), array('image/gif', 'image/jpeg', 'image/png'));
index c51be43..7bc225f 100644 (file)
@@ -29,6 +29,27 @@ class Horde_Mime_Viewer_Msexcel extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the gnumeric binary.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -36,22 +57,21 @@ class Horde_Mime_Viewer_Msexcel extends Horde_Mime_Viewer_Base
     protected function _render()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
-        $tmp_in = Horde::getTempFile('horde_msexcel');
-        $tmp_out = Horde::getTempFile('horde_msexcel');
+        $tmp_in = $this->_getTempFile();
+        $tmp_out = $this->_getTempFile();
 
         file_put_contents($tmp_in, $this->_mimepart->getContents());
-        $args = ' -E Gnumeric_Excel:excel_dsf -T Gnumeric_html:html40 ' . $tmp_in . ' ' . $tmp_out;
 
-        exec($this->_conf['location'] . $args);
+        exec($location . ' -E Gnumeric_Excel:excel_dsf -T Gnumeric_html:html40 ' . $tmp_in . ' ' . $tmp_out);
 
         return $this->_renderReturn(
             file_get_contents($tmp_out),
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 4245355..336f95f 100644 (file)
@@ -28,6 +28,27 @@ class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the ppthtml binary.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -35,17 +56,17 @@ class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Base
     protected function _render()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
         $data = '';
 
-        $tmp_ppt = Horde::getTempFile('horde_mspowerpoint');
+        $tmp_ppt = $this->_getTempFile();
         file_put_contents($tmp_ppt, $this->_mimepart->getContents());
 
-        $fh = popen($this->_conf['location'] . " $tmp_ppt 2>&1", 'r');
+        $fh = popen($location . ' ' . $tmp_ppt . ' 2>&1', 'r');
         while (($rc = fgets($fh, 8192))) {
             $data .= $rc;
         }
@@ -53,7 +74,7 @@ class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $data,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index c28287d..d082548 100644 (file)
@@ -29,6 +29,27 @@ class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the abiword binary.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -36,21 +57,20 @@ class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Base
     protected function _render()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
-        $tmp_in = Horde::getTempFile('msword');
-        $tmp_out = Horde::getTempFile('msword');
+        $tmp_in = $this->_getTempFile();
+        $tmp_out = $this->_getTempFile();
 
         file_put_contents($tmp_in, $this->_mimepart->getContents());
-        $args = ' --to=html --to-name=' . $tmp_out . ' ' . $tmp_in;
 
-        exec($this->_conf['location'] . $args);
+        exec($location . ' --to=html --to-name=' . $tmp_out . ' ' . $tmp_in);
 
-        if (file_exists($tmp_output)) {
-            $data = file_get_contents($tmp_output);
+        if (file_exists($tmp_out)) {
+            $data = file_get_contents($tmp_out);
             $type = 'text/html';
         } else {
             $data = _("Unable to translate this Word document");
@@ -59,7 +79,7 @@ class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $data,
-            $type . '; charset=' . $GLOBALS['registry']->getCharset()
+            $type . '; charset=' . $this->getConfigParam('charset')
         );
     }
 
index ea7a42c..99d6563 100644 (file)
@@ -42,6 +42,21 @@ class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'zip' - (Horde_Compress_Zip) A zip object.
+     * </pre>
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -64,8 +79,10 @@ class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Base
             'table:number-columns-spanned=' => 'colspan='
         );
 
-        $zip = Horde_Compress::factory('zip');
-        $list = $zip->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_LIST));
+        if (!$this->getConfigParam('zip')) {
+            $this->setConfigParam('zip', Horde_Compress::factory('Zip'));
+        }
+        $list = $this->getConfigParam('zip')->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_LIST));
 
         foreach ($list as $key => $file) {
             if (in_array($file['name'], $fnames)) {
@@ -102,8 +119,8 @@ class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Base
             $result = @$xslt->process($dom, array(
                 'metaFileURL' => $tmpdir . 'meta.xml',
                 'stylesFileURL' => $tmpdir . 'styles.xml',
-                'disableJava' => true)
-            );
+                'disableJava' => true
+            ));
             $result = $xslt->result_dump_mem($result);
         } else {
             // Use XSLT
@@ -111,8 +128,8 @@ class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Base
             $result = @xslt_process($xslt, $tmpdir . 'content.xml', $xsl_file, null, null, array(
                 'metaFileURL' => $tmpdir . 'meta.xml',
                 'stylesFileURL' => $tmpdir . 'styles.xml',
-                'disableJava' => true)
-            );
+                'disableJava' => true
+            ));
             if (!$result) {
                 $result = xslt_error($xslt);
             }
@@ -127,4 +144,5 @@ class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Base
             )
         );
     }
+
 }
index 636bf2d..722ee2c 100644 (file)
@@ -52,7 +52,7 @@ class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source
 
         return $this->_renderReturn(
             $this->_lineNumber(trim(str_replace(array("\n", '<br />'), array('', "\n"), $text))),
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 9d25aa2..4dca5d3 100644 (file)
@@ -43,7 +43,7 @@ class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Base
             $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'));
         }
 
-        $text = '<html><body><tt>' . Horde_Text_Filter::filter($text, 'text2html', array(
+        $text = '<html><body><tt>' . $this->_textFilter($text, 'Text2html', array(
             'charset' => $charset,
             'parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL
         )) . '</tt></body></html>';
@@ -61,7 +61,7 @@ class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Base
      */
     protected function _renderInline()
     {
-        $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset());
+        $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset(), $this->getConfigParam('charset'));
 
         /* Check for 'flowed' text data. */
         $data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed')
@@ -70,7 +70,7 @@ class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $data,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 2ef0d23..2e84aff 100644 (file)
@@ -39,6 +39,23 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Base
         'forceinline' => false
     );
 
+   /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'monospace' - (string) A class to use to display monospace text inline.
+     *               DEFAULT: Uses style="font-family:monospace"
+     * 'rar' - (Horde_Compress_Rar) A zip object.
+     * </pre>
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        parent::__construct($part, $conf);
+    }
+
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
@@ -57,12 +74,13 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Base
      */
     protected function _renderInfo()
     {
+        $charset = $this->getConfigParam('charset');
         $contents = $this->_mimepart->getContents();
 
-        $rar = Horde_Compress::factory('rar');
-        $rarData = $rar->decompress($contents);
-
-        $charset = $GLOBALS['registry']->getCharset();
+        if (!$this->getConfigParam('rar')) {
+            $this->setConfigParam('rar', Horde_Compress::factory('rar'));
+        }
+        $rarData = $this->getConfigParam('rar')->decompress($contents);
         $fileCount = count($rarData);
 
         $name = $this->_mimepart->getName(true);
@@ -70,13 +88,30 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Base
             $name = _("unnamed");
         }
 
-        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
-            '<table><tr><td align="left"><pre>' .
-            Horde_Text_Filter::filter(_("Archive Name") . ':  ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
-            Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
-            Horde_Text_Filter::filter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) .
+        $monospace = $this->getConfigParam('monospace');
+
+        $text = '<strong>' .
+            htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) .
+            ":</strong>\n" .
+            '<table><tr><td align="left"><span ' .
+            ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
+            $this->_textFilter(_("Archive Name") . ':  ' . $name, 'space2html', array(
+                'charset' => $charset,
+                'encode' => true,
+                'encode_all' => true
+            )) . "\n" .
+            $this->_textFilter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array(
+                'charset' => $charset,
+                'encode' => true,
+                'encode_all' => true
+            )) . "\n" .
+            $this->_textFilter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array(
+                'charset' => $charset,
+                'encode' => true,
+                'encode_all' => true
+            )) .
             "\n\n" .
-            Horde_Text_Filter::filter(
+            $this->_textFilter(
                 Horde_String::pad(_("File Name"), 50, ' ', STR_PAD_RIGHT) .
                 Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
                 Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
@@ -84,15 +119,19 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Base
                 Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
                 Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT),
                 'space2html',
-                array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
-            str_repeat('-', 109) . "\n";
+                array(
+                    'charset' => $charset,
+                    'encode' => true,
+                    'encode_all' => true
+                )
+            ) . "\n" . str_repeat('-', 109) . "\n";
 
         foreach ($rarData as $val) {
             $ratio = empty($val['size'])
                 ? 0
                 : 100 * ($val['csize'] / $val['size']);
 
-            $text .= Horde_Text_Filter::filter(
+            $text .= $this->_textFilter(
                 Horde_String::pad($val['name'], 50, ' ', STR_PAD_RIGHT) .
                 Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT) .
                 Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT) .
@@ -100,12 +139,15 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Base
                 Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT) .
                 Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT),
                 'space2html',
-                array('encode' => true, 'encode_all' => true)
+                array(
+                    'encode' => true,
+                    'encode_all' => true
+                )
             ) . "\n";
         }
 
         return $this->_renderReturn(
-            nl2br($text . str_repeat('-', 106) . "\n</pre></td></tr></table>"),
+            nl2br($text . str_repeat('-', 106) . "\n</span></td></tr></table>"),
             'text/html; charset=' . $charset
         );
     }
index 6581675..7fc1ead 100644 (file)
 class Horde_Mime_Viewer_Report extends Horde_Mime_Viewer_Base
 {
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'viewer_callback' - (callback) A callback to a factory that will
+     *                     return the appropriate viewer for the embedded
+     *                     MIME type. Is passed three parameters: the
+     *                     current driver object, the MIME part object, and
+     *                     the MIME type to use.
+     * </pre>
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the underlying MIME Viewer for this part.
      *
      * @return mixed  A Horde_Mime_Viewer object, or false if not found.
      */
     protected function _getViewer()
     {
+        if (!($callback = $this->getConfigParam('viewer_callback'))) {
+            return false;
+        }
+
         if (!($type = $this->_mimepart->getContentTypeParameter('report-type'))) {
             /* This is a broken RFC 3462 message, since 'report-type' is
              * mandatory. Try to determine the report-type by looking at the
@@ -33,12 +56,7 @@ class Horde_Mime_Viewer_Report extends Horde_Mime_Viewer_Base
             $type = $parts[1]->getSubType();
         }
 
-        $viewer = Horde_Mime_Viewer::factory($this->_mimepart, 'message/' . Horde_String::lower($type));
-        if ($viewer) {
-            $viewer->setParams($this->_params);
-        }
-
-        return $viewer;
+        return call_user_func($callback, $this, $this->_mimepart, 'message/' . Horde_String::lower($type));
     }
 
 }
index 1d53c39..dd67031 100644 (file)
@@ -36,7 +36,7 @@ class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Base
     {
         return $this->_renderReturn(
             null,
-            'text/plain; charset=' . $GLOBALS['registry']->getCharset()
+            'text/plain; charset=' . $this->getConfigParam('charset')
         );
     }
 
@@ -81,8 +81,8 @@ class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Base
         }
 
         return $this->_renderReturn(
-            (empty($header_output) ? '' : ('<div class="fixed mimeHeaders">' . Horde_Text_Filter::filter(implode("<br />\n", $header_output), 'emails') . '</div>')),
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            (empty($header_output) ? '' : ('<div class="fixed mimeHeaders">' . $this->_textFilter(implode("<br />\n", $header_output), 'emails') . '</div>')),
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 628649c..d2122d9 100644 (file)
@@ -70,8 +70,8 @@ class Horde_Mime_Viewer_Richtext extends Horde_Mime_Viewer_Base
     protected function _renderInline()
     {
         return $this->_renderReturn(
-            Horde_String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()),
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            Horde_String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset(), $this->getConfigParam('charset')),
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 4abd20c..3427ada 100644 (file)
@@ -38,6 +38,29 @@ class Horde_Mime_Viewer_Rpm extends Horde_Mime_Viewer_Base
         'forceinline' => false
     );
 
+   /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) The location of the rpm binary [REQUIRED].
+     * 'monospace' - (string) A class to use to display monospace text inline.
+     *               DEFAULT: Uses style="font-family:monospace"
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
@@ -56,25 +79,29 @@ class Horde_Mime_Viewer_Rpm extends Horde_Mime_Viewer_Base
     protected function _renderInfo()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
         $data = '';
 
-        $tmp_rpm = Horde::getTempFile('horde_rpm');
+        $tmp_rpm = $this->_getTempFile();
         file_put_contents($tmp_rpm, $this->_mimepart->getContents());
 
-        $fh = popen($this->_conf['location'] . " -qip $tmp_rpm 2>&1", 'r');
+        $fh = popen($location . ' -qip ' . $tmp_rpm . ' 2>&1', 'r');
         while (($rc = fgets($fh, 8192))) {
             $data .= $rc;
         }
         pclose($fh);
 
+        $monospace = $this->getConfigParam('monospace');
+
         return $this->_renderReturn(
-            '<pre>' . htmlspecialchars($data) . '</pre>',
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            '<span ' .
+            ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
+            htmlspecialchars($data) . '</span>',
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 89ae1a6..4c2c341 100644 (file)
@@ -29,6 +29,27 @@ class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Base
         'raw' => false
     );
 
+   /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the unrtf binary.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
@@ -37,17 +58,17 @@ class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Base
     protected function _render()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
-        $tmp_rtf = Horde::getTempFile('rtf');
-        $tmp_output = Horde::getTempFile('rtf');
+        $tmp_rtf = $this->_getTempFile();
+        $tmp_output = $this->_getTempFile();
 
         file_put_contents($tmp_rtf, $this->_mimepart->getContents());
 
-        exec($this->_conf['location'] . " $tmp_rtf > $tmp_output");
+        exec($location . ' ' . $tmp_rtf . ' > ' . $tmp_output);
 
         $data = file_exists($tmp_output)
             ? file_get_contents($tmp_output)
@@ -55,7 +76,7 @@ class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $data,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 8e3d03e..5ae2fe7 100644 (file)
 class Horde_Mime_Viewer_Security extends Horde_Mime_Viewer_Base
 {
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'viewer_callback' - (callback) A callback to a factory that will
+     *                     return the appropriate viewer for the embedded
+     *                     MIME type. Is passed three parameters: the
+     *                     current driver object, the MIME part object, and
+     *                     the MIME type to use.
+     * </pre>
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the underlying MIME Viewer for this part.
      *
      * @return mixed  A Horde_Mime_Viewer object, or false if not found.
      */
     protected function _getViewer()
     {
-        if (!($protocol = $this->_mimepart->getContentTypeParameter('protocol'))) {
-            return false;
-        }
-
-        $viewer = Horde_Mime_Viewer::factory($this->_mimepart, $protocol);
-        if ($viewer) {
-            $viewer->setParams($this->_params);
+        if (($callback = $this->getConfigParam('viewer_callback')) &&
+            ($protocol = $this->_mimepart->getContentTypeParameter('protocol'))) {
+            return call_user_func($callback, $this, $this->_mimepart, $protocol);
         }
 
-        return $viewer;
+        return false;
     }
 
 }
index a5c2f0c..542bc1c 100644 (file)
@@ -70,7 +70,7 @@ class Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $this->_content,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index 9a0cc63..dfbb614 100644 (file)
@@ -32,6 +32,27 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the source-highlight binary.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -49,14 +70,13 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Base
     protected function _renderInline()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
-        /* Create temporary files for Webcpp. */
-        $tmpin  = Horde::getTempFile('SrcIn');
-        $tmpout = Horde::getTempFile('SrcOut');
+        $tmpin = $this->_getTempFile();
+        $tmpout = $this->_getTempFile();
 
         /* Write the contents of our buffer to the temporary input file. */
         file_put_contents($tmpin, $this->_mimepart->getContents());
@@ -65,13 +85,13 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Base
         $lang = $this->_typeToLang($this->_mimepart->getType());
 
         /* Execute Source-Highlite. */
-        exec($this->_conf['location'] . " --src-lang $lang --out-format html --input $tmpin --output $tmpout");
+        exec($location . ' --src-lang ' . escapeshellarg($lang) . ' --out-format html --input ' . $tmpin . ' --output ' . $tmpout);
         $results = file_get_contents($tmpout);
         unlink($tmpout);
 
         return $this->_renderReturn(
             $results,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index cfa3b0f..e7a4a56 100644 (file)
@@ -41,16 +41,21 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Base
     /**
      * Constructor.
      *
-     * @param Horde_Mime_Part $mime_part  Reference to an object with the
-     *                                    information to be rendered.
-     * @param array $conf                 Configuration specific to the
-     *                                    driver.
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'gzip' - (Horde_Compress_Gzip) A gzip object.
+     * 'monospace' - (string) A class to use to display monospace text inline.
+     *               DEFAULT: Uses style="font-family:monospace"
+     * 'tar' - (Horde_Compress_Tar) A tar object.
+     * </pre>
      */
-    public function __construct($mime_part, $conf = array())
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
     {
-        parent::__construct($mime_part, $conf);
+        parent::__construct($part, $conf);
 
-        $this->_metadata['compressed'] = in_array($mime_part->getSubType(), $this->_gzipSubtypes);
+        $this->_metadata['compressed'] = in_array($part->getSubType(), $this->_gzipSubtypes);
     }
 
     /**
@@ -78,19 +83,23 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Base
             return array();
         }
 
+        $charset = $this->getConfigParam('charset');
         $contents = $this->_mimepart->getContents();
 
         /* Decompress gzipped files. */
         if (in_array($subtype, $this->_gzipSubtypes)) {
-            $gzip = Horde_Compress::factory('gzip');
-            $contents = $gzip->decompress($contents);
+            if (!$this->getConfigParam('gzip')) {
+                $this->setConfigParam('gzip', Horde_Compress::factory('Gzip'));
+            }
+            $contents = $this->getConfigParam('gzip')->decompress($contents);
         }
 
         /* Obtain the list of files/data in the tar file. */
-        $tar = Horde_Compress::factory('tar');
-        $tarData = $tar->decompress($contents);
+        if (!$this->getConfigParam('tar')) {
+            $this->setConfigParam('tar', Horde_Compress::factory('Tar'));
+        }
+        $tarData = $this->getConfigParam('tar')->decompress($contents);
 
-        $charset = $GLOBALS['registry']->getCharset();
         $fileCount = count($tarData);
 
         $name = $this->_mimepart->getName(true);
@@ -98,35 +107,58 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Base
             $name = _("unnamed");
         }
 
+        $monospace = $this->getConfigParam('monospace');
+
         $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
-            '<table><tr><td align="left"><pre>' .
-            Horde_Text_Filter::filter(_("Archive Name") . ':  ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
-            Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
-            Horde_Text_Filter::filter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) .
+            '<table><tr><td align="left"><span ' .
+            ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
+            $this->_textFilter(_("Archive Name") . ':  ' . $name, 'Space2html', array(
+                'charset' => $charset,
+                'encode' => true,
+                'encode_all' => true
+            )) . "\n" .
+            $this->_textFilter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'Space2html', array(
+                'charset' => $charset,
+                'encode' => true,
+                'encode_all' => true
+            )) . "\n" .
+            $this->_textFilter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'Space2html', array(
+                'charset' => $charset,
+                'encode' => true,
+                'encode_all' => true
+            )) .
             "\n\n" .
-            Horde_Text_Filter::filter(
+            $this->_textFilter(
                 str_pad(_("File Name"), 62, ' ', STR_PAD_RIGHT) .
                 str_pad(_("Attributes"), 15, ' ', STR_PAD_LEFT) .
                 str_pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
                 str_pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT),
-                'space2html',
-                array('charset' => $charset, 'encode' => true, 'encode_all' => true)
+                'Space2html',
+                array(
+                    'charset' => $charset,
+                    'encode' => true,
+                    'encode_all' => true
+                )
             ) . "\n" .
             str_repeat('-', 106) . "\n";
 
         foreach ($tarData as $val) {
-            $text .= Horde_Text_Filter::filter(
+            $text .= $this->_textFilter(
                 str_pad($val['name'], 62, ' ', STR_PAD_RIGHT) .
                 str_pad($val['attr'], 15, ' ', STR_PAD_LEFT) .
                 str_pad($val['size'], 10, ' ', STR_PAD_LEFT) .
                 str_pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT),
-                'space2html',
-                array('charset' => $charset, 'encode' => true, 'encode_all' => true)
+                'Space2html',
+                array(
+                    'charset' => $charset,
+                    'encode' => true,
+                    'encode_all' => true
+                )
             ) . "\n";
         }
 
         return $this->_renderReturn(
-            nl2br($text . str_repeat('-', 106) . "\n</pre></td></tr></table>"),
+            nl2br($text . str_repeat('-', 106) . "\n</span></td></tr></table>"),
             'text/html; charset=' . $charset
         );
     }
index 46c2cd5..91a237e 100644 (file)
@@ -40,6 +40,23 @@ class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'tnef' - (Horde_Compress_Tnef) TNEF object.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -58,8 +75,10 @@ class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Base
      */
     protected function _renderInfo()
     {
-        $tnef = Horde_Compress::factory('tnef');
-        $info = $tnef->decompress($this->_mimepart->getContents());
+        if (!$this->getConfigParam('tnef')) {
+            $this->setConfigParam('tnef', Horde_Compress::factory('Tnef'));
+        }
+        $info = $this->getConfigParam('tnef')->decompress($this->_mimepart->getContents());
 
         $data = '<table border="1">';
         if (empty($info)) {
@@ -74,7 +93,7 @@ class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $data,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
diff --git a/framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php b/framework/Mime_Viewer/lib/Horde/Mime/Viewer/Vcard.php
deleted file mode 100644 (file)
index c7c90e4..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-<?php
-/**
- * The Horde_Mime_Viewer_Vcard class renders out vCards in HTML format.
- *
- * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Jan Schneider <jan@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package  Mime_Viewer
- */
-class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
-{
-    /**
-     * This driver's display capabilities.
-     *
-     * @var array
-     */
-    protected $_capability = array(
-        'full' => true,
-        'info' => false,
-        'inline' => true,
-        'raw' => false
-    );
-
-    /**
-     * URL that can be used as a callback for displaying images.
-     *
-     * @var Horde_Url
-     */
-    protected $_imageUrl;
-
-    /**
-     * Return the full rendered version of the Horde_Mime_Part object.
-     *
-     * @return array  See parent::render().
-     */
-    protected function _render()
-    {
-        $ret = $this->_renderInline();
-
-        if (!empty($ret)) {
-            reset($ret);
-            Horde::startBuffer();
-            include $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
-            echo $ret[key($ret)]['data'];
-            include $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
-            $ret[key($ret)]['data'] = Horde::endBuffer();
-        }
-
-        return $ret;
-    }
-
-    /**
-     * Return the rendered inline version of the Horde_Mime_Part object.
-     *
-     * @return array  See parent::render().
-     */
-    protected function _renderInline()
-    {
-        global $registry, $prefs, $notification;
-
-        $app = false;
-        $data = $this->_mimepart->getContents();
-        $html = '';
-        $import_msg = null;
-        $title = _("vCard");
-
-        $iCal = new Horde_Icalendar();
-        if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
-            $notification->push(_("There was an error reading the contact data."), 'horde.error');
-        }
-
-        if (Horde_Util::getFormData('import') &&
-            Horde_Util::getFormData('source') &&
-            $registry->hasMethod('contacts/import')) {
-            $source = Horde_Util::getFormData('source');
-            $count = 0;
-            foreach ($iCal->getComponents() as $c) {
-                if ($c->getType() == 'vcard') {
-                    try {
-                        $contacts = $registry->call('contacts/import', array($c, null, $source));
-                        ++$count;
-                    } catch (Horde_Exception $e) {
-                        $notification->push(_("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
-                    }
-                }
-            }
-            $notification->push(sprintf(ngettext(
-                "%d contact was successfully added to your address book.",
-                "%d contacts were successfully added to your address book.",
-                $count),
-                                        $count),
-                                'horde.success');
-        }
-
-        $html .= '<table cellspacing="1" border="0" cellpadding="1">';
-
-        foreach ($iCal->getComponents() as $i => $vc) {
-            if ($i > 0) {
-                $html .= '<tr><td colspan="2">&nbsp;</td></tr>';
-            }
-
-            $html .= '<tr><td colspan="2" class="header">';
-            $fullname = $vc->getAttributeDefault('FN', false);
-            if ($fullname !== false) {
-                $html .= $fullname;
-            }
-            $html .= '</td></tr>';
-
-            $n = $vc->printableName();
-            if (!empty($n)) {
-                $html .= $this->_row(_("Name"), $n);
-            }
-
-            $aliases = $vc->getAttributeValues('ALIAS');
-            if (!is_a($aliases, 'PEAR_Error')) {
-                $html .= $this->_row(_("Alias"), implode("\n", $aliases));
-            }
-            $birthdays = $vc->getAttributeValues('BDAY');
-            if (!is_a($birthdays, 'PEAR_Error')) {
-                $birthday = new Horde_Date($birthdays[0]);
-                $html .= $this->_row(
-                    _("Birthday"),
-                    $birthday->strftime($prefs->getValue('date_format')));
-            }
-
-            $photos = $vc->getAllAttributes('PHOTO');
-            foreach ($photos as $p => $photo) {
-                if (isset($photo['params']['VALUE']) &&
-                    Horde_String::upper($photo['params']['VALUE']) == 'URI') {
-                    $html .= $this->_row(_("Photo"),
-                                         '<img src="' . htmlspecialchars($photo['value']) . '" />',
-                                         false);
-                } elseif (isset($photo['params']['ENCODING']) &&
-                          Horde_String::upper($photo['params']['ENCODING']) == 'B' &&
-                          isset($photo['params']['TYPE'])) {
-                    if ($GLOBALS['browser']->hasFeature('datauri') === true ||
-                        $GLOBALS['browser']->hasFeature('datauri') >= strlen($photo['value'])) {
-                        $html .= $this->_row(_("Photo"),
-                                             '<img src="data:' . htmlspecialchars($photo['params']['TYPE'] . ';base64,' . $photo['value']) . '" />',
-                                             false);
-                    } elseif ($this->_imageUrl) {
-                        $html .= $this->_row(_("Photo"),
-                                             '<img src="' . htmlspecialchars($this->_imageUrl->add(array('c' => $i, 'p' => $p))) . '" />',
-                                             false);
-                    }
-                }
-            }
-
-            $labels = $vc->getAllAttributes('LABEL');
-            foreach ($labels as $label) {
-                if (isset($label['params']['TYPE'])) {
-                    if (!is_array($label['params']['TYPE'])) {
-                        $label['params']['TYPE'] = array($label['params']['TYPE']);
-                    }
-                } else {
-                    $label['params']['TYPE'] = array_keys($label['params']);
-                }
-                $types = array();
-                foreach ($label['params']['TYPE'] as $type) {
-                    switch(Horde_String::upper($type)) {
-                    case 'HOME':
-                        $types[] = _("Home Address");
-                        break;
-
-                    case 'WORK':
-                        $types[] = _("Work Address");
-                        break;
-
-                    case 'DOM':
-                        $types[] = _("Domestic Address");
-                        break;
-
-                    case 'INTL':
-                        $types[] = _("International Address");
-                        break;
-
-                    case 'POSTAL':
-                        $types[] = _("Postal Address");
-                        break;
-
-                    case 'PARCEL':
-                        $types[] = _("Parcel Address");
-                        break;
-
-                    case 'PREF':
-                        $types[] = _("Preferred Address");
-                        break;
-                    }
-                }
-                if (!count($types)) {
-                    $types = array(_("Address"));
-                }
-                $html .= $this->_row(implode('/', $types), $label['value']);
-            }
-
-            $adrs = $vc->getAllAttributes('ADR');
-            foreach ($adrs as $item) {
-                if (isset($item['params']['TYPE'])) {
-                    if (!is_array($item['params']['TYPE'])) {
-                        $item['params']['TYPE'] = array($item['params']['TYPE']);
-                    }
-                } else {
-                    $item['params']['TYPE'] = array_keys($item['params']);
-                }
-
-                $address = $item['values'];
-                $a = array();
-                $a_list = array(
-                    Horde_Icalendar_Vcard::ADR_STREET,
-                    Horde_Icalendar_Vcard::ADR_LOCALITY,
-                    Horde_Icalendar_Vcard::ADR_REGION,
-                    Horde_Icalendar_Vcard::ADR_POSTCODE,
-                    Horde_Icalendar_Vcard::ADR_COUNTRY
-                );
-
-                foreach ($a_list as $val) {
-                    if (isset($address[$val])) {
-                        $a[] = $address[$val];
-                    }
-                }
-
-                $types = array();
-                foreach ($item['params']['TYPE'] as $type) {
-                    switch(Horde_String::upper($type)) {
-                    case 'HOME':
-                        $types[] = _("Home Address");
-                        break;
-
-                    case 'WORK':
-                        $types[] = _("Work Address");
-                        break;
-
-                    case 'DOM':
-                        $types[] = _("Domestic Address");
-                        break;
-
-                    case 'INTL':
-                        $types[] = _("International Address");
-                        break;
-
-                    case 'POSTAL':
-                        $types[] = _("Postal Address");
-                        break;
-
-                    case 'PARCEL':
-                        $types[] = _("Parcel Address");
-                        break;
-
-                    case 'PREF':
-                        $types[] = _("Preferred Address");
-                        break;
-                    }
-                }
-                if (!count($types)) {
-                    $types = array(_("Address"));
-                }
-                $html .= $this->_row(implode('/', $types), implode("\n", $a));
-            }
-
-            $numbers = $vc->getAllAttributes('TEL');
-
-            foreach ($numbers as $number) {
-                if (isset($number['params']['TYPE'])) {
-                    if (!is_array($number['params']['TYPE'])) {
-                        $number['params']['TYPE'] = array($number['params']['TYPE']);
-                    }
-                    foreach ($number['params']['TYPE'] as $type) {
-                        $number['params'][Horde_String::upper($type)] = true;
-                    }
-                }
-                if (isset($number['params']['FAX'])) {
-                    $html .= $this->_row(_("Fax"), $number['value']);
-                } else {
-                    if (isset($number['params']['HOME'])) {
-                        $html .= $this->_row(_("Home Phone"),
-                                             $number['value']);
-                    } elseif (isset($number['params']['WORK'])) {
-                        $html .= $this->_row(_("Work Phone"),
-                                             $number['value']);
-                    } elseif (isset($number['params']['CELL'])) {
-                        $html .= $this->_row(_("Cell Phone"),
-                                             $number['value']);
-                    } else {
-                        $html .= $this->_row(_("Phone"),
-                                             $number['value']);
-                    }
-                }
-            }
-
-            $addresses = $vc->getAllAttributes('EMAIL');
-            $emails = array();
-            foreach ($addresses as $address) {
-                if (isset($address['params']['TYPE'])) {
-                    if (!is_array($address['params']['TYPE'])) {
-                        $address['params']['TYPE'] = array($address['params']['TYPE']);
-                    }
-                    foreach ($address['params']['TYPE'] as $type) {
-                        $address['params'][Horde_String::upper($type)] = true;
-                    }
-                }
-                $email = '<a href="';
-                if ($registry->hasMethod('mail/compose')) {
-                    $email .= $registry->call(
-                        'mail/compose',
-                        array(array('to' => $address['value'])));
-                } else {
-                    $email .= 'mailto:' . htmlspecialchars($address['value']);
-                }
-                $email .= '">' . htmlspecialchars($address['value']) . '</a>';
-                if (isset($address['params']['PREF'])) {
-                    array_unshift($emails, $email);
-                } else {
-                    $emails[] = $email;
-                }
-            }
-
-            if (count($emails)) {
-                $html .= $this->_row(_("Email"), implode("\n", $emails), false);
-            }
-
-            $title = $vc->getAttributeValues('TITLE');
-            if (!is_a($title, 'PEAR_Error')) {
-                $html .= $this->_row(_("Title"), $title[0]);
-            }
-
-            $role = $vc->getAttributeValues('ROLE');
-            if (!is_a($role, 'PEAR_Error')) {
-                $html .= $this->_row(_("Role"), $role[0]);
-            }
-
-            $org = $vc->getAttributeValues('ORG');
-            if (!is_a($org, 'PEAR_Error')) {
-                $html .= $this->_row(_("Company"), $org[0]);
-                if (isset($org[1])) {
-                    $html .= $this->_row(_("Department"), $org[1]);
-                }
-            }
-
-            $notes = $vc->getAttributeValues('NOTE');
-            if (!is_a($notes, 'PEAR_Error')) {
-                $html .= $this->_row(_("Notes"), $notes[0]);
-            }
-
-            $url = $vc->getAttributeValues('URL');
-            if (!is_a($url, 'PEAR_Error')) {
-                $html .= $this->_row(
-                    _("URL"),
-                    '<a href="' . htmlspecialchars($url[0])
-                        . '" target="_blank">' . htmlspecialchars($url[0])
-                        . '</a>',
-                    false);
-            }
-        }
-
-        if ($registry->hasMethod('contacts/import') &&
-            $registry->hasMethod('contacts/sources')) {
-            $html .= '<tr><td colspan="2" class="smallheader"><form action="'
-                . Horde::selfUrl() . '" method="get" name="vcard_import">'
-                . Horde_Util::formInput();
-            foreach ($_GET as $key => $val) {
-                $html .= '<input type="hidden" name="' . htmlspecialchars($key)
-                    . '" value="' . htmlspecialchars($val) . '" />';
-            }
-
-            $sources = $registry->call('contacts/sources', array(true));
-            if (count($sources) > 1) {
-                $html .=
-                    '<input type="submit" class="button" name="import" value="'
-                    . _("Add to address book:") . '" />'
-                    . '<label for="add_source" class="hidden">'
-                    . _("Address Book") . '</label>'
-                    . '<select id="add_source" name="source">';
-                foreach ($sources as $key => $label) {
-                    $selected = ($key == $prefs->getValue('add_source'))
-                        ? ' selected="selected"' : '';
-                    $html .= '<option value="' . htmlspecialchars($key) . '"'
-                        . $selected . '>' . htmlspecialchars($label)
-                        . '</option>';
-                }
-            } else {
-                reset($sources);
-                $html .=
-                    '<input type="submit" class="button" name="import" value="'
-                    . _("Add to my address book") . '" />'
-                    . '<input type="hidden" name="source" value="'
-                    . htmlspecialchars(key($sources)) . '" />';
-            }
-
-            $html .= '</form></td></tr><tr><td>&nbsp;</td></tr>';
-        }
-
-        $html .=  '</table>';
-
-        Horde::startBuffer();
-        $notification->notify(array('listeners' => 'status'));
-
-        return $this->_renderReturn(
-            Horde::endBuffer() . $html,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
-        );
-    }
-
-    /**
-     * TODO
-     */
-    protected function _row($label, $value, $encode = true)
-    {
-        if ($encode) {
-            $label = htmlspecialchars($label);
-            $value = htmlspecialchars($value);
-        }
-        return '<tr><td class="item" valign="top">' . $label .
-            '</td><td class="item" valign="top">' . nl2br($value) .
-            "</td></tr>\n";
-    }
-
-}
index 7e6522c..a7aee86 100644 (file)
@@ -30,6 +30,27 @@ class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Base
     );
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'location' - (string) Location of the wpd2html binary.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        $this->_required = array_merge($this->_required, array(
+            'location'
+        ));
+
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -37,17 +58,17 @@ class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Base
     protected function _render()
     {
         /* Check to make sure the viewer program exists. */
-        if (!isset($this->_conf['location']) ||
-            !file_exists($this->_conf['location'])) {
+        if (!($location = $this->getConfigParam('location')) ||
+            !file_exists($location)) {
             return array();
         }
 
-        $tmp_wpd = Horde::getTempFile('wpd');
-        $tmp_output = Horde::getTempFile('wpd');
+        $tmp_wpd = $this->_getTempFile();
+        $tmp_output = $this->_getTempFile();
 
         file_put_contents($tmp_wpd, $this->_mimepart->getContents());
 
-        exec($this->_conf['location'] . " $tmp_wpd > $tmp_output");
+        exec($location . ' ' . $tmp_wpd . ' > ' . $tmp_output);
 
         $data = file_exists($tmp_output)
             ? file_get_contents($tmp_output)
@@ -55,7 +76,7 @@ class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             $data,
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $this->getConfigParam('charset')
         );
     }
 
index be2c0b7..b7c9a87 100644 (file)
@@ -47,6 +47,25 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
     protected $_callback = null;
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Mime_Part $mime_part  The object with the data to be
+     *                                    rendered.
+     * @param array $conf                 Configuration:
+     * <pre>
+     * 'monospace' - (string) A class to use to display monospace text inline.
+     *               DEFAULT: Uses style="font-family:monospace"
+     * 'zip' - (Horde_Compress_Zip) Zip object.
+     * </pre>
+     *
+     * @throws InvalidArgumentException
+     */
+    public function __construct(Horde_Mime_Part $part, array $conf = array())
+    {
+        parent::__construct($part, $conf);
+    }
+
+    /**
      * Return the full rendered version of the Horde_Mime_Part object.
      *
      * @return array  See parent::render().
@@ -76,10 +95,15 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
      */
     protected function _toHTML()
     {
+        $charset = $this->getConfigParam('charset');
         $contents = $this->_mimepart->getContents();
 
-        $zip = Horde_Compress::factory('zip');
-        $zipInfo = $zip->decompress($contents, array('action' => Horde_Compress_Zip::ZIP_LIST));
+        if (!$this->getConfigParam('zip')) {
+            $this->setConfigParam('zip', Horde_Compress::factory('Zip'));
+        }
+        $zipInfo = $this->getConfigParam('zip')->decompress($contents, array(
+            'action' => Horde_Compress_Zip::ZIP_LIST
+        ));
 
         $fileCount = count($zipInfo);
 
@@ -95,9 +119,12 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
             $name = _("unnamed");
         }
 
+        $monospace = $this->getConfigParam('monospace');
+
         $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
-            '<table><tr><td align="left"><span style="font-family:monospace">' .
-            Horde_Text_Filter::filter(
+            '<table><tr><td align="left"><span ' .
+            ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
+            $this->_textFilter(
                 _("Archive Name") . ': ' . $name . "\n" .
                 _("Archive File Size") . ': ' . strlen($contents) .
                 " bytes\n" .
@@ -110,8 +137,12 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
                 Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
                 Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) .
                 "\n",
-                'space2html',
-                array('charset' => $GLOBALS['registry']->getCharset(), 'encode' => true, 'encode_all' => true)
+                'Space2html',
+                array(
+                    'charset' => $charset,
+                    'encode' => true,
+                    'encode_all' => true
+                )
             ) . str_repeat('-', 59 + $maxlen) . "\n";
 
         foreach ($zipInfo as $key => $val) {
@@ -119,16 +150,20 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
                 ? 0
                 : 100 * ($val['csize'] / $val['size']);
 
-            $val['name']   = Horde_String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT);
-            $val['attr']   = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT);
-            $val['size']   = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT);
-            $val['date']   = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT);
+            $val['name'] = Horde_String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT);
+            $val['attr'] = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT);
+            $val['size'] = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT);
+            $val['date'] = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT);
             $val['method'] = Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT);
-            $val['ratio']  = Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT);
+            $val['ratio'] = Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT);
 
             reset($val);
             while (list($k, $v) = each($val)) {
-                $val[$k] = Horde_Text_Filter::filter($v, 'space2html', array('charset' => $GLOBALS['registry']->getCharset(), 'encode' => true, 'encode_all' => true));
+                $val[$k] = $this->_textFilter($v, 'Space2html', array(
+                    'charset' => $charset,
+                    'encode' => true,
+                    'encode_all' => true
+                ));
             }
 
             if (!is_null($this->_callback)) {
@@ -142,7 +177,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
 
         return $this->_renderReturn(
             nl2br($text . str_repeat('-', 59 + $maxlen) . "\n</span></td></tr></table>"),
-            'text/html; charset=' . $GLOBALS['registry']->getCharset()
+            'text/html; charset=' . $charset
         );
     }
 
index 1a85f0c..c0d445c 100644 (file)
@@ -74,7 +74,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <file name="Srchighlite.php" role="php" />
        <file name="Tgz.php" role="php" />
        <file name="Tnef.php" role="php" />
-       <file name="Vcard.php" role="php" />
        <file name="Wordperfect.php" role="php" />
        <file name="Zip.php" role="php" />
       </dir> <!-- /lib/Horde/Mime/Viewer -->
@@ -103,43 +102,37 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <min>1.5.4</min>
    </pearinstaller>
    <package>
-    <name>Core</name>
+    <name>Browser</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Exception</name>
+    <name>Compress</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Mime</name>
+    <name>Exception</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Util</name>
-    <channel>pear.horde.org</channel>
-   </package>
-   <extension>
-    <name>gettext</name>
-   </extension>
-  </required>
-  <optional>
-   <package>
-    <name>Browser</name>
+    <name>Mime</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Compress</name>
+    <name>Text_Filter</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Icalendar</name>
+    <name>Text_Flowed</name>
     <channel>pear.horde.org</channel>
    </package>
    <package>
-    <name>Text_Filter</name>
+    <name>Util</name>
     <channel>pear.horde.org</channel>
    </package>
-  </optional>
+   <extension>
+    <name>gettext</name>
+   </extension>
+  </required>
  </dependencies>
  <phprelease>
   <filelist>
@@ -183,7 +176,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Mime/Viewer/Srchighlite.php" as="Horde/Mime/Viewer/Srchighlite.php" />
    <install name="lib/Horde/Mime/Viewer/Tgz.php" as="Horde/Mime/Viewer/Tgz.php" />
    <install name="lib/Horde/Mime/Viewer/Tnef.php" as="Horde/Mime/Viewer/Tnef.php" />
-   <install name="lib/Horde/Mime/Viewer/Vcard.php" as="Horde/Mime/Viewer/Vcard.php" />
    <install name="lib/Horde/Mime/Viewer/Wordperfect.php" as="Horde/Mime/Viewer/Wordperfect.php" />
    <install name="lib/Horde/Mime/Viewer/Zip.php" as="Horde/Mime/Viewer/Zip.php" />
    <install name="lib/Horde/Mime/Viewer.php" as="Horde/Mime/Viewer.php" />
index 71db5d4..74d0e40 100644 (file)
@@ -1,35 +1,20 @@
 <?php
 /**
- * Decide which output drivers you want to activate for Gollem.
- * Settings in this file override settings in horde/config/mime_drivers.php.
+ * MIME Viewer configuration for Gollem.
  *
- * The available drivers are:
- * --------------------------
- * images     View images inline
+ * Settings in this file override settings in horde/config/mime_drivers.php.
+ * All drivers configured in that file, but not configured here, will also
+ * be used to display MIME content.
  *
  * $Id$
  */
-$mime_drivers_map['gollem']['registered'] = array('images');
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here. Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
- */
-$mime_drivers_map['gollem']['overrides'] = array();
 
-/**
- * Driver specific settings. See horde/config/mime_drivers.php for
- * the format.
- */
-
-/**
- * Image driver settings
- */
-$mime_drivers['gollem']['images'] = array(
-    'inline' => true,
-    'handles' => array(
-        'image/*'
+$mime_drivers = array(
+    /* Image viewing. Gollem can display images inline. */
+    'images' => array(
+        'inline' => true,
+        'handles' => array(
+            'image/*'
+        )
     )
 );
index 711b186..3c8c08d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The Gollem_Horde_Mime_Viewer_Images class allows images to be displayed
+ * The Gollem_Mime_Viewer_Images class allows images to be displayed
  * inline from file data.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -11,7 +11,7 @@
  * @author  Mike Cochrane <mike@graftonhall.co.nz>
  * @package Horde_Mime
  */
-class Gollem_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
+class Gollem_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
 {
     /**
      * Can this driver render various views?
index a03075c..1348e54 100644 (file)
@@ -389,7 +389,7 @@ if (is_array($list) && $numitem && $read_perms) {
             $item['graphic'] = $folder_img;
         } else {
             if (empty($icon_cache[$val['type']])) {
-                $icon_cache[$val['type']] = Horde::img(Horde_Mime_Viewer::getIcon(Horde_Mime_Magic::extToMime($val['type'])), '', '', '');
+                $icon_cache[$val['type']] = Horde::img($injector->getInstance('Horde_Mime_Viewer')->getIcon(Horde_Mime_Magic::extToMime($val['type'])), '', '', '');
             }
             $item['graphic'] = $icon_cache[$val['type']];
         }
index b2a3468..c8b3c1f 100644 (file)
@@ -66,8 +66,7 @@ if ($command) {
     $part->setType('application/x-httpd-phps');
     $part->buildMimeIds();
 
-    $viewer = Horde_Mime_Viewer::factory($part);
-    $pretty = $viewer->render('inline');
+    $pretty = $injector->getInstance('Horde_Mime_Viewer')->getViewer($part)->render('inline');
 
     echo '<h1 class="header">' . _("PHP Code") . '</h1>' .
         $pretty[1]['data'] .
index f87b23a..1f8bca2 100644 (file)
@@ -1,75 +1,10 @@
 <?php
 /**
- * Decide which output drivers you want to activate for all Horde
- * applications. Individual Horde applications can override these settings
- * in their config/mime_drivers.php files.
- *
- * The available drivers are:
- * --------------------------
- * audio          Audio files
- * css            CSS Styles
- * deb            Debian packages
- * enriched       Enriched text format
- * html           HTML data
- * images         Image files
- * msword         Microsoft Word files via AbiWord
- * msexcel        Microsoft Excel files via Gnumeric
- * mspowerpoint   Microsoft Powerpoint files via ppthtml
- * ooo            OpenOffice.org/StarOffice Documents
- * pdf            Portable Document Format (PDF) files
- * php            The internal PHP4 syntax highlighting engine
- * plain          Return text, with links made clickable and other HTML
- *                filtered out
- * rar            RAR archives
- * report         Report messages (RFC 3452)
- * rfc822         Digested messages (RFC 2046 [5.2.1])
- * richtext       Richtext text format (RFC 1341 [7.1.3])
- * rpm            RPM packages
- * rtf            RTF documents via unrtf
- * security       Secure multiparts (RFC 1847)
- * simple         Output text without modification
- * smil           SMIL documents
- * srchighlite    Source Highlight
- * tgz            Tarballs, including gzipped ones
- * tnef           MS-TNEF attachments
- * vcard          vCards
- * wordperfect    WordPerfect documents via wpd2html
- * zip            Zip files
+ * MIME Viewer configuration file.
  *
- * $Id$
- */
-$mime_drivers_map['horde']['registered'] = array(
-    'audio', 'css', 'enriched', 'html', 'images', 'ooo', 'pdf', 'php',
-    'plain', 'rar', 'report', 'rfc822', 'richtext', 'security', 'simple',
-    'smil', 'tgz', 'tnef', 'vcard', 'zip',
-
-    /* The following mime drivers require external applications to be
-     * installed and are disabled by default. */
-    // 'deb',
-    // 'msword',
-    // 'msexcel',
-    // 'mspowerpoint',
-    // 'rpm',
-    // 'rtf',
-    // 'srchighlite',
-    // 'wordperfect',
-);
-
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here.  Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
- */
-$mime_drivers_map['horde']['overrides'] = array();
-
-
-/**
- * Driver specific settings. Here, you have to configure each driver
- * which you chose to activate above. Default settings have been
- * filled in for them, and if you haven't activated it, then just
- * leave it as it is - it won't get loaded.
+ * Default settings used for all Horde applications that require MIME
+ * viewing. Individual Horde applications can override these settings
+ * in their config/mime_drivers.php files.
  *
  * The 'handles' setting below shouldn't be changed in most
  * circumstances. It registers a set of MIME type that the driver can
@@ -84,561 +19,500 @@ $mime_drivers_map['horde']['overrides'] = array();
  * for that driver, and can also include specific MIME-types which can
  * have their own icons. You can set the MIME subtype to '*' to match
  * all possible subtypes (i.e. 'image/*').
+ *
+ * $Id$
  */
 
-/**
- * Default driver settings
- */
-$mime_drivers['horde']['default']['icons'] = array(
-    'default'                       => 'text.png',
-    'message/*'                     => 'mail.png',
-    'unknown/*'                     => 'binary.png',
-    'video/*'                       => 'video.png',
-    'application/pgp-signature'     => 'encryption.png',
-    'application/x-pkcs7-signature' => 'encryption.png',
-    'application/octet-stream'      => 'binary.png'
-);
-
-
-/**
- * Default text driver settings
- */
-$mime_drivers['horde']['simple'] = array(
-    'inline' => false,
-    'handles' => array(
-        'text/*'
+$mime_drivers = array(
+    /* Default driver. */
+    'default' => array(
+        'icons' => array(
+            'default'                       => 'text.png',
+            'message/*'                     => 'mail.png',
+            'unknown/*'                     => 'binary.png',
+            'video/*'                       => 'video.png',
+            'application/pgp-signature'     => 'encryption.png',
+            'application/x-pkcs7-signature' => 'encryption.png',
+            'application/octet-stream'      => 'binary.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'text.png'
-    )
-);
-
 
-/**
- * Plain text driver settings
- */
-$mime_drivers['horde']['plain'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/plain'
+    /* Default text driver. */
+    'simple' => array(
+        'handles' => array(
+            'text/*'
+        ),
+        'icons' => array(
+            'default' => 'text.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'text.png'
-    )
-);
-
 
-/**
- * Default audio driver settings
- */
-$mime_drivers['horde']['audio'] = array(
-    'inline' => false,
-    'handles' => array(
-        'audio/*'
+    /* Plain text driver. */
+    'plain' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/plain'
+        ),
+        'icons' => array(
+            'default' => 'text.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'audio.png'
-    )
-);
-
 
-/**
- * Default smil driver settings
- */
-$mime_drivers['horde']['smil'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/smil'
+    /* Default audio driver. */
+    'audio' => array(
+        'handles' => array(
+            'audio/*'
+        ),
+        'icons' => array(
+            'default' => 'audio.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'video.png'
-    )
-);
-
 
-/**
- * PHP driver settings
- */
-$mime_drivers['horde']['php'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/x-php',
-        'x-extension/phps',
-        'x-extension/php3s',
-        'application/x-httpd-php',
-        'application/x-httpd-php3',
-        'application/x-httpd-phps'
+    /* Default smil driver. */
+    'smil' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/smil'
+        ),
+        'icons' => array(
+            'default' => 'video.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'php.png'
-    )
-);
-
 
-/**
- * CSS driver settings
- */
-$mime_drivers['horde']['css'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/css',
-        'x-extension/css'
+    /* PHP pretty-print code display. */
+    'php' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/x-php',
+            'x-extension/phps',
+            'x-extension/php3s',
+            'application/x-httpd-php',
+            'application/x-httpd-php3',
+            'application/x-httpd-phps'
+        ),
+        'icons' => array(
+            'default' => 'php.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'html.png'
-    )
-);
-
 
-/**
- * HTML text driver settings
- */
-$mime_drivers['horde']['html'] = array(
-    // NOTE: Inline HTML viewing is DISABLED by default.
-    'inline' => false,
-    'handles' => array(
-        'text/html'
-    ),
-    'icons' => array(
-        'default' => 'html.png'
+    /* CSS pretty-print display. */
+    'css' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/css',
+            'x-extension/css'
+        ),
+        'icons' => array(
+            'default' => 'html.png'
+        )
     ),
-    // Check for phishing exploits?
-    'phishing_check' => true
-);
-
 
-/**
- * Enriched text driver settings
- */
-$mime_drivers['horde']['enriched'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/enriched'
+    /* HTML display. */
+    'html' => array(
+        // NOTE: Inline HTML viewing is DISABLED by default.
+        'inline' => false,
+        'handles' => array(
+            'text/html'
+        ),
+        'icons' => array(
+            'default' => 'html.png'
+        ),
+
+        // Check for phishing exploits?
+        'phishing_check' => true
     ),
-    'icons' => array(
-        'default' => 'text.png'
-    )
-);
-
 
-/**
- * Richtext text driver settings
- */
-$mime_drivers['horde']['richtext'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/richtext'
+    /* Enriched text display. */
+    'enriched' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/enriched'
+        ),
+        'icons' => array(
+            'default' => 'text.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'text.png'
-    )
-);
-
 
-/**
- * Source-Highlight driver settings
- * http://www.gnu.org/software/src-highlite/
- */
-$mime_drivers['horde']['srchighlite'] = array(
-    'location' => '/usr/bin/source-highlight',
-    'inline' => true,
-    'handles' => array(
-        'application/x-httpd-php',
-        'application/x-httpd-php3',
-        'application/x-httpd-phps',
-        'application/x-javascript',
-        'application/x-perl',
-        'application/x-php',
-        'application/x-python',
-        'application/x-ruby',
-        'application/x-sh',
-        'application/x-shellscript',
-        'application/x-tcl',
-        'application/xml',
-        'text/cpp',
-        'text/css',
-        'text/diff',
-        'text/x-c++hdr',
-        'text/x-c++src',
-        'text/x-chdr',
-        'text/x-csrc',
-        'text/x-diff',
-        'text/x-emacs-lisp',
-        'text/x-fortran',
-        'text/x-java',
-        'text/x-pascal',
-        'text/x-patch',
-        'text/x-sql',
-        'text/x-tex',
-        'text/xml',
-        'x-extension/asm',
-        'x-extension/bat',
-        'x-extension/cs',
-        'x-extension/css',
-        'x-extension/f77',
-        'x-extension/f90',
-        'x-extension/for',
-        'x-extension/ftn',
-        'x-extension/php3s',
-        'x-extension/phps',
-        'x-extension/rc',
-        'x-extension/vb',
-        'x-extension/vba'
+    /* Richtext display. */
+    'richtext' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/richtext'
+        ),
+        'icons' => array(
+            'default' => 'text.png'
+        )
     ),
-    'icons' => array(
-        'default'                   => 'text.png',
-        'application/x-httpd-php'   => 'php.png',
-        'application/x-httpd-php3'  => 'php.png',
-        'application/x-httpd-phps'  => 'php.png',
-        'application/x-javascript'  => 'script-js.png',
-        'application/x-php'         => 'php.png',
-        'application/x-python'      => 'source-python.png',
-        'application/x-sh'          => 'shell.png',
-        'application/x-shellscript' => 'shell.png',
-        'application/xml'           => 'xml.png',
-        'text/cpp'                  => 'source-c.png',
-        'text/css'                  => 'html.png',
-        'text/x-c++hdr'             => 'source-c.png',
-        'text/x-c++src'             => 'source-c.png',
-        'text/x-chdr'               => 'source-h.png',
-        'text/x-csrc'               => 'source-c.png',
-        'text/x-java'               => 'source-java.png',
-        'text/x-sql'                => 'sql.png',
-        'text/xml'                  => 'xml.png',
-        'x-extension/css'           => 'html.png',
-        'x-extension/php3s'         => 'php.png',
-        'x-extension/phps'          => 'php.png',
-        'x-extension/rc'            => 'xml.png'
-    )
-);
-
 
-/**
- * Tar driver settings
- * To access gzipped files, the zlib library must have been built into PHP
- * (with the --with-zlib option).
- */
-$mime_drivers['horde']['tgz'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/gzip',
-        'application/x-compressed-tar',
-        'application/x-gtar',
-        'application/x-gzip',
-        'application/x-gzip-compressed',
-        'application/x-tar',
-        'application/x-tgz'
+    /* Source-highlight driver.
+     * http://www.gnu.org/software/src-highlite/ */
+    'srchighlite' => array(
+        // Disabled by default
+        'disable' => true,
+        'inline' => true,
+        'handles' => array(
+            'application/x-httpd-php',
+            'application/x-httpd-php3',
+            'application/x-httpd-phps',
+            'application/x-javascript',
+            'application/x-perl',
+            'application/x-php',
+            'application/x-python',
+            'application/x-ruby',
+            'application/x-sh',
+            'application/x-shellscript',
+            'application/x-tcl',
+            'application/xml',
+            'text/cpp',
+            'text/css',
+            'text/diff',
+            'text/x-c++hdr',
+            'text/x-c++src',
+            'text/x-chdr',
+            'text/x-csrc',
+            'text/x-diff',
+            'text/x-emacs-lisp',
+            'text/x-fortran',
+            'text/x-java',
+            'text/x-pascal',
+            'text/x-patch',
+            'text/x-sql',
+            'text/x-tex',
+            'text/xml',
+            'x-extension/asm',
+            'x-extension/bat',
+            'x-extension/cs',
+            'x-extension/css',
+            'x-extension/f77',
+            'x-extension/f90',
+            'x-extension/for',
+            'x-extension/ftn',
+            'x-extension/php3s',
+            'x-extension/phps',
+            'x-extension/rc',
+            'x-extension/vb',
+            'x-extension/vba'
+        ),
+        'icons' => array(
+            'default'                   => 'text.png',
+            'application/x-httpd-php'   => 'php.png',
+            'application/x-httpd-php3'  => 'php.png',
+            'application/x-httpd-phps'  => 'php.png',
+            'application/x-javascript'  => 'script-js.png',
+            'application/x-php'         => 'php.png',
+            'application/x-python'      => 'source-python.png',
+            'application/x-sh'          => 'shell.png',
+            'application/x-shellscript' => 'shell.png',
+            'application/xml'           => 'xml.png',
+            'text/cpp'                  => 'source-c.png',
+            'text/css'                  => 'html.png',
+            'text/x-c++hdr'             => 'source-c.png',
+            'text/x-c++src'             => 'source-c.png',
+            'text/x-chdr'               => 'source-h.png',
+            'text/x-csrc'               => 'source-c.png',
+            'text/x-java'               => 'source-java.png',
+            'text/x-sql'                => 'sql.png',
+            'text/xml'                  => 'xml.png',
+            'x-extension/css'           => 'html.png',
+            'x-extension/php3s'         => 'php.png',
+            'x-extension/phps'          => 'php.png',
+            'x-extension/rc'            => 'xml.png'
+        ),
+
+        // REQUIRED: Location of the source-highlight binary
+        'location' => '/usr/bin/source-highlight'
     ),
-    'icons' => array(
-        'default' => 'compressed.png'
-    )
-);
-
 
-/**
- * Zip file driver settings
- */
-$mime_drivers['horde']['zip'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/x-compressed',
-        'application/x-zip-compressed',
-        'application/zip'
+    /* Tar file display.
+     * To access gzipped files, the zlib library must have been built into PHP
+     * (with the --with-zlib option). */
+    'tgz' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/gzip',
+            'application/x-compressed-tar',
+            'application/x-gtar',
+            'application/x-gzip',
+            'application/x-gzip-compressed',
+            'application/x-tar',
+            'application/x-tgz'
+        ),
+        'icons' => array(
+            'default' => 'compressed.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'compressed.png'
-    )
-);
 
-
-/**
- * RAR archive driver settings
- */
-$mime_drivers['horde']['rar'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/x-rar',
-        'application/x-rar-compressed'
+    /* Zip file display. */
+    'zip' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/x-compressed',
+            'application/x-zip-compressed',
+            'application/zip'
+        ),
+        'icons' => array(
+            'default' => 'compressed.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'compressed.png'
-    )
-);
 
-
-/**
- * MS Word driver settings
- * This driver requires AbiWord to be installed.
- * AbiWord homepage: http://www.abisource.com/
- */
-$mime_drivers['horde']['msword'] = array(
-    'location' => '/usr/bin/abiword',
-    'inline' => false,
-    'handles' => array(
-        'application/msword',
-        'application/vnd.ms-word'
+    /* RAR archive display. */
+    'rar' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/x-rar',
+            'application/x-rar-compressed'
+        ),
+        'icons' => array(
+            'default' => 'compressed.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'msword.png'
-    )
-);
 
-
-/**
- * MS Excel driver settings
- * This driver requires Gnumeric to be installed.
- * Gnumeric homepage: http://projects.gnome.org/gnumeric/
- */
-$mime_drivers['horde']['msexcel'] = array(
-    'location' => '/usr/bin/ssconvert',
-    'inline' => false,
-    'handles' => array(
-        'application/msexcel',
-        'application/x-msexcel',
-        'application/vnd.ms-excel'
+    /* MS Word display.
+     * This driver requires AbiWord to be installed.
+     * AbiWord homepage: http://www.abisource.com/ */
+    'msword' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/msword',
+            'application/vnd.ms-word'
+        ),
+        'icons' => array(
+            'default' => 'msword.png'
+        ),
+
+        // REQUIRED: Location of the AbiWord binary
+        'location' => '/usr/bin/abiword'
     ),
-    'icons' => array(
-        'default' => 'msexcel.png'
-    )
-);
 
-
-/**
- * MS Powerpoint driver settings
- * This driver requires ppthtml, included with xlhtml, to be installed.
- * xlhtml homepage: http://chicago.sourceforge.net/xlhtml/
- */
-$mime_drivers['horde']['mspowerpoint'] = array(
-    'location' => '/usr/bin/ppthtml',
-    'inline' => false,
-    'handles' => array(
-        'application/mspowerpoint',
-        'application/vnd.ms-powerpoint'
+    /* MS Excel display.
+     * This driver requires Gnumeric to be installed.
+     * Gnumeric homepage: http://projects.gnome.org/gnumeric/ */
+    'msexcel' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/msexcel',
+            'application/x-msexcel',
+            'application/vnd.ms-excel'
+        ),
+        'icons' => array(
+            'default' => 'msexcel.png'
+        ),
+
+        // REQUIRED: Location of the ssconvert binary
+        'location' => '/usr/bin/ssconvert'
     ),
-    'icons' => array(
-        'default' => 'mspowerpoint.png'
-    )
-);
 
-
-/**
- * vCard driver settings
- */
-$mime_drivers['horde']['vcard'] = array(
-    'handles' => array(
-        'text/directory',
-        'text/vcard',
-        'text/x-vcard'
+    /* MS Powerpoint display.
+     * This driver requires ppthtml, included with xlhtml, to be installed.
+     * xlhtml homepage: http://chicago.sourceforge.net/xlhtml/ */
+    'mspowerpoint' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/mspowerpoint',
+            'application/vnd.ms-powerpoint'
+        ),
+        'icons' => array(
+            'default' => 'mspowerpoint.png'
+        ),
+
+        // REQUIRED: Location of the ppthtml binary
+        'location' => '/usr/bin/ppthtml'
     ),
-    'icons' => array(
-        'default' => 'vcard.png'
-    )
-);
 
-
-/**
- * RPM driver settings
- */
-$mime_drivers['horde']['rpm'] = array(
-    'location' => '/usr/bin/rpm',
-    'inline' => false,
-    'handles' => array(
-        'application/x-rpm'
+    /* vCard display. */
+    'vcard' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/directory',
+            'text/vcard',
+            'text/x-vcard'
+        ),
+        'icons' => array(
+            'default' => 'vcard.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'rpm.png'
-    )
-);
 
-
-/**
- * Debian package driver settings
- */
-$mime_drivers['horde']['deb'] = array(
-    'location' => '/usr/bin/dpkg',
-    'inline' => false,
-    'handles' => array(
-        'application/x-deb',
-        'application/x-debian-package'
+    /* RPM archive display. */
+    'rpm' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/x-rpm'
+        ),
+        'icons' => array(
+            'default' => 'rpm.png'
+        ),
+
+        // REQUIRED: Location of the rpm binary
+        'location' => '/usr/bin/rpm'
     ),
-    'icons' => array(
-        'default' => 'deb.png'
-    )
-);
 
-
-/**
- * Secure multiparts (RFC 1847)
- */
-$mime_drivers['horde']['security'] = array(
-    'inline' => true,
-    'handles' => array(
-        'multipart/encrypted',
-        'multipart/signed'
+    /* Debian archive display. */
+    'deb' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/x-deb',
+            'application/x-debian-package'
+        ),
+        'icons' => array(
+            'default' => 'deb.png'
+        ),
+
+        // REQUIRED: Location of the dpkg binary
+        'location' => '/usr/bin/dpkg'
     ),
-    'icons' => array(
-        'default' => 'encryption.png'
-    )
-);
 
-
-/**
- * Image settings
- */
-$mime_drivers['horde']['images'] = array(
-    'inline' => false,
-    'handles' => array(
-        'image/*'
+    /* Secure multipart (RFC 1847) display. */
+    'security' => array(
+        'inline' => true,
+        'handles' => array(
+            'multipart/encrypted',
+            'multipart/signed'
+        ),
+        'icons' => array(
+            'default' => 'encryption.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'image.png'
-    )
-);
 
-
-/**
- * MS-TNEF Attachment (application/ms-tnef) settings
- */
-$mime_drivers['horde']['tnef'] = array(
-    'inline' => false,
-    'handles' => array(
-        'application/ms-tnef'
+    /* Image display. */
+    'images' => array(
+        'handles' => array(
+            'image/*'
+        ),
+        'icons' => array(
+            'default' => 'image.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'binary.png'
-    )
-);
 
-
-/**
- * Digest message (RFC 2046 [5.2.1]) settings
- */
-$mime_drivers['horde']['rfc822'] = array(
-    'inline' => false,
-    'handles' => array(
-        'message/rfc822',
-        'x-extension/eml'
+    /* MS-TNEF Attachment display. */
+    'tnef' => array(
+        'handles' => array(
+            'application/ms-tnef'
+        ),
+        'icons' => array(
+            'default' => 'binary.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'mail.png'
-    )
-);
 
-
-/**
- * Report messages (RFC 3452)
- */
-$mime_drivers['horde']['report'] = array(
-    'inline' => true,
-    'handles' => array(
-        'multipart/report'
+    /* Digest message (RFC 2046 [5.2.1]) display. */
+    'rfc822' => array(
+        'handles' => array(
+            'message/rfc822',
+            'x-extension/eml'
+        ),
+        'icons' => array(
+            'default' => 'mail.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'mail.png'
-    )
-);
 
-
-/**
- * OpenOffice.org/StarOffice settings
- */
-$mime_drivers['horde']['ooo'] = array(
-    'inline' => false,
-    'handles' => array(
-        'application/vnd.stardivision.calc',
-        'application/vnd.stardivision.draw',
-        'application/vnd.stardivision.impress',
-        'application/vnd.stardivision.math',
-        'application/vnd.stardivision.writer',
-        'application/vnd.sun.xml.calc',
-        'application/vnd.sun.xml.calc.template',
-        'application/vnd.sun.xml.draw',
-        'application/vnd.sun.xml.draw.template',
-        'application/vnd.sun.xml.impress',
-        'application/vnd.sun.xml.impress.template',
-        'application/vnd.sun.xml.math',
-        'application/vnd.sun.xml.writer',
-        'application/vnd.sun.xml.writer.global',
-        'application/vnd.sun.xml.writer.template',
-        'application/vnd.oasis.opendocument.presentation',
-        'application/vnd.oasis.opendocument.spreadsheet',
-        'application/vnd.oasis.opendocument.text'
+    /* Mail report messages (RFC 3452) display. */
+    'report' => array(
+        'inline' => true,
+        'handles' => array(
+            'multipart/report'
+        ),
+        'icons' => array(
+            'default' => 'mail.png'
+        )
     ),
-    'icons' => array(
-        'default'                                  => 'ooo_calc.png',
-        'application/vnd.stardivision.calc'        => 'ooo_calc.png',
-        'application/vnd.stardivision.draw'        => 'ooo_draw.png',
-        'application/vnd.stardivision.impress'     => 'ooo_impress.png',
-        'application/vnd.stardivision.math'        => 'ooo_math.png',
-        'application/vnd.stardivision.writer'      => 'ooo_writer.png',
-        'application/vnd.sun.xml.calc'             => 'ooo_calc.png',
-        'application/vnd.sun.xml.calc.template'    => 'ooo_calc.png',
-        'application/vnd.sun.xml.draw'             => 'ooo_draw.png',
-        'application/vnd.sun.xml.draw.template'    => 'ooo_draw.png',
-        'application/vnd.sun.xml.impress'          => 'ooo_impress.png',
-        'application/vnd.sun.xml.impress.template' => 'ooo_impress.png',
-        'application/vnd.sun.xml.math'             => 'ooo_math.png',
-        'application/vnd.sun.xml.writer'           => 'ooo_writer.png',
-        'application/vnd.sun.xml.writer.global'    => 'ooo_writer.png',
-        'application/vnd.sun.xml.writer.template'  => 'ooo_writer.png',
-        'application/vnd.oasis.opendocument.presentation' => 'ooo_impress.png',
-        'application/vnd.oasis.opendocument.spreadsheet'  => 'ooo_calc.png',
-        'application/vnd.oasis.opendocument.text'         => 'ooo_writer.png'
-    )
-);
 
-
-/**
- * Portable Document Format (PDF) files
- */
-$mime_drivers['horde']['pdf'] = array(
-    /* This setting is irrelevant - PDF files can not be displayed inline. */
-    'inline' => false,
-    'handles' => array(
-        'application/pdf',
-        'application/x-pdf',
-        'image/pdf'
+    /* OpenOffice.org/StarOffice document display. */
+    'ooo' => array(
+        'handles' => array(
+            'application/vnd.stardivision.calc',
+            'application/vnd.stardivision.draw',
+            'application/vnd.stardivision.impress',
+            'application/vnd.stardivision.math',
+            'application/vnd.stardivision.writer',
+            'application/vnd.sun.xml.calc',
+            'application/vnd.sun.xml.calc.template',
+            'application/vnd.sun.xml.draw',
+            'application/vnd.sun.xml.draw.template',
+            'application/vnd.sun.xml.impress',
+            'application/vnd.sun.xml.impress.template',
+            'application/vnd.sun.xml.math',
+            'application/vnd.sun.xml.writer',
+            'application/vnd.sun.xml.writer.global',
+            'application/vnd.sun.xml.writer.template',
+            'application/vnd.oasis.opendocument.presentation',
+            'application/vnd.oasis.opendocument.spreadsheet',
+            'application/vnd.oasis.opendocument.text'
+            ),
+        'icons' => array(
+            'default'                                  => 'ooo_calc.png',
+            'application/vnd.stardivision.calc'        => 'ooo_calc.png',
+            'application/vnd.stardivision.draw'        => 'ooo_draw.png',
+            'application/vnd.stardivision.impress'     => 'ooo_impress.png',
+            'application/vnd.stardivision.math'        => 'ooo_math.png',
+            'application/vnd.stardivision.writer'      => 'ooo_writer.png',
+            'application/vnd.sun.xml.calc'             => 'ooo_calc.png',
+            'application/vnd.sun.xml.calc.template'    => 'ooo_calc.png',
+            'application/vnd.sun.xml.draw'             => 'ooo_draw.png',
+            'application/vnd.sun.xml.draw.template'    => 'ooo_draw.png',
+            'application/vnd.sun.xml.impress'          => 'ooo_impress.png',
+            'application/vnd.sun.xml.impress.template' => 'ooo_impress.png',
+            'application/vnd.sun.xml.math'             => 'ooo_math.png',
+            'application/vnd.sun.xml.writer'           => 'ooo_writer.png',
+            'application/vnd.sun.xml.writer.global'    => 'ooo_writer.png',
+            'application/vnd.sun.xml.writer.template'  => 'ooo_writer.png',
+            'application/vnd.oasis.opendocument.presentation' => 'ooo_impress.png',
+            'application/vnd.oasis.opendocument.spreadsheet'  => 'ooo_calc.png',
+            'application/vnd.oasis.opendocument.text'         => 'ooo_writer.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'pdf.png'
-    )
-);
 
-
-/**
- * RTF driver settings
- * This driver requires UnRTF to be installed.
- * UnRTF homepage: http://www.gnu.org/software/unrtf/unrtf.html
- */
-$mime_drivers['horde']['rtf'] = array(
-    'location' => '/usr/bin/unrtf',
-    'inline' => false,
-    'handles' => array(
-        'application/rtf',
-        'text/rtf'
+    /* Portable Document Format (PDF) display. */
+    'pdf' => array(
+        'handles' => array(
+            'application/pdf',
+            'application/x-pdf',
+            'image/pdf'
+        ),
+        'icons' => array(
+            'default' => 'pdf.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'text.png'
-    )
-);
 
-
-/**
- * WordPerfect driver settings
- * This driver requires wpd2html to be installed.
- * libwpd homepage: http://libwpd.sourceforge.net/
- */
-$mime_drivers['horde']['wordperfect'] = array(
-    'location' => '/usr/bin/wpd2html',
-    'inline' => false,
-    'handles' => array(
-        'application/vnd.wordperfect',
-        'application/wordperf',
-        'application/wordperfect',
-        'application/wpd',
-        'application/x-wpwin'
+    /* RTF display.
+     * This driver requires UnRTF to be installed.
+     * UnRTF homepage: http://www.gnu.org/software/unrtf/unrtf.html */
+    'rtf' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/rtf',
+            'text/rtf'
+        ),
+        'icons' => array(
+            'default' => 'text.png'
+        ),
+
+        // REQUIRED: location of the unrtf binary
+        'location' => '/usr/bin/unrtf'
     ),
-    'icons' => array(
-        'default' => 'wordperfect.png'
+
+    /* WordPerfect document display.
+     * This driver requires wpd2html to be installed.
+     * libwpd homepage: http://libwpd.sourceforge.net/ */
+    'wordperfect' => array(
+        // Disabled by default
+        'disable' => true,
+        'handles' => array(
+            'application/vnd.wordperfect',
+            'application/wordperf',
+            'application/wordperfect',
+            'application/wpd',
+            'application/x-wpwin'
+        ),
+        'icons' => array(
+            'default' => 'wordperfect.png'
+        ),
+
+        // REQUIRED: location of the wpd2html binary
+        'location' => '/usr/bin/wpd2html'
     )
 );
index a2240a9..bba5669 100644 (file)
@@ -39,6 +39,8 @@ The following hooks have changed:
     * username_tobackend, username_frombackend (combined and renamed to
       authusername).
 
+The format for the config/mime_drivers.php configuration files has changed.
+
 Horde_Alarm is using UTC dates now.
 
 Crypt_Blowfish is required.
index d724f2f..2247827 100644 (file)
@@ -1003,13 +1003,14 @@ if ($redirect) {
         $t->set('numberattach', $imp_compose->numberOfAttachments());
         if ($t->get('numberattach')) {
             $atc = array();
+            $v = $injector->getInstance('Horde_Mime_Viewer');
             foreach ($imp_compose->getAttachments() as $atc_num => $data) {
                 $mime = $data['part'];
                 $type = $mime->getType();
 
                 $entry = array(
                     'name' => $mime->getName(true),
-                    'icon' => Horde_Mime_Viewer::getIcon($type),
+                    'icon' => $v->getIcon($type),
                     'number' => $atc_num,
                     'type' => $type,
                     'size' => $mime->getSize(),
index 013ef97..7a357e2 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
- * Decide which output drivers you want to activate for the IMP application.
+ * MIME Viewer configuration for IMP.
+ *
  * Settings in this file override settings in horde/config/mime_drivers.php.
  * All drivers configured in that file, but not configured here, will also
  * be used to display MIME content.
  * $Id$
  */
 
-/**
- * The available drivers are:
- * --------------------------
- * alternative    multipart/alternative parts
- * appledouble    multipart/appledouble parts
- * enriched       Enriched text messages
- * html           HTML messages
- * images         Images
- * itip           iCalendar Transport-Independent Interoperability Protocol
- * mdn            Message disposition notification messages
- * partial        message/partial parts
- * pdf            Portable Document Format (PDF) files
- * pgp            PGP signed/encrypted messages
- * plain          URL syntax highlighting for text/plain parts
- * related        multipart/related parts
- * rfc822         Digested messages (RFC 2046 [5.2.1])
- * smil           SMIL documents
- * smime          S/MIME signed/encrypted messages
- * status         Mail delivery status messages
- * tnef           MS-TNEF attachments
- * vcard          vCards
- * zip            ZIP attachments
- */
-$mime_drivers_map['imp']['registered'] = array(
-    'alternative', 'appledouble', 'enriched', 'html', 'images', 'itip',
-    'mdn', 'partial', 'pdf', 'pgp', 'plain', 'related', 'rfc822', 'smil',
-    'smime', 'status', 'tnef', 'vcard', 'zip'
-);
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here.  Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
- */
-$mime_drivers_map['imp']['overrides'] = array();
-
-/**
- * Driver specific settings. See horde/config/mime_drivers.php for
- * the format.
- */
-
-/**
- * Text driver settings
- */
-$mime_drivers['imp']['plain'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/plain', 'text/rfc822-headers', 'application/pgp'
+$mime_drivers = array(
+    /* Plain text viewer. */
+    'plain' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/pgp',
+            'text/plain',
+            'text/rfc822-headers'
+        ),
+
+        /* If you want to limit the display of message data inline for large
+         * messages, set the maximum size of the displayed message here (in
+         * bytes).  If exceeded, the user will only be able to download the
+         * part. Set to 0 to disable this check. */
+        'limit_inline_size' => 1048576,
+
+        /* If you want to scan ALL incoming text/plain messages for UUencoded
+         * data, set the following to true. This is very performance intensive
+         * and can take a long time for large messages. It is not recommended
+         * (as UUencoded data is rare these days) and is disabled by
+         * default. */
+        'uudecode' => false
     ),
-    /* If you want to limit the display of message data inline for large
-     * messages, set the maximum size of the displayed message here (in
-     * bytes).  If exceeded, the user will only be able to download the part.
-     * Set to 0 to disable this check. */
-    'limit_inline_size' => 1048576,
-    /* If you want to scan ALL incoming text/plain messages for UUencoded
-     * data, set the following to true. This is very performance intensive and
-     * can take a long time for large messages. It is not recommended (as
-     * UUencoded data is very rare anymore) and is disabled by default. */
-    'uudecode' => false
-);
 
-/**
- * HTML driver settings
- */
-$mime_drivers['imp']['html'] = array(
-    /* NOTE: Inline HTML display is turned OFF by default. */
-    'inline' => false,
-    'handles' => array(
-        'text/html'
+    /* HTML driver settings */
+    'html' => array(
+        /* NOTE: Inline HTML display is turned OFF by default. */
+        'inline' => false,
+        'handles' => array(
+            'text/html'
+        ),
+        'icons' => array(
+            'default' => 'html.png'
+        ),
+
+        /* If you want to limit the display of message data inline for large
+         * messages, set the maximum size of the displayed message here (in
+         * bytes).  If exceeded, the user will only be able to download the
+         * part. Set to 0 to disable this check. */
+        'limit_inline_size' => 1048576,
+
+        /* Check for phishing exploits? */
+        'phishing_check' => true,
+
+        /* A list of from e-mail addresses that are considered "safe" for
+         * purposes of image blocking (if image blocking is enabled in the
+         * preferences). */
+        'safe_addrs' => array()
     ),
-    'icons' => array(
-        'default' => 'html.png'
+
+    /* Default smil driver. */
+    'smil' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/smil'
+        )
     ),
-    /* If you want to limit the display of message data inline for large
-     * messages, set the maximum size of the displayed message here (in
-     * bytes).  If exceeded, the user will only be able to download the part.
-     * Set to 0 to disable this check. */
-    'limit_inline_size' => 1048576,
-    /* Check for phishing exploits? */
-    'phishing_check' => true,
-    /* A list of from e-mail addresses that are considered "safe" for purposes
-     * of image blocking (if enabled). */
-    'safe_addrs' => array()
-);
 
-/**
- * Default smil driver settings
- */
-$mime_drivers['imp']['smil'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/smil'
-    )
-);
+    /* Image display. */
+    'images' => array(
+        'inline' => true,
+        'handles' => array(
+            'image/*'
+        ),
 
-/**
- * Image driver settings
- */
-$mime_drivers['imp']['images'] = array(
-    'inline' => true,
-    'handles' => array(
-        'image/*'
-    ),
-    /* Display thumbnails for all images, not just large images? */
-    'allthumbs' => true,
-    /* Display images inline that are less than this size (in bytes). */
-    'inlinesize' => 262144
-);
+        /* Display thumbnails for all images, not just large images? */
+        'allthumbs' => true,
 
-/**
- * Enriched text driver settings
- */
-$mime_drivers['imp']['enriched'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/enriched'
+        /* Display images inline that are less than this size (in bytes). */
+        'inlinesize' => 262144
     ),
-    'icons' => array(
-        'default' => 'text.png'
-    )
-);
 
-/**
- * PDF settings
- */
-$mime_drivers['imp']['pdf'] = array(
-    'inline' => false,
-    'handles' => array(
-        'application/pdf', 'application/x-pdf', 'image/pdf'
+    /* Enriched text display. */
+    'enriched' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/enriched'
+        ),
+        'icons' => array(
+            'default' => 'text.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'pdf.png'
-    )
-);
 
-/**
- * PGP settings
- */
-$mime_drivers['imp']['pgp'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/pgp-encrypted', 'application/pgp-keys',
-        'application/pgp-signature'
+    /* PDF display. */
+    'pdf' => array(
+        'handles' => array(
+            'application/pdf',
+            'application/x-pdf',
+            'image/pdf'
+        ),
+        'icons' => array(
+            'default' => 'pdf.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'encryption.png'
-    )
-);
 
-/**
- * S/MIME settings
- */
-$mime_drivers['imp']['smime'] = array(
-    'inline' => true,
-    'handles' => array(
-        'application/x-pkcs7-signature', 'application/x-pkcs7-mime',
-        'application/pkcs7-signature', 'application/pkcs7-mime'
+    /* PGP (Pretty Good Privacy) display. */
+    'pgp' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/pgp-encrypted',
+            'application/pgp-keys',
+            'application/pgp-signature'
+        ),
+        'icons' => array(
+            'default' => 'encryption.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'encryption.png'
-    )
-);
 
-/**
- * vCard driver settings
- */
-$mime_drivers['imp']['vcard'] = array(
-    'handles' => array(
-        'text/vcard', 'text/x-vcard', 'text/directory'
+    /* S/MIME display. */
+    'smime' => array(
+        'inline' => true,
+        'handles' => array(
+            'application/x-pkcs7-signature',
+            'application/x-pkcs7-mime',
+            'application/pkcs7-signature',
+            'application/pkcs7-mime'
+        ),
+        'icons' => array(
+            'default' => 'encryption.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'vcard.png'
-    )
-);
 
-/**
- * Zip File Attachments settings
- */
-$mime_drivers['imp']['zip'] = array(
-    'inline' => false,
-    'handles' => array(
-        'application/zip', 'application/x-compressed',
-        'application/x-zip-compressed'
+    /* vCard display. */
+    'vcard' => array(
+        'handles' => array(
+            'text/directory',
+            'text/vcard',
+            'text/x-vcard'
+        ),
+        'icons' => array(
+            'default' => 'vcard.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'compressed.png'
-    )
-);
 
-/**
- * Delivery Status messages settings
- */
-$mime_drivers['imp']['status'] = array(
-    'inline' => true,
-    'handles' => array(
-        'message/delivery-status'
-    )
-);
+    /* Zip file display. */
+    'zip' => array(
+        'handles' => array(
+            'application/x-compressed',
+            'application/x-zip-compressed',
+            'application/zip'
+        ),
+        'icons' => array(
+            'default' => 'compressed.png'
+        )
+    ),
 
-/**
- * Disposition Notification message settings
- */
-$mime_drivers['imp']['mdn'] = array(
-    'inline' => true,
-    'handles' => array(
-        'message/disposition-notification'
-    )
-);
+    /* Delivery status messages display. */
+    'status' => array(
+        'inline' => true,
+        'handles' => array(
+            'message/delivery-status'
+        )
+    ),
 
-/**
- * multipart/appledouble settings
- */
-$mime_drivers['imp']['appledouble'] = array(
-    'inline' => true,
-    'handles' => array(
-        'multipart/appledouble'
+    /* Message Disposition Notification (MDN) display. */
+    'mdn' => array(
+        'inline' => true,
+        'handles' => array(
+            'message/disposition-notification'
+        )
     ),
-    'icons' => array(
-        'default' => 'apple.png'
-    )
-);
 
-/**
- * iCalendar Transport-Independent Interoperability Protocol
- */
-$mime_drivers['imp']['itip'] = array(
-    'inline' => true,
-    'handles' => array(
-        'text/calendar', 'text/x-vcalendar'
+    /* Appledouble message display. */
+    'appledouble' => array(
+        'inline' => true,
+        'handles' => array(
+            'multipart/appledouble'
+        ),
+        'icons' => array(
+            'default' => 'apple.png'
+        )
     ),
-    'icons' => array(
-        'default' => 'itip.png'
-    )
-);
 
-/**
- * multipart/alternative settings
- */
-$mime_drivers['imp']['alternative'] = array(
-    /* The 'inline' setting should normally not be changed. */
-    'inline' => true,
-    'handles' => array(
-        'multipart/alternative'
-    )
-);
+    /* ITIP (iCalendar Transport-Independent Interoperability Protocol)
+     * display. */
+    'itip' => array(
+        'inline' => true,
+        'handles' => array(
+            'text/calendar',
+            'text/x-vcalendar'
+        ),
+        'icons' => array(
+            'default' => 'itip.png'
+        )
+    ),
 
-/**
- * multipart/related settings
- * YOU SHOULD NOT NORMALLY ALTER THIS SETTING.
- */
-$mime_drivers['imp']['related'] = array(
-    'inline' => true,
-    'handles' => array(
-        'multipart/related'
+    /* Alternative part display.
+     * YOU SHOULD NOT NORMALLY ALTER THIS SETTING. */
+    'alternative' => array(
+        'inline' => true,
+        'handles' => array(
+            'multipart/alternative'
+        )
     ),
-    'icons' => array(
-        'default' => 'html.png'
-    )
-);
 
-/**
- * message/partial settings
- * YOU SHOULD NOT NORMALLY ALTER THIS SETTING.
- */
-$mime_drivers['imp']['partial'] = array(
-    'handles' => array(
-        'message/partial'
-    )
-);
+    /* Related part display.
+     * YOU SHOULD NOT NORMALLY ALTER THIS SETTING. */
+    'related' => array(
+        'inline' => true,
+        'handles' => array(
+            'multipart/related'
+        ),
+        'icons' => array(
+            'default' => 'html.png'
+        )
+    ),
 
-/**
- * Digest message (RFC 2046 [5.2.1]) settings
- * YOU SHOULD NOT NORMALLY ALTER THIS SETTING.
- */
-$mime_drivers['imp']['rfc822'] = array(
-    'inline' => false,
-    'handles' => array(
-        'message/rfc822', 'x-extension/eml'
-    )
-);
+    /* Partial parts display.
+     * YOU SHOULD NOT NORMALLY ALTER THIS SETTING. */
+    'partial' => array(
+        'handles' => array(
+            'message/partial'
+        )
+    ),
 
-/**
- * MS-TNEF Attachment (application/ms-tnef) settings
- * YOU SHOULD NOT NORMALLY ALTER THIS SETTING.
- */
-$mime_drivers['imp']['tnef'] = array(
-    'inline' => false,
-    'handles' => array(
-        'application/ms-tnef'
+    /* Digest message (RFC 2046 [5.2.1]) display.
+     * YOU SHOULD NOT NORMALLY ALTER THIS SETTING. */
+    'rfc822' => array(
+        'handles' => array(
+            'message/rfc822',
+            'x-extension/eml'
+        )
     ),
-    'icons' => array(
-        'default' => 'binary.png'
+
+    /* MS-TNEF Attachment display.
+     * YOU SHOULD NOT NORMALLY ALTER THIS SETTING. */
+    'tnef' => array(
+        'inline' => false,
+        'handles' => array(
+            'application/ms-tnef'
+        ),
+        'icons' => array(
+            'default' => 'binary.png'
+        )
     )
 );
index 7856a6c..ef1f7e4 100644 (file)
@@ -101,6 +101,7 @@ class IMP_Application extends Horde_Registry_Application
             'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
             'IMP_Mail' => new IMP_Injector_Binder_Mail(),
             'IMP_Mailbox' => new IMP_Injector_Binder_Mailbox(),
+            'IMP_Mime_Viewer' => new IMP_Injector_Binder_MimeViewer(),
             'IMP_Quota' => new IMP_Injector_Binder_Quota(),
             'IMP_Search' => new IMP_Injector_Binder_Search(),
             'IMP_Sentmail' => new IMP_Injector_Binder_Sentmail()
index bc9f016..ad3ce2a 100644 (file)
@@ -38,6 +38,7 @@ class IMP_Contents
     const RENDER_INFO = 8;
     const RENDER_INLINE_AUTO = 16;
     const RENDER_RAW = 32;
+    const RENDER_RAW_FALLBACK = 64;
 
     /**
      * Flag to indicate whether the last call to getBodypart() returned
@@ -348,9 +349,6 @@ class IMP_Contents
      * @param array $options   Additional options:
      * <pre>
      * 'mime_part' - (Horde_Mime_Part) The MIME part to render.
-     * '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>
@@ -375,14 +373,10 @@ class IMP_Contents
             ? $this->getMIMEPart($mime_id)
             : $options['mime_part'];
         $type = empty($options['type'])
-            ? $mime_part->getType()
+            ? null
             : $options['type'];
 
-        $viewer = Horde_Mime_Viewer::factory($mime_part, $type);
-        $viewer->setParams(array('contents' => $this));
-        if (!empty($options['params'])) {
-            $viewer->setParams($options['params']);
-        }
+        $viewer = $GLOBALS['injector']->getInstance('IMP_Mime_Viewer')->getViewer($mime_part, $this, $type);
 
         switch ($mode) {
         case self::RENDER_FULL:
@@ -430,6 +424,12 @@ class IMP_Contents
         case self::RENDER_RAW:
             $textmode = 'raw';
             break;
+
+        case self::RENDER_RAW_FALLBACK:
+            $textmode = $viewer->canRender('raw')
+                ? 'raw'
+                : 'full';
+            break;
         }
 
         $ret = $viewer->render($textmode);
@@ -625,7 +625,7 @@ class IMP_Contents
         }
 
         /* Get part's icon. */
-        $part['icon'] = ($mask & self::SUMMARY_ICON) ? Horde::img(Horde_Mime_Viewer::getIcon($mime_type), '', array('title' => $mime_type), '') : null;
+        $part['icon'] = ($mask & self::SUMMARY_ICON) ? Horde::img($GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getIcon($mime_type), '', array('title' => $mime_type), '') : null;
 
         /* Get part's description. */
         $description = $mime_part->getDescription(true);
@@ -658,7 +658,7 @@ class IMP_Contents
         if ($is_atc &&
             $download_zip &&
             ($part['bytes'] > 204800)) {
-            $viewer = Horde_Mime_Viewer::factory($mime_part, $mime_type);
+            $viewer = $GLOBALS['injector']->getInstance('IMP_Mime_Viewer')->getViewer($mime_part, $this, $mime_type);
             if (!$viewer->getMetadata('compressed')) {
                 $part['download_zip'] = $this->linkView($mime_part, 'download_attach', null, array('class' => 'downloadZipAtc', 'dload' => true, 'jstext' => sprintf(_("Download %s in .zip Format"), $mime_part->getDescription(true)), 'params' => array('zip' => 1)));
             }
@@ -871,11 +871,10 @@ class IMP_Contents
             $last_id = null;
 
             $mime_part = $this->getMIMEPart($id, array('nocontents' => true));
-            $viewer = Horde_Mime_Viewer::factory($mime_part);
+            $viewer = $GLOBALS['injector']->getInstance('IMP_Mime_Viewer')->getViewer($mime_part, $this);
             if ($viewer->embeddedMimeParts()) {
                 $mime_part = $this->getMIMEPart($id);
                 $viewer->setMIMEPart($mime_part);
-                $viewer->setParams(array('contents' => $this));
                 $new_part = $viewer->getEmbeddedMimeParts();
                 if (!is_null($new_part)) {
                     $this->_embedded[] = $id;
@@ -907,7 +906,7 @@ class IMP_Contents
         if (!is_object($part)) {
             $part = $this->getMIMEPart($part, array('nocontents' => true));
         }
-        $viewer = Horde_Mime_Viewer::factory($part, $type);
+        $viewer = $GLOBALS['injector']->getInstance('IMP_Mime_Viewer')->getViewer($part, $this, $type);
 
         if ($mask & self::RENDER_INLINE_AUTO) {
             $mask |= self::RENDER_INLINE | self::RENDER_INFO;
@@ -1018,4 +1017,27 @@ class IMP_Contents
         return false;
     }
 
+    /**
+     * Find a MIME type in parent parts.
+     *
+     * @param string $id    The MIME ID to begin the search at.
+     * @param string $type  The MIME type to search for.
+     *
+     * @return mixed  Either the requested MIME part, or null if not found.
+     */
+    public function findMimeType($id, $type)
+    {
+        $id = Horde_Mime::mimeIdArithmetic($id, 'up');
+
+        while (!is_null($id)) {
+            if (($part = $this->getMIMEPart($id, array('nocontents' => true))) &&
+                ($part->getType() == $type)) {
+                return $part;
+            }
+            $id = Horde_Mime::mimeIdArithmetic($id, 'up');
+        }
+
+        return null;
+    }
+
 }
diff --git a/imp/lib/Injector/Binder/MimeViewer.php b/imp/lib/Injector/Binder/MimeViewer.php
new file mode 100644 (file)
index 0000000..f9eb0a1
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Binder for the Horde_Mime_Viewer which includes support for the IMP
+ * drivers.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  IMP
+ */
+class IMP_Injector_Binder_MimeViewer implements Horde_Injector_Binder
+{
+    /**
+     */
+    public function create(Horde_Injector $injector)
+    {
+        return new IMP_Injector_Factory_MimeViewer($injector);
+    }
+
+    /**
+     */
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+
+}
diff --git a/imp/lib/Injector/Factory/MimeViewer.php b/imp/lib/Injector/Factory/MimeViewer.php
new file mode 100644 (file)
index 0000000..7add9a4
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  IMP
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @link     http://pear.horde.org/index.php?package=IMP
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @category Horde
+ * @package  IMP
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @link     http://pear.horde.org/index.php?package=IMP
+ */
+class IMP_Injector_Factory_MimeViewer
+{
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Attempts to return a concrete Horde_Mime_Viewer object based on the
+     * MIME type.
+     *
+     * @param Horde_Mime_Part $mime   An object with the data to be rendered.
+     * @param IMP_Contents $contents  The IMP_Contents object associated with
+     *                                $mime.
+     * @param string $type            The MIME type to use for loading.
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created instance.
+     * @throws Horde_Mime_Viewer_Exception
+     */
+    public function getViewer(Horde_Mime_Part $mime,
+                              IMP_Contents $contents = null,
+                              $type = null)
+    {
+        list($driver, $params) = $this->_injector->getInstance('Horde_Mime_Viewer')->getViewerConfig($type ? $type : $mime->getType(), 'imp');
+
+        switch ($driver) {
+        case 'Report':
+        case 'Security':
+            $params['viewer_callback'] = array($this, 'getViewerCallback');
+            break;
+        }
+
+        $params['imp_contents'] = $contents;
+
+        return Horde_Mime_Viewer::factory($driver, $mime, $params);
+    }
+
+    /**
+     * Callback used to return a MIME Viewer object from within certain
+     * Viewer drivers.
+     *
+     * @param Horde_Mime_Viewer_Base $viewer  The MIME Viewer driver
+     *                                        requesting the new object.
+     * @param Horde_Mime_Part $mime           An object with the data to be
+     *                                        rendered.
+     * @param string $type                    The MIME type to use for
+     *                                        rendering.
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created instance.
+     * @throws Horde_Mime_Viewer_Exception
+     */
+    public function getViewerCallback(Horde_Mime_Viewer_Base $viewer,
+                                      Horde_Mime_Part $mime, $type)
+    {
+        return $this->getViewer($mime, $viewer->getConfigParam('imp_contents'), $type);
+    }
+
+}
index b65797b..f5f42b9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Alternative class renders out messages from
+ * The IMP_Mime_Viewer_Alternative class renders out messages from
  * multipart/alternative content types (RFC 2046 [5.1.4]).
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -85,7 +85,7 @@ class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base
         foreach ($subparts as $mime_id => $type) {
             $ret[$mime_id] = null;
             if ((strcmp($base_id, $mime_id) !== 0) &&
-                $this->_params['contents']->canDisplay($mime_id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL)) {
+                $this->getConfigParam('imp_contents')->canDisplay($mime_id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL)) {
                 if (!$is_mimp ||
                     !$prefer_plain ||
                     ($type == 'text/plain')) {
@@ -107,7 +107,7 @@ class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base
                         'type' => 'info'
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             );
             return $ret;
         }
@@ -128,7 +128,7 @@ class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base
         $render_part = $this->_mimepart->getPart($disp_id);
         foreach (array_keys($render_part->contentTypeMap()) as $val) {
             if (isset($display_ids[$val])) {
-                $render = $this->_params['contents']->renderMIMEPart($val, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL, array('params' => $this->_params));
+                $render = $this->getConfigParam('imp_contents')->renderMIMEPart($val, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL);
                 foreach (array_keys($render) as $id) {
                     unset($display_ids[$id]);
                     if (!$inline) {
@@ -155,4 +155,5 @@ class IMP_Horde_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base
             ? $ret
             : null;
     }
+
 }
index 26221a0..1fd2940 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Appledouble class handles multipart/appledouble
+ * The IMP_Mime_Viewer_Appledouble class handles multipart/appledouble
  * messages conforming to RFC 1740.
  *
  * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Appledouble extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Appledouble extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -92,14 +92,14 @@ class IMP_Horde_Mime_Viewer_Appledouble extends Horde_Mime_Viewer_Base
             'icon' => Horde::img('mime/apple.png', _("Macintosh File")),
             'text' => array(
                 sprintf(_("This message contains a Macintosh file (named \"%s\")."), $data_name),
-                sprintf(_("The Macintosh resource fork can be downloaded %s."), $this->_params['contents']->linkViewJS($applefile_part, 'download_attach', _("HERE"), array('jstext' => _("The Macintosh resource fork"))))
+                sprintf(_("The Macintosh resource fork can be downloaded %s."), $this->getConfigParam('imp_contents')->linkViewJS($applefile_part, 'download_attach', _("HERE"), array('jstext' => _("The Macintosh resource fork"))))
             )
         );
 
         /* For inline viewing, attempt to display the data inline. */
         $ret = array();
-        if ($inline && (($disp = $this->_params['contents']->canDisplay($data_part, IMP_Contents::RENDER_INLINE | IMP_Contents::RENDER_INFO)))) {
-            $ret = $this->_params['contents']->renderMIMEPart($data_id, $disp, array('params' => $this->_params));
+        if ($inline && (($disp = $this->getConfigParam('imp_contents')->canDisplay($data_part, IMP_Contents::RENDER_INLINE | IMP_Contents::RENDER_INFO)))) {
+            $ret = $this->getConfigParam('imp_contents')->renderMIMEPart($data_id, $disp);
         }
 
         foreach ($parts_list as $val) {
@@ -108,7 +108,7 @@ class IMP_Horde_Mime_Viewer_Appledouble extends Horde_Mime_Viewer_Base
                     ? array(
                           'data' => '',
                           'status' => array($status),
-                          'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset(),
+                          'type' => 'text/html; charset=' . $this->getConfigParam('charset'),
                           'wrap' => 'mimePartWrap'
                       )
                     : null;
@@ -119,4 +119,5 @@ class IMP_Horde_Mime_Viewer_Appledouble extends Horde_Mime_Viewer_Base
 
         return $ret;
     }
+
 }
index a9d8e68..7b0d9a9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Enriched class renders out plain text from
+ * The IMP_Mime_Viewer_Enriched class renders out plain text from
  * enriched content tags, ala RFC 1896
  *
  * Copyright 2001-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Enriched
+class IMP_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Enriched
 {
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
index ce37b57..bf91ca8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Html class renders out HTML text with an effort
+ * The IMP_Mime_Viewer_Html class renders out HTML text with an effort
  * to remove potentially malicious code.
  *
  * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
@@ -15,7 +15,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
+class IMP_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
 {
     /**
      * Temp array for storing data when parsing the HTML document.
@@ -57,7 +57,7 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
     {
         /* Non-javascript browsers can't handle IFRAME resizing, so it isn't
          * possible to view inline. */
-        if (!$GLOBALS['browser']->hasFeature('javascript')) {
+        if (!$this->getConfigParam('browser')->hasFeature('javascript')) {
             return array(
                 $this->_mimepart->getMimeId() => array(
                     'data' => '',
@@ -66,11 +66,11 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
                             'icon' => Horde::img('mime/html.png'),
                             'text' => array(
                                 _("This message part contains HTML data, but this data can not be displayed inline."),
-                                $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View HTML data in new window.")),
+                                $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("View HTML data in new window.")),
                             )
                         )
                     ),
-                    'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                    'type' => 'text/html; charset=' . $this->getConfigParam('charset')
                 )
             );
         }
@@ -113,12 +113,12 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
                         'icon' => Horde::img('mime/html.png', _("HTML data")),
                         'text' => array(
                             _("This message part contains HTML data, but inline HTML display is disabled."),
-                            $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View HTML data in new window.")),
-                            $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("Convert HTML data to plain text and view in new window."), array('params' => array('convert_text' => 1)))
+                            $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("View HTML data in new window.")),
+                            $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("Convert HTML data to plain text and view in new window."), array('params' => array('convert_text' => 1)))
                         )
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
@@ -156,10 +156,10 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
 
             /* Search for inlined images that we can display
              * (multipart/related parts) - see RFC 2392. */
-            if (isset($this->_params['related_id'])) {
+            if ($related_part = $this->getConfigParam('imp_contents')->findMimeType($this->_mimepart->getMimeId(), 'multipart/related')) {
                 $cid_replace = array();
 
-                foreach ($this->_params['related_cids'] as $mime_id => $cid) {
+                foreach ($related_part->getMetadata('related_cids') as $mime_id => $cid) {
                     if ($cid = trim($cid, '<>')) {
                         $cid_replace['cid:' . $cid] = $mime_id;
                     }
@@ -191,13 +191,15 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
         /* We are done processing if in mimp mode, or we are converting to
          * text. */
         if (is_null($this->_imptmp)) {
-            $data = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($data, 'Html2text', array('wrap' => false));
+            $data = $this->_textFilter($data, 'Html2text', array(
+                'wrap' => false
+            ));
 
             // Filter bad language.
             return array(
                 'data' => IMP::filterText($data),
                 'status' => array(),
-                'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/plain; charset=' . $this->getConfigParam('charset')
             );
         }
 
@@ -223,7 +225,7 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
         }
 
         if (!empty($filters)) {
-            $data = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($data, array_keys($filters), array(array_values($filters)));
+            $data = $this->_textFilter($data, array_keys($filters), array(array_values($filters)));
         }
 
         /* Filter bad language. */
@@ -243,11 +245,11 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
      */
     protected function _inAddressBook()
     {
-        if (empty($this->_params['contents'])) {
+        if (!$this->getConfigParam('imp_contents')) {
             return false;
         }
 
-        $from = Horde_Mime_Address::bareAddress($this->_params['contents']->getHeaderOb()->getValue('from'));
+        $from = Horde_Mime_Address::bareAddress($this->getConfigParam('imp_contents')->getHeaderOb()->getValue('from'));
 
         if ($GLOBALS['prefs']->getValue('html_image_addrbook') &&
             $GLOBALS['registry']->hasMethod('contacts/getField')) {
@@ -305,9 +307,9 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
                     if (($tag == 'img') &&
                         $this->_imptmp['cid'] &&
                         isset($this->_imptmp['cid'][$val])) {
-                        $val = $this->_params['contents']->urlView(null, 'view_attach', array('params' => array(
+                        $val = $this->getConfigParam('imp_contents')->urlView(null, 'view_attach', array('params' => array(
                             'id' => $this->_imptmp['cid'][$val],
-                            'related_data' => 1
+                            'imp_img_view' => 'data'
                         )));
                         $node->setAttribute('src', $val);
                     }
index 8cf3d0d..f14baa0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Images class allows display of images attached
+ * The IMP_Mime_Viewer_Images class allows display of images attached
  * to a message.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
+class IMP_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
 {
     /**
      * This driver's display capabilities.
@@ -24,7 +24,7 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
         'full' => true,
         'info' => true,
         'inline' => true,
-        'raw' => false
+        'raw' => true
     );
 
     /**
@@ -44,10 +44,6 @@ 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') ||
-            !empty($this->_params['raw'])) {
-            $view = 'data';
-        }
 
         switch ($view) {
         case 'data':
@@ -93,7 +89,7 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
                     $this->_mimepart->getMimeId() => array(
                         'data' => $this->_outputImgTag('data', $this->_mimepart->getName(true)),
                         'status' => array(),
-                        'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                        'type' => 'text/html; charset=' . $this->getConfigParam('charset')
                     )
                 );
             } else {
@@ -110,7 +106,7 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
             $img = $this->_getHordeImageOb(false);
             if ($img &&
                 $GLOBALS['browser']->isViewable($img->getContentType())) {
-                $convert_link = $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("HERE"), array('params' => array('imp_img_view' => 'load_convert')));
+                $convert_link = $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("HERE"), array('params' => array('imp_img_view' => 'load_convert')));
                 $status[] = sprintf(_("Click %s to convert the image file into a format your browser can attempt to view."), $convert_link);
             }
         }
@@ -123,7 +119,7 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
                         'text' => $status
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
@@ -147,9 +143,9 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
         $status = array(_("This is a thumbnail of an image attached to this message."));
 
         if ($GLOBALS['browser']->hasFeature('javascript')) {
-            $status[] = $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', $this->_outputImgTag('view_thumbnail', _("View Attachment")), null, null, null);
+            $status[] = $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', $this->_outputImgTag('view_thumbnail', _("View Attachment")), null, null, null);
         } else {
-            $status[] = Horde::link($this->_params['contents']->urlView($this->_mimepart, 'view_attach')) . $this->_outputImgTag('view_thumbnail', _("View Attachment")) . '</a>';
+            $status[] = Horde::link($this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach')) . $this->_outputImgTag('view_thumbnail', _("View Attachment")) . '</a>';
         }
 
         return array(
@@ -161,12 +157,22 @@ class IMP_Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Images
                         'text' => $status
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
 
     /**
+     * Return the full rendered version of the Horde_Mime_Part object.
+     *
+     * @return array  See parent::render().
+     */
+    protected function _renderRaw()
+    {
+        return parent::_render();
+    }
+
+    /**
      * Generate the HTML output for the JS auto-resize view window.
      *
      * @return string  The HTML output.
@@ -202,7 +208,7 @@ EOD;
             $this->_mimepart->getMimeId() => array(
                 'data' => $str,
                 'status' => array(),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
@@ -293,7 +299,7 @@ EOD;
      */
     protected function _outputImgTag($type, $alt)
     {
-        return '<img src="' . $this->_params['contents']->urlView($this->_mimepart, 'view_attach', array('params' => array('imp_img_view' => $type))) . '" alt="' . htmlspecialchars($alt, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . '" />';
+        return '<img src="' . $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach', array('params' => array('imp_img_view' => $type))) . '" alt="' . htmlspecialchars($alt, ENT_COMPAT, $this->getConfigParam('charset')) . '" />';
     }
 
 }
index a6f8063..58b3740 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Itip class displays vCalendar/iCalendar data
+ * The IMP_Mime_Viewer_Itip class displays vCalendar/iCalendar data
  * and provides an option to import the data into a calendar source,
  * if one is available.
  *
@@ -15,7 +15,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -49,11 +49,13 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
     {
         $ret = $this->_renderInline(true);
         if (!empty($ret)) {
+            $templates = $GLOBALS['registry']->get('templates', 'horde');
+
             reset($ret);
             Horde::startBuffer();
-            include $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
+            include $templates . '/common-header.inc';
             echo $ret[key($ret)]['data'];
-            include $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
+            include $templates . '/common-footer.inc';
 
             $ret[key($ret)]['data'] = Horde::endBuffer();
         }
@@ -75,7 +77,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
     {
         global $registry;
 
-        $charset = $GLOBALS['registry']->getCharset();
+        $charset = $this->getConfigParam('charset');
         $data = $this->_mimepart->getContents();
         $mime_id = $this->_mimepart->getMimeId();
 
@@ -94,7 +96,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
         // Check if we got vcard data with the wrong vcalendar mime type.
         $c = $vCal->getComponentClasses();
         if ((count($c) == 1) && !empty($c['horde_icalendar_vcard'])) {
-            return $this->_params['contents']->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE, array('type' => 'text/x-vcard'));
+            return $this->getConfigParam('imp_contents')->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE, array('type' => 'text/x-vcard'));
         }
 
         // Get the method type.
@@ -138,7 +140,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
                 // vEvent reply.
                 if ($registry->hasMethod('calendar/updateAttendee')) {
                     try {
-                        $hdrs = $this->_params['contents']->getHeaderOb();
+                        $hdrs = $this->getConfigParam('imp_contents')->getHeaderOb();
                         $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $hdrs->getValue('From')));
                         $msgs[] = array('success', _("Respondent Status Updated."));
                     } catch (Horde_Exception $e) {
@@ -498,7 +500,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
             }
             return array(
                 $mime_id => array(
-                    'data' => Horde_String::convertCharset(Horde::escapeJson(Horde::prepareResponse(null, true), array('charset' => $GLOBALS['registry']->getCharset())), $GLOBALS['registry']->getCharset(), 'UTF-8'),
+                    'data' => Horde_String::convertCharset(Horde::escapeJson(Horde::prepareResponse(null, true), array('charset' => $this->getConfigParam('charset'))), $this->getConfigParam('charset'), 'UTF-8'),
                     'status' => array(),
                     'name' => null,
                     'type' => 'application/json'
@@ -508,7 +510,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
 
         // Create the HTML to display the iCal file.
         if ($_SESSION['imp']['view'] != 'imp' && !$full) {
-            $url = $this->_params['contents']->urlView($this->_mimepart, 'view_attach', array('params' => array('ajax' => 1, 'mode' => IMP_Contents::RENDER_INLINE)));
+            $url = $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach', array('params' => array('ajax' => 1, 'mode' => IMP_Contents::RENDER_INLINE)));
             $onsubmit = ' onsubmit="DimpCore.submitForm(\'impMimeViewerItip\');return false"';
         } else {
             $url = IMP::selfUrl();
@@ -567,7 +569,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
             break;
 
         case 'REQUEST':
-            $hdrs = $this->_params['contents']->getHeaderOb();
+            $hdrs = $this->getConfigParam('imp_contents')->getHeaderOb();
             $sender = $hdrs->getValue('From');
             $desc = _("%s requests your free/busy information.");
             break;
@@ -717,7 +719,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
             break;
 
         case 'REPLY':
-            $hdrs = $this->_params['contents']->getHeaderOb();
+            $hdrs = $this->getConfigParam('imp_contents')->getHeaderOb();
             $desc = _("%s has replied to the invitation to \"%s\".");
             $sender = $hdrs->getValue('From');
             if ($registry->hasMethod('calendar/updateAttendee')) {
index 873a19b..a032625 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Mdn class handles multipart/report messages that
+ * The IMP_Mime_Viewer_Mdn class handles multipart/report messages that
  * that refer to message disposition notification (MDN) messages (RFC 3798).
  *
  * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Mdn extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Mdn extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -48,7 +48,7 @@ class IMP_Horde_Mime_Viewer_Mdn extends Horde_Mime_Viewer_Base
         /* If this is a straight message/disposition-notification part, just
          * output the text. */
         if ($this->_mimepart->getType() == 'message/disposition-notification') {
-            return $this->_params['contents']->renderMIMEPart($this->_mimepart->getMIMEId(), IMP_Contents::RENDER_FULL, array('type' => 'text/plain', 'params' => $this->_params));
+            return $this->getConfigParam('imp_contents')->renderMIMEPart($this->_mimepart->getMIMEId(), IMP_Contents::RENDER_FULL, array('type' => 'text/plain'));
         }
 
         return $this->_renderInfo();
@@ -80,21 +80,21 @@ class IMP_Horde_Mime_Viewer_Mdn extends Horde_Mime_Viewer_Base
         /* Print the human readable message. */
         reset($parts);
         $curr_id = $first_id = next($parts);
-        $first_part = $this->_params['contents']->renderMIMEPart($curr_id, IMP_Contents::RENDER_INLINE_AUTO, array('params' => $this->_params));
+        $first_part = $this->getConfigParam('imp_contents')->renderMIMEPart($curr_id, IMP_Contents::RENDER_INLINE_AUTO);
 
         /* Display a link to more detailed message. */
         $curr_id = Horde_Mime::mimeIdArithmetic($curr_id, 'next');
-        $part = $this->_params['contents']->getMIMEPart($curr_id);
+        $part = $this->getConfigParam('imp_contents')->getMIMEPart($curr_id);
         if ($part) {
-            $status[0]['text'][] = sprintf(_("Additional information can be viewed %s."), $this->_params['contents']->linkViewJS($part, 'view_attach', _("HERE"), array('jstext' => _("Additional information details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE))));
+            $status[0]['text'][] = sprintf(_("Additional information can be viewed %s."), $this->getConfigParam('imp_contents')->linkViewJS($part, 'view_attach', _("HERE"), array('jstext' => _("Additional information details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE))));
         }
 
         /* Display a link to the sent message. Try to download the text of
            the message/rfc822 part first, if it exists. */
         $curr_id = Horde_Mime::mimeIdArithmetic($curr_id, 'next');
-        $part = $this->_params['contents']->getMIMEPart($curr_id);
+        $part = $this->getConfigParam('imp_contents')->getMIMEPart($curr_id);
         if ($part) {
-            $status[0]['text'][] = sprintf(_("The text of the sent message can be viewed %s."), $this->_params['contents']->linkViewJS($part, 'view_attach', _("HERE"), array('jstext' => _("The text of the sent message"))));
+            $status[0]['text'][] = sprintf(_("The text of the sent message can be viewed %s."), $this->getConfigParam('imp_contents')->linkViewJS($part, 'view_attach', _("HERE"), array('jstext' => _("The text of the sent message"))));
         }
 
         if (empty($first_part)) {
@@ -109,7 +109,7 @@ class IMP_Horde_Mime_Viewer_Mdn extends Horde_Mime_Viewer_Base
         $ret[$mdn_id] = array(
             'data' => $data,
             'status' => $status,
-            'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset(),
+            'type' => 'text/html; charset=' . $this->getConfigParam('charset'),
             'wrap' => 'mimePartWrap'
         );
 
index c0052ae..08e02d1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Partial class allows message/partial messages
+ * The IMP_Mime_Viewer_Partial class allows message/partial messages
  * to be displayed (RFC 2046 [5.2.2]).
  *
  * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -59,7 +59,7 @@ class IMP_Horde_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
                 $id => array(
                     'data' => null,
                     'status' => array(self::$_statuscache[$id]),
-                    'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset()
+                    'type' => 'text/plain; charset=' . $this->getConfigParam('charset')
                 )
             );
         } else {
@@ -87,7 +87,7 @@ class IMP_Horde_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
         /* Perform the search to find the other parts of the message. */
         $query = new Horde_Imap_Client_Search_Query();
         $query->headerText('Content-Type', $id);
-        $indices = $GLOBALS['injector']->getInstance('IMP_Search')->runSearchQuery($query, $this->_params['contents']->getMailbox());
+        $indices = $GLOBALS['injector']->getInstance('IMP_Search')->runSearchQuery($query, $this->getConfigParam('imp_contents')->getMailbox());
 
         /* If not able to find the other parts of the message, prepare a
          * status message. */
index 751cf48..2ec340e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Pdf class enables generation of thumbnails for
+ * The IMP_Mime_Viewer_Pdf class enables generation of thumbnails for
  * PDF attachments.
  *
  * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
+class IMP_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
 {
     /**
      * This driver's display capabilities.
@@ -81,9 +81,9 @@ class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
         $status = array(_("This is a thumbnail of a PDF file attached to this message."));
 
         if ($GLOBALS['browser']->hasFeature('javascript')) {
-            $status[] = $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', $this->_outputImgTag(), null, null, null);
+            $status[] = $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', $this->_outputImgTag(), null, null, null);
         } else {
-            $status[] = Horde::link($this->_params['contents']->urlView($this->_mimepart, 'view_attach')) . $this->_outputImgTag() . '</a>';
+            $status[] = Horde::link($this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach')) . $this->_outputImgTag() . '</a>';
         }
 
         return array(
@@ -95,7 +95,7 @@ class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
                         'text' => $status
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
@@ -149,7 +149,7 @@ class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf
      */
     protected function _outputImgTag()
     {
-        return '<img src="' . $this->_params['contents']->urlView($this->_mimepart, 'view_attach', array('params' => array('pdf_view_thumbnail' => 1))) . '" alt="' . htmlspecialchars(_("View PDF File"), ENT_COMPAT, $GLOBALS['registry']->getCharset()) . '" />';
+        return '<img src="' . $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach', array('params' => array('pdf_view_thumbnail' => 1))) . '" alt="' . htmlspecialchars(_("View PDF File"), ENT_COMPAT, $this->getConfigParam('charset')) . '" />';
     }
 
 }
index 7d672b0..7755e2c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Pgp class allows viewing/decrypting of PGP
+ * The IMP_Mime_Viewer_Pgp class allows viewing/decrypting of PGP
  * formatted messages.  This class implements RFC 3156.
  *
  * This class handles the following MIME types:
@@ -22,7 +22,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -77,7 +77,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
             $id => array(
                 'data' => '',
                 'status' => array(),
-                'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/plain; charset=' . $this->getConfigParam('charset')
             )
         );
 
@@ -113,7 +113,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
 
         /* Determine the address of the sender. */
         if (is_null($this->_address)) {
-            $headers = $this->_params['contents']->getHeaderOb();
+            $headers = $this->getConfigParam('imp_contents')->getHeaderOb();
             $this->_address = Horde_Mime_Address::bareAddress($headers->getValue('from'));
         }
 
@@ -130,7 +130,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
                     $id => array(
                         'data' => null,
                         'status' => self::$_cache[$id]['status'],
-                        'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset(),
+                        'type' => 'text/plain; charset=' . $this->getConfigParam('charset'),
                         'wrap' => self::$_cache[$id]['wrap']
                     )
                 ), self::$_cache[$id]['other']);
@@ -187,7 +187,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
         /* PGP version information appears in the first MIME subpart. We
          * don't currently need to do anything with this information. The
          * encrypted data appears in the second MIME subpart. */
-        $encrypted_part = $this->_params['contents']->getMIMEPart($data_id);
+        $encrypted_part = $this->getConfigParam('imp_contents')->getMIMEPart($data_id);
         $encrypted_data = $encrypted_part->getContents();
 
         $symmetric_pass = $personal_pass = null;
@@ -304,9 +304,9 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
         if ($GLOBALS['prefs']->getValue('use_pgp') &&
             $GLOBALS['prefs']->getValue('add_source') &&
             $GLOBALS['registry']->hasMethod('contacts/addField')) {
-            $status['text'][] = Horde::link('#', '', '', '', $imp_pgp->savePublicKeyURL($this->_params['contents']->getMailbox(), $this->_params['contents']->getUid(), $mime_id) . 'return false;') . _("Save the key to your address book.") . '</a>';
+            $status['text'][] = Horde::link('#', '', '', '', $imp_pgp->savePublicKeyURL($this->getConfigParam('imp_contents')->getMailbox(), $this->getConfigParam('imp_contents')->getUid(), $mime_id) . 'return false;') . _("Save the key to your address book.") . '</a>';
         }
-        $status['text'][] = $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View the raw text of the Public Key."), array('jstext' => _("View Public Key"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE, 'rawpgpkey' => 1)));
+        $status['text'][] = $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("View the raw text of the Public Key."), array('jstext' => _("View Public Key"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE, 'rawpgpkey' => 1)));
 
         try {
             $data = '<span class="fixed">' . nl2br(str_replace(' ', '&nbsp;', $imp_pgp->pgpPrettyKey($this->_mimepart->getContents()))) . '</span>';
@@ -318,7 +318,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
             $mime_id => array(
                 'data' => $data,
                 'status' => array($status),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
@@ -344,7 +344,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
                         'text' => array()
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset(),
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset'),
                 'wrap' => 'mimePartWrap'
             ),
             $sig_id => null
@@ -363,13 +363,13 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
 
         if ($GLOBALS['prefs']->getValue('pgp_verify') ||
             Horde_Util::getFormData('pgp_verify_msg')) {
-            $sig_part = $this->_params['contents']->getMIMEPart($sig_id);
+            $sig_part = $this->getConfigParam('imp_contents')->getMIMEPart($sig_id);
 
             try {
                 $imp_pgp = $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp');
                 $sig_result = $sig_part->getMetadata('imp-pgp-signature')
                     ? $imp_pgp->verifySignature($sig_part->getContents(array('canonical' => true)), $this->_address)
-                    : $imp_pgp->verifySignature($sig_part->replaceEOL($this->_params['contents']->getBodyPart($signed_id, array('mimeheaders' => true)), Horde_Mime_Part::RFC_EOL), $this->_address, $sig_part->getContents());
+                    : $imp_pgp->verifySignature($sig_part->replaceEOL($this->getConfigParam('imp_contents')->getBodyPart($signed_id, array('mimeheaders' => true)), Horde_Mime_Part::RFC_EOL), $this->_address, $sig_part->getContents());
 
                 $icon = Horde::img('alerts/success.png', _("Success"));
                 $sig_text = $sig_result->message;
@@ -384,7 +384,9 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
                 'icon' => $icon,
                 'success' => $success,
                 'text' => array(
-                    $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($sig_text, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML))
+                    $this->_textFilter($sig_text, 'text2html', array(
+                        'parselevel' => Horde_Text_Filter_Text2html::NOHTML
+                    ))
                 )
             );
 
@@ -413,7 +415,7 @@ class IMP_Horde_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
      */
     protected function _getSymmetricID()
     {
-        return $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp')->getSymmetricID($this->_params['contents']->getMailbox(), $this->_params['contents']->getUid(), $this->_mimepart->getMimeId());
+        return $GLOBALS['injector']->getInstance('IMP_Crypt_Pgp')->getSymmetricID($this->getConfigParam('imp_contents')->getMailbox(), $this->getConfigParam('imp_contents')->getUid(), $this->_mimepart->getMimeId());
     }
 
     /**
index 9e45bac..1234427 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Plain class renders out text/plain MIME parts
+ * The IMP_Mime_Viewer_Plain class renders out text/plain MIME parts
  * with URLs made into hyperlinks.
  *
  * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
@@ -14,7 +14,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
+class IMP_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
 {
     /**
      * Cached data.
@@ -78,8 +78,8 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
 
         // Convert to the local charset.
         if ($inline) {
-            $text = Horde_String::convertCharset($text, $charset);
-            $charset = $GLOBALS['registry']->getCharset();
+            $text = Horde_String::convertCharset($text, $charset, $this->getConfigParam('charset'));
+            $charset = $this->getConfigParam('charset');
         }
         $type = 'text/html; charset=' . $charset;
 
@@ -124,7 +124,7 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
                 (($show == 'hidden') ||
                  (($show == 'thread') && (basename(Horde::selfUrl()) == 'thread.php')));
             if (!$hideBlocks && in_array($show, array('list', 'listthread'))) {
-                $header = $this->_params['contents']->getHeaderOb();
+                $header = $this->getConfigParam('imp_contents')->getHeaderOb();
                 $imp_ui = new IMP_Ui_Message();
                 $list_info = $imp_ui->getListInformation($header);
                 $hideBlocks = $list_info['exists'];
@@ -147,7 +147,7 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
         }
 
         // Run filters.
-        $text = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($text, array_keys($filters), array_values($filters));
+        $text = $this->_textFilter($text, array_keys($filters), array_values($filters));
 
         // Wordwrap.
         $text = str_replace(array('  ', "\n "), array(' &nbsp;', "\n&nbsp;"), $text);
@@ -317,7 +317,7 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
 
         $text_part = new Horde_Mime_Part();
         $text_part->setType('text/plain');
-        $text_part->setCharset($GLOBALS['registry']->getCharset());
+        $text_part->setCharset($this->getConfigParam('charset'));
         $text_part->setContents(preg_replace("/begin [0-7]{3} .+\r?\n.+\r?\nend/Us", "\n", $text));
         $new_part->addPart($text_part);
 
@@ -353,7 +353,7 @@ class IMP_Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
         );
 
         return '<div class="fixed">' .
-            $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter(Horde_String::convertCharset(fread($stream, 1024), $this->_mimepart->getCharset()), array_keys($filters), array_values($filters)) .
+            $this->_textFilter(Horde_String::convertCharset(fread($stream, 1024), $this->_mimepart->getCharset(), $this->getConfigParam('charset')), array_keys($filters), array_values($filters)) .
             ' [...]</div>';
     }
 
index 523e26b..6785951 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Related class handles multipart/related
+ * The IMP_Mime_Viewer_Related class handles multipart/related
  * (RFC 2387) messages.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Related extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Related extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -98,11 +98,14 @@ class IMP_Horde_Mime_Viewer_Related extends Horde_Mime_Viewer_Base
         /* Only display if the start part (normally text/html) can be
          * displayed inline -OR- we are viewing this part as an attachment. */
         if ($inline &&
-            !$this->_params['contents']->canDisplay($id, IMP_Contents::RENDER_INLINE)) {
+            !$this->getConfigParam('imp_contents')->canDisplay($id, IMP_Contents::RENDER_INLINE)) {
             return array();
         }
 
-        $render = $this->_params['contents']->renderMIMEPart($id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL, array('params' => array_merge($this->_params, array('related_id' => $related_id, 'related_cids' => $cids))));
+        /* Set related information in message metadata. */
+        $this->_mimepart->setMetadata('related_cids', $cids);
+
+        $render = $this->getConfigParam('imp_contents')->renderMIMEPart($id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL);
 
         if (!$inline) {
             foreach (array_keys($render) as $key) {
index 5d46215..1dfbbb6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Rfc822 class extends the base Horde Mime Viewer
+ * The IMP_Mime_Viewer_Rfc822 class extends the base Horde Mime Viewer
  * by indicating that all subparts should be wrapped in a display DIV.
  *
  * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Rfc822
+class IMP_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Rfc822
 {
     /**
      * Return the rendered information about the Horde_Mime_Part object.
index 918133c..a7127fd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Smil renders SMIL documents to very basic HTML.
+ * The IMP_Mime_Viewer_Smil renders SMIL documents to very basic HTML.
  *
  * Copyright 2006-2010 The Horde Project (http://www.horde.org/)
  *
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Smil
+class IMP_Mime_Viewer_Smil extends Horde_Mime_Viewer_Smil
 {
     /**
      * User-defined function callback for start elements.
@@ -28,7 +28,7 @@ class IMP_Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Smil
         case 'IMG':
             if (isset($attrs['SRC']) &&
                 (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) {
-                $this->_content .= '<img src="' . $this->_params['contents']->urlView($rp, 'view_attach') . '" alt="" /><br />';
+                $this->_content .= '<img src="' . $this->getConfigParam('imp_contents')->urlView($rp, 'view_attach') . '" alt="" /><br />';
             }
             break;
 
@@ -50,11 +50,12 @@ class IMP_Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Smil
      */
     protected function _getRelatedLink($cid)
     {
-        if (isset($this->_params['related_id']) &&
-            (($key = array_search(trim($cid, '<>', $this->_params['related_cids']))) !== false)) {
-            return $this->_param['contents']->getMIMEPart($key);
+        if ($related_part = $this->findMimeType($this->_mimepart->getMimeId(), 'multipart/related') &&
+            (($key = array_search(trim($cid, '<>', $related_part->getMetadata('related_cids')))) !== false)) {
+            return $this->getConfigParam('imp_contents')->getMIMEPart($key);
         }
 
         return false;
     }
+
 }
index 92d3ca9..cd5358d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Smime class allows viewing/decrypting of S/MIME
+ * The IMP_Mime_Viewer_Smime class allows viewing/decrypting of S/MIME
  * messages (RFC 2633).
  *
  * This class handles the following MIME types:
@@ -24,7 +24,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -118,7 +118,7 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
                     $id => array(
                         'data' => null,
                         'status' => self::$_cache[$id]['status'],
-                        'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset(),
+                        'type' => 'text/plain; charset=' . $this->getConfigParam('charset'),
                         'wrap' => self::$_cache[$id]['wrap']
                     )
                 );
@@ -205,8 +205,8 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
         }
 
         $raw_text = $this->_mimepart->getMimeId()
-            ? $this->_params['contents']->getBodyPart($this->_mimepart->getMimeId(), array('mimeheaders' => true, 'stream' => true))
-            : $this->_params['contents']->fullMessageText();
+            ? $this->getConfigParam('imp_contents')->getBodyPart($this->_mimepart->getMimeId(), array('mimeheaders' => true, 'stream' => true))
+            : $this->getConfigParam('imp_contents')->fullMessageText();
 
         try {
             $decrypted_data = $this->_impsmime->decryptMessage($this->_mimepart->replaceEOL($raw_text, Horde_Mime_Part::RFC_EOL));
@@ -219,7 +219,7 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
 
         $new_part = Horde_Mime_Part::parseMessage($decrypted_data, array('forcemime' => true));
 
-        $hdrs = $this->_params['contents']->getHeaderOb();
+        $hdrs = $this->getConfigParam('imp_contents')->getHeaderOb();
         $new_part->setMetadata('imp-smime-from', $hdrs->getValue('from'));
 
         return $new_part;
@@ -256,14 +256,14 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
             return null;
         }
 
-        if ($this->_params['contents']->isEmbedded($base_id)) {
+        if ($this->getConfigParam('imp_contents')->isEmbedded($base_id)) {
             $hdrs = new Horde_Mime_Headers();
             $hdrs->addHeader('From', $this->_mimepart->getMetadata('imp-smime-from'));
             $stream = $this->_mimepart->toString(array('headers' => $hdrs, 'stream' => true));
         } else {
             $stream = $base_id
-                ? $this->_params['contents']->getBodyPart($base_id, array('mimeheaders' => true, 'stream' => true))
-                : $this->_params['contents']->fullMessageText(array('stream' => true));
+                ? $this->getConfigParam('imp_contents')->getBodyPart($base_id, array('mimeheaders' => true, 'stream' => true))
+                : $this->getConfigParam('imp_contents')->fullMessageText(array('stream' => true));
         }
 
         $raw_text = $this->_mimepart->replaceEOL($stream, Horde_Mime_Part::RFC_EOL);
@@ -300,7 +300,7 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
                     isset($sig_result->email) &&
                     $GLOBALS['registry']->hasMethod('contacts/addField') &&
                     $GLOBALS['prefs']->getValue('add_source')) {
-                    $status[] = '[' . $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View Certificate"), array('params' => array('mode' => IMP_Contents::RENDER_INLINE, 'view_smime_key' => 1))) . '] [' . Horde::link('#', '', null, null, $this->_impsmime->savePublicKeyURL($sig_result->cert, $this->_params['contents']->getUid(), $sig_id) . ' return false;') . _("Save Certificate in your Address Book") . '</a>]';
+                    $status[] = '[' . $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("View Certificate"), array('params' => array('mode' => IMP_Contents::RENDER_INLINE, 'view_smime_key' => 1))) . '] [' . Horde::link('#', '', null, null, $this->_impsmime->savePublicKeyURL($sig_result->cert, $this->getConfigParam('imp_contents')->getUid(), $sig_id) . ' return false;') . _("Save Certificate in your Address Book") . '</a>]';
                 }
             } catch (Horde_Exception $e) {
                 self::$_cache[$base_id]['status'][0]['icon'] = ($e->getCode() == 'horde.warning')
@@ -325,7 +325,7 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
             return;
         }
 
-        $subpart = $this->_params['contents']->getMIMEPart($sig_id);
+        $subpart = $this->getConfigParam('imp_contents')->getMIMEPart($sig_id);
         if (empty($subpart)) {
             try {
                 $msg_data = $this->_impsmime->extractSignedContents($raw_text);
@@ -351,8 +351,8 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
         }
 
         $raw_text = $this->_mimepart->getMimeId()
-            ? $this->_params['contents']->getBodyPart($this->_mimepart->getMimeId(), array('mimeheaders' => true, 'stream' => true))
-            : $this->_params['contents']->fullMessageText();
+            ? $this->getConfigParam('imp_contents')->getBodyPart($this->_mimepart->getMimeId(), array('mimeheaders' => true, 'stream' => true))
+            : $this->getConfigParam('imp_contents')->fullMessageText();
 
         try {
             $sig_result = $this->_impsmime->verifySignature($this->_mimepart->replaceEOL($raw_text, Horde_Mime_Part::RFC_EOL));
@@ -364,7 +364,7 @@ class IMP_Horde_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
             $this->_mimepart->getMimeId() => array(
                 'data' => $this->_impsmime->certToHTML($sig_result->cert),
                 'status' => array(),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
index 64279f3..3e285b3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Status class handles multipart/report messages
+ * The IMP_Mime_Viewer_Status class handles multipart/report messages
  * that refer to mail system administrative messages (RFC 3464).
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
+class IMP_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
 {
     /**
      * This driver's display capabilities.
@@ -48,7 +48,7 @@ class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
         /* If this is a straight message/disposition-notification part, just
          * output the text. */
         if ($this->_mimepart->getType() == 'message/delivery-status') {
-            return $this->_params['contents']->renderMIMEPart($this->_mimepart->getMIMEId(), IMP_Contents::RENDER_FULL, array('type' => 'text/plain', 'params' => $this->_params));
+            return $this->getConfigParam('imp_contents')->renderMIMEPart($this->_mimepart->getMIMEId(), IMP_Contents::RENDER_FULL, array('type' => 'text/plain'));
         }
 
         return $this->_renderInfo();
@@ -80,7 +80,7 @@ class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
 
         /* Get the action first - it appears in the second part. */
         $action = null;
-        $part2 = $this->_params['contents']->getMIMEPart($part2_id);
+        $part2 = $this->getConfigParam('imp_contents')->getMIMEPart($part2_id);
 
         foreach (explode("\n", $part2->getContents()) as $line) {
             if (stristr($line, 'Action:') !== false) {
@@ -105,7 +105,7 @@ class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
                     'icon' => Horde::img('alerts/error.png', _("Error")),
                     'text' => array(
                         _("ERROR: Your message could not be delivered."),
-                        sprintf(_("Additional error message details can be viewed %s."), $this->_params['contents']->linkViewJS($part2, 'view_attach', _("HERE"), array('jstext' => _("Additional message details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE))))
+                        sprintf(_("Additional error message details can be viewed %s."), $this->getConfigParam('imp_contents')->linkViewJS($part2, 'view_attach', _("HERE"), array('jstext' => _("Additional message details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE))))
                     )
                 )
             );
@@ -121,7 +121,7 @@ class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
                     'icon' => Horde::img('alerts/success.png', _("Success")),
                     'text' => array(
                         _("Your message was successfully delivered."),
-                        sprintf(_("Additional message details can be viewed %s."), $this->_params['contents']->linkViewJS($part2, 'view_attach', _("HERE"), array('jstext' => _("Additional message details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE))))
+                        sprintf(_("Additional message details can be viewed %s."), $this->getConfigParam('imp_contents')->linkViewJS($part2, 'view_attach', _("HERE"), array('jstext' => _("Additional message details"), 'params' => array('mode' => IMP_Contents::RENDER_INLINE))))
                     )
                 )
             );
@@ -131,12 +131,12 @@ class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
         }
 
         /* Print the human readable message. */
-        $first_part = $this->_params['contents']->renderMIMEPart($part1_id, IMP_Contents::RENDER_INLINE_AUTO, array('params' => $this->_params));
+        $first_part = $this->getConfigParam('imp_contents')->renderMIMEPart($part1_id, IMP_Contents::RENDER_INLINE_AUTO);
 
         /* Display a link to the returned message, if it exists. */
-        $part3 = $this->_params['contents']->getMIMEPart($part3_id);
+        $part3 = $this->getConfigParam('imp_contents')->getMIMEPart($part3_id);
         if ($part3) {
-            $status[0]['text'][] = sprintf($msg_link, $this->_params['contents']->linkViewJS($part3, 'view_attach', _("HERE"), array('jstext' => $msg_link_status, 'ctype' => 'message/rfc822')));
+            $status[0]['text'][] = sprintf($msg_link, $this->getConfigParam('imp_contents')->linkViewJS($part3, 'view_attach', _("HERE"), array('jstext' => $msg_link_status, 'ctype' => 'message/rfc822')));
         }
 
         if (empty($first_part)) {
@@ -152,7 +152,7 @@ class IMP_Horde_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
         $ret[$this->_mimepart->getMimeId()] = array(
             'data' => $data,
             'status' => $status,
-            'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset(),
+            'type' => 'text/html; charset=' . $this->getConfigParam('charset'),
             'wrap' => 'mimePartWrap'
         );
 
index 017bca1..f078861 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Tnef class allows MS-TNEF attachments to be
+ * The IMP_Mime_Viewer_Tnef class allows MS-TNEF attachments to be
  * displayed.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
+class IMP_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
 {
     /**
      * This driver's display capabilities.
@@ -51,7 +51,7 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
      */
     protected function _render()
     {
-        if (!Horde_Util::getFormData('tnef_attachment')) {
+        if (!($tnef_atc = Horde_Util::getFormData('tnef_attachment'))) {
             $ret = $this->_renderInfo();
             reset($ret);
             $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
@@ -59,12 +59,15 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
         }
 
         /* Get the data from the attachment. */
-        $tnef = Horde_Compress::factory('tnef');
+        if (!($tnef = $this->getConfigParam('tnef'))) {
+            $tnef = Horde_Compress::factory('Tnef');
+            $this->setConfigParam('tnef', $tnef);
+        }
         $tnefData = $tnef->decompress($this->_mimepart->getContents());
 
         /* Display the requested file. Its position in the $tnefData
          * array can be found in 'tnef_attachment'. */
-        $tnefKey = Horde_Util::getFormData('tnef_attachment') - 1;
+        $tnefKey = $tnef_atc - 1;
 
         /* Verify that the requested file exists. */
         if (isset($tnefData[$tnefKey])) {
@@ -94,7 +97,10 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
     protected function _renderInfo()
     {
         /* Get the data from the attachment. */
-        $tnef = Horde_Compress::factory('tnef');
+        if (!($tnef = $this->getConfigParam('tnef'))) {
+            $tnef = Horde_Compress::factory('Tnef');
+            $this->setConfigParam('tnef', $tnef);
+        }
         $tnefData = $tnef->decompress($this->_mimepart->getContents());
 
         if (!count($tnefData)) {
@@ -120,7 +126,7 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
             }
             $temp_part->setType($type);
 
-            $link = $this->_params['contents']->linkView($temp_part, 'view_attach', htmlspecialchars($data['name']), array('jstext' => sprintf(_("View %s"), $data['name']), 'params' => array('tnef_attachment' => $key + 1)));
+            $link = $this->getConfigParam('imp_contents')->linkView($temp_part, 'view_attach', htmlspecialchars($data['name']), array('jstext' => sprintf(_("View %s"), $data['name']), 'params' => array('tnef_attachment' => $key + 1)));
             $text .= _("Attached File:") . '&nbsp;&nbsp;' . $link . '&nbsp;&nbsp;(' . $data['type'] . '/' . $data['subtype'] . ")<br />\n";
         }
 
@@ -132,7 +138,7 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef
                         'text' => array(_("The following files were attached to this part:"))
                     )
                 ),
-                'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+                'type' => 'text/html; charset=' . $this->getConfigParam('charset')
             )
         );
     }
index e8cd4f2..8a5d971 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Vcard class renders out the contents of vCard
+ * The IMP_Mime_Viewer_Vcard class renders out the contents of vCard
  * files in HTML format and allows inline display of embedded photos.
  *
  * Copyright 2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Vcard
+class IMP_Mime_Viewer_Vcard extends Horde_Core_Mime_Viewer_Vcard
 {
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
@@ -30,7 +30,7 @@ class IMP_Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Vcard
     protected function _render()
     {
         if (is_null(Horde_Util::getFormData('p'))) {
-            $this->_imageUrl = $this->_params['contents']->urlView($this->_mimepart, 'download_render');
+            $this->_imageUrl = $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'download_render');
             return parent::_render();
         }
 
index f8ed424..1e5e105 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Horde_Mime_Viewer_Zip class renders out the contents of ZIP files
+ * The IMP_Mime_Viewer_Zip class renders out the contents of ZIP files
  * in HTML format and allows downloading of extractable files.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -14,7 +14,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip
+class IMP_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip
 {
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
@@ -29,21 +29,31 @@ class IMP_Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip
      */
     protected function _render()
     {
-        if (!Horde_Util::getFormData('zip_attachment')) {
-            $this->_callback = array(&$this, '_IMPcallback');
+        if (!($zip_atc = Horde_Util::getFormData('zip_attachment'))) {
+            $this->_callback = array($this, '_IMPcallback');
             return parent::_render();
         }
 
         /* Send the requested file. Its position in the zip archive is located
          * in 'zip_attachment'. */
         $data = $this->_mimepart->getContents();
-        $zip = Horde_Compress::factory('zip');
-        $fileKey = Horde_Util::getFormData('zip_attachment') - 1;
-        $zipInfo = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_LIST));
+        $fileKey = $zip_atc - 1;
+
+        if (!($zip = $this->getConfigParam('zip'))) {
+            $zip = Horde_Compress::factory('Zip');
+            $this->setConfigParam('zip', $zip);
+        }
+        $zipInfo = $zip->decompress($data, array(
+            'action' => Horde_Compress_Zip::ZIP_LIST
+        ));
 
         /* Verify that the requested file exists. */
         if (isset($zipInfo[$fileKey])) {
-            $text = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_DATA, 'info' => $zipInfo, 'key' => $fileKey));
+            $text = $zip->decompress($data, array(
+                'action' => Horde_Compress_Zip::ZIP_DATA,
+                'info' => $zipInfo,
+                'key' => $fileKey
+            ));
             if (!empty($text)) {
                 return array(
                     $this->_mimepart->getMimeId() => array(
@@ -67,7 +77,7 @@ class IMP_Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip
      */
     protected function _renderInfo()
     {
-        $this->_callback = array(&$this, '_IMPcallback');
+        $this->_callback = array($this, '_IMPcallback');
         return parent::_renderInfo();
     }
 
@@ -88,7 +98,7 @@ class IMP_Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip
              ($val['method'] == 0x0))) {
             $mime_part = $this->_mimepart;
             $mime_part->setName(basename($name));
-            $val['name'] = str_replace($name, $this->_params['contents']->linkView($mime_part, 'download_render', $name, array('jstext' => sprintf(_("View %s"), str_replace('&nbsp;', ' ', $name)), 'class' => 'fixed', 'params' => array('zip_attachment' => urlencode($key) + 1))), $val['name']);
+            $val['name'] = str_replace($name, $this->getConfigParam('imp_contents')->linkView($mime_part, 'download_render', $name, array('jstext' => sprintf(_("View %s"), str_replace('&nbsp;', ' ', $name)), 'class' => 'fixed', 'params' => array('zip_attachment' => urlencode($key) + 1))), $val['name']);
         }
 
         return $val;
index 43b3f3e..aed3c7a 100644 (file)
@@ -272,7 +272,7 @@ class IMP_Prefs_Ui
 
             $mock_part = new Horde_Mime_Part();
             $mock_part->setType('text/html');
-            $v = Horde_Mime_Viewer::factory($mock_part);
+            $v = $GLOBALS['injector']->getInstance('IMP_Mime_Viewer')->getViewer($mock_part);
 
             if (!$v->canRender('inline')) {
                 $ui->suppress[] = 'html_image_replacement';
index 1f882b0..eff16dc 100644 (file)
@@ -429,7 +429,7 @@ class IMP_Ui_Message
      * Prints out a MIME status message (in HTML).
      *
      * @param array $data  An array of information (as returned from
-                           Horde_Mime_Viewer::render()).
+                           Horde_Mime_Viewer_Base::render()).
      *
      * @return string  The formatted status message string.
      */
index 4b7700f..4be0a0e 100644 (file)
@@ -154,7 +154,10 @@ case 'download_render':
 
 case 'compose_attach_preview':
 case 'view_attach':
-    $render = $contents->renderMIMEPart($vars->id, isset($vars->mode) ? $vars->mode : IMP_Contents::RENDER_FULL, array('params' => array('raw' => ($vars->actionID == 'compose_attach_preview'), 'type' => $vars->ctype)));
+    $render_mode = ($vars->actionID == 'compose_attach_preview')
+        ? IMP_Contents::RENDER_RAW_FALLBACK
+        : (isset($vars->mode) ? $vars->mode : IMP_Contents::RENDER_FULL);
+    $render = $contents->renderMIMEPart($vars->id, $render_mode, array('type' => $vars->ctype));
     if (!empty($render)) {
         reset($render);
         $key = key($render);
index 6d35191..4b716a9 100644 (file)
@@ -1,37 +1,13 @@
 <?php
-// $Horde: luxor/config/mime_drivers.php.dist,v 1.2 2003/01/30 10:40:23 mikec Exp $
-
 /**
- * Decide which output drivers you want to activate for the Luxor
- * module.
+ * MIME Viewer configuration for Luxor.
  *
- * Right now, the choices are:
+ * Settings in this file override settings in horde/config/mime_drivers.php.
+ * All drivers configured in that file, but not configured here, will also
+ * be used to display MIME content.
  *
+ * $Id$
  */
-$mime_drivers_map['luxor']['registered'] = array();
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here. Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
- */
-$mime_drivers_map['luxor']['overrides'] = array();
 
-/**
- * Driver specific settings. Here, you have to configure each driver
- * which you chose to activate above. Default settings have been
- * filled in for them, and if you haven't activated it, then just
- * leave it as it is - it won't get loaded.
- *
- * The 'handles' setting below shouldn't be changed in most
- * circumstances. It registers a set of MIME type that the driver can
- * handle. The 'x-extension' MIME type is a special one to Horde that
- * maps a file extension to a MIME type. It's useful when you know
- * that all files ending in '.c' are C files, for example.
- *
- * The 'icons' entry is for the driver to register various icons for
- * the MIME types it handles. The array consists of a 'default' icon
- * for that driver, and can also include specific MIME-types which can
- * have their own icons.
- */
+/* By default, Luxor uses the default Horde-wide settings contained in
+ * horde/config/mime_drivers.php. */
index 7552057..d4a58f7 100644 (file)
@@ -157,7 +157,7 @@ class Luxor
                 if (preg_match('/^.*\.[oa]$|^core$|^00-INDEX$/', $node)) {
                     continue;
                 }
-                $icon = Horde::img(Horde_Mime_Viewer::getIcon(Horde_Mime_Magic::filenameToMime($node)), '', '', '');
+                $icon = Horde::img($GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getIcon(Horde_Mime_Magic::filenameToMime($node)), '', '', '');
                 $filesize = $files->getFilesize($dir . $node);
                 if ($filesize < 1 << 10) {
                     $bytes = _("bytes");
@@ -206,8 +206,10 @@ class Luxor
 
             $mime_part = new Horde_Mime_Part('text/plain', $contents);
             $mime_part->setName('README');
-            $viewer = Horde_Mime_Viewer::factory($mime_part);
-            return $table_head . $viewer->render() . $table_foot;
+
+            return $table_head .
+                $GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getViewer($mime_part)->render() .
+                $table_foot;
         }
     }
 
index c81516c..8185610 100644 (file)
@@ -109,7 +109,7 @@ function printfile_raw($pathname)
 
     $mime_part = new Horde_Mime_Part(Horde_Mime_Magic::filenameToMime($pathname), $data);
     $mime_part->setName($pathname);
-    $viewer = Horde_Mime_Viewer::factory($mime_part);
+    $viewer = $GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getViewer($mime_part);
 
     if ($viewer->getType() == 'text/plain') {
         return '<pre class="fixed">' . htmlspecialchars($viewer->render()) . '</pre>';
index b340353..749e00a 100644 (file)
@@ -60,7 +60,7 @@ case 'view_file':
     $mime_part->setType($file_type);
     $mime_part->setContents($data);
 
-    $viewer = Horde_Mime_Viewer::factory($mime_part);
+    $viewer = $injector->getInstance('Horde_Mime_Viewer')->getViewer($mime_part);
     if ($viewer) {
         $render = $viewer->render('full');
         if (!empty($render)) {
index 10e702a..eb283ae 100644 (file)
@@ -210,7 +210,7 @@ class News {
             $html .= Horde::link(Horde_Util::addParameter($view_url, 'actionID', 'download_zip'), sprintf(_("Compress and dowload %s"), $file['file_name'])) . $dowload_zip . '</a> ' . "\n";
             $html .= Horde::link(Horde_Util::addParameter($view_url, 'actionID', 'download_file'), sprintf(_("Dowload %s"), $file['file_name'])) . $dowload_img . '</a> ' . "\n";
             $html .= Horde::link(Horde_Util::addParameter($view_url, 'actionID', 'view_file'), sprintf(_("Preview %s"), $file['file_name']), '', '_file_view');
-            $html .= Horde::img(Horde_Mime_Viewer::getIcon($file['file_type']), $file['file_name'], 'width="16" height="16"', '') . ' ';
+            $html .= Horde::img($GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getIcon($file['file_type']), $file['file_name'], 'width="16" height="16"', '') . ' ';
             if ($GLOBALS['registry']->isAdmin(array('permission' => 'news:admin'))) {
                 $html .= Horde::link(Horde_Util::addParameter($delete_url, $file), sprintf(_("Delete %s"), $file['file_name'])) . $delete_img . '</a> ' . "\n";
             }
index fad1b9b..530185a 100644 (file)
@@ -1,21 +1,13 @@
 <?php
 /**
- * Decide which output drivers you want to activate for Turba.
+ * MIME Viewer configuration for Turba.
+ *
  * Settings in this file override settings in horde/config/mime_drivers.php.
+ * All drivers configured in that file, but not configured here, will also
+ * be used to display MIME content.
  *
  * $Id$
  */
-$mime_drivers_map['turba']['registered'] = array();
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here. Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
- */
-$mime_drivers_map['turba']['overrides'] = array();
 
-/**
- * Driver specific settings. See horde/config/mime_drivers.php for
- * the format.
- */
+/* By default, Turba uses the default Horde-wide settings contained in
+ * horde/config/mime_drivers.php. */
index b6f0a17..aa21f26 100644 (file)
@@ -423,7 +423,7 @@ class Turba_Object {
 
         $mime_part = new Horde_Mime_Part();
         $mime_part->setType(Horde_Mime_Magic::extToMime($file['type']));
-        $viewer = Horde_Mime_Viewer::factory($mime_part);
+        $viewer = $GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getViewer($mime_part);
 
         // We can always download files.
         $url_params = array('actionID' => 'download_file',
@@ -434,7 +434,7 @@ class Turba_Object {
         $dl = Horde::link(Horde::downloadUrl($file['name'], $url_params), $file['name']) . Horde::img('download.png', _("Download")) . '</a>';
 
         // Let's see if we can view this one, too.
-        if ($viewer && !is_a($viewer, 'Horde_Mime_Viewer_default')) {
+        if ($viewer && !($viewer instanceof Horde_Mime_Viewer_Default)) {
             $url = Horde::applicationUrl('view.php')->add('actionID', 'view_file');
             $link = Horde::link($url, $file['name'], null, '_blank') . $file['name'] . '</a>';
         } else {
index 3232150..25390cc 100644 (file)
@@ -64,9 +64,8 @@ case 'view_file':
     $mime_part->setContents($data);
     $mime_part->setName($filename);
     $mime_part->buildMimeIds();
-    $viewer = Horde_Mime_Viewer::factory($mime_part);
 
-    $content = $viewer->render('full');
+    $content = $injector->getInstance('Horde_Mime_Viewer')->getViewer($mime_part)->render('full');
     $body = $content[1]['data'];
 
     $browser->downloadHeaders($filename, $content[1]['type'], true, strlen($body));
index 9df7bcf..c8cd2ab 100644 (file)
@@ -1,37 +1,25 @@
 <?php
 /**
- * Decide which output drivers you want to activate for the Whups application.
+ * MIME Viewer configuration for Whups.
+ *
  * Settings in this file override settings in horde/config/mime_drivers.php.
+ * All drivers configured in that file, but not configured here, will also
+ * be used to display MIME content.
  *
- * The available drivers are:
- * --------------------------
- * zip            ZIP attachments
- */
-$mime_drivers_map['whups']['registered'] = array('zip');
-
-/**
- * If you want to specifically override any MIME type to be handled by
- * a specific driver, then enter it here.  Normally, this is safe to
- * leave, but it's useful when multiple drivers handle the same MIME
- * type, and you want to specify exactly which one should handle it.
- */
-$mime_drivers_map['whups']['overrides'] = array();
-
-/**
- * Driver specific settings. See horde/config/mime_drivers.php for
- * the format.
+ * $Id$
  */
 
-$mime_drivers['horde']['enscript']['handles'][] = 'text/html';
-
-/**
- * Zip File Attachments settings
- */
-$mime_drivers['whups']['zip']['inline'] = false;
-$mime_drivers['whups']['zip']['handles'] = array(
-    'x-extension/zip',
-    'application/zip',
-    'application/x-compressed',
-    'application/x-zip-compressed');
-$mime_drivers['whups']['zip']['icons'] = array(
-    'default' => 'compressed.png');
+$mime_drivers = array(
+    /* Zip File archive viewer. */
+    'zip' => array(
+        'handles' = array(
+            'application/x-compressed',
+            'application/x-zip-compressed',
+            'application/zip',
+            'x-extension/zip',
+        ),
+        'icons' => array(
+            'default' => 'compressed.png'
+        )
+    )
+);
index b66e328..400fb05 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The Whups_Horde_Mime_Viewer_Zip class renders out the contents of ZIP files
+ * The Whups_Mime_Viewer_Zip class renders out the contents of ZIP files
  * in HTML format and allows downloading of extractable files.
  *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
@@ -13,7 +13,7 @@
  * @author  Jan Schneider <jan@horde.org>
  * @package Horde_MIME_Viewer
  */
-class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip
+class Whups_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip
 {
     /**
      * Return the full rendered version of the Horde_Mime_Part object.
@@ -27,7 +27,7 @@ class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip
      */
     protected function _render()
     {
-        if (!Horde_Util::getFormData('zip_attachment')) {
+        if (!($zip_atc = Horde_Util::getFormData('zip_attachment'))) {
             $this->_callback = array($this, '_whupsCallback');
             return parent::_render();
         }
@@ -35,13 +35,24 @@ class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip
         /* Send the requested file. Its position in the zip archive is located
          * in 'zip_attachment'. */
         $data = $this->_mimepart->getContents();
-        $zip = Horde_Compress::factory('zip');
-        $fileKey = Horde_Util::getFormData('zip_attachment') - 1;
-        $zipInfo = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_LIST));
+
+        if (!($zip = $this->getConfigParam('zip'))) {
+            $zip = Horde_Compress::factory('zip');
+            $this->setConfigParam('zip', $zip);
+        }
+
+        $fileKey = $zip_atc - 1;
+        $zipInfo = $zip->decompress($data, array(
+            'action' => Horde_Compress_Zip::ZIP_LIST
+        ));
 
         /* Verify that the requested file exists. */
         if (isset($zipInfo[$fileKey])) {
-            $text = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_DATA, 'info' => &$zipInfo, 'key' => $fileKey));
+            $text = $zip->decompress($data, array(
+                'action' => Horde_Compress_Zip::ZIP_DATA,
+                'info' => &$zipInfo,
+                'key' => $fileKey
+            ));
             if (!empty($text)) {
                 return array(
                     $this->_mimepart->getMimeId() => array(
@@ -53,6 +64,7 @@ class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip
                 );
             }
         }
+
         // TODO: Error reporting
         return array();
     }
@@ -85,7 +97,7 @@ class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip
              ($val['method'] == 0x0))) {
             $mime_part = $this->_mimepart;
             $mime_part->setName(basename($name));
-            $val['name'] = str_replace($name, Horde::link(Horde_Util::addParameter(Horde::applicationUrl('view.php'), array('actionID' => 'view_file', 'type' => Horde_Util::getFormData('type'), 'file' => Horde_Util::getFormData('file'), 'ticket' => Horde_Util::getFormData('ticket'), 'zip_attachment' => $key + 1))) . $name . '</a>', $val['name']);
+            $val['name'] = str_replace($name, Horde::applicationUrl('view.php')->add(array('actionID' => 'view_file', 'type' => Horde_Util::getFormData('type'), 'file' => Horde_Util::getFormData('file'), 'ticket' => Horde_Util::getFormData('ticket'), 'zip_attachment' => $key + 1))->link() . $name . '</a>', $val['name']);
         }
 
         return $val;
index 5b88390..596b7b9 100644 (file)
@@ -821,8 +821,8 @@ class Whups {
         // Can we view the attachment online?
         $mime_part = new Horde_Mime_Part();
         $mime_part->setType(Horde_Mime_Magic::extToMime($file['type']));
-        $viewer = Horde_Mime_Viewer::factory($mime_part);
-        if ($viewer && !is_a($viewer, 'Horde_Mime_Viewer_Default')) {
+        $viewer = $GLOBALS['injector']->getInstance('Horde_Mime_Viewer')->getViewer($mime_part);
+        if ($viewer && !($viewer instanceof Horde_Mime_Viewer_Default)) {
             $url = Horde_Util::addParameter(Horde::applicationUrl('view.php'),
                                       array('actionID' => 'view_file',
                                             'type' => $file['type'],
index a90fee5..7e9063c 100644 (file)
@@ -61,9 +61,7 @@ case 'view_file':
     $mime_part->setContents($data);
     $mime_part->setName($filename);
 
-    $viewer = Horde_Mime_Viewer::factory($mime_part);
-
-    $ret = $viewer->render('full');
+    $ret = $injector->getInstance('Horde_Mime_Viewer')->getViewer($mime_part)->render('full');
     reset($ret);
     $key = key($ret);
 
index 5c1a4fb..bec9220 100644 (file)
@@ -124,7 +124,7 @@ foreach ($attachments as $attachment) {
                               array('page' => $this->pageName(),
                                     'file' => $attachment['attachment_name'],
                                     'version' => $attachment['attachment_majorversion'] . '.' . $attachment['attachment_minorversion']));
-    $icon = Horde_Mime_Viewer::getIcon(Horde_Mime_Magic::filenameToMime($attachment['attachment_name']));
+    $icon = $injector->getInstance('Horde_Mime_Viewer')->getIcon(Horde_Mime_Magic::filenameToMime($attachment['attachment_name']));
     echo Horde::link($url) .
         '<img src="' . $icon . '" width="16" height="16" alt="" />&nbsp;' .
         htmlspecialchars($attachment['attachment_name']) . '</a><br />';