Update smil Viewer.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 Nov 2008 18:50:23 +0000 (11:50 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 12 Nov 2008 18:50:23 +0000 (11:50 -0700)
framework/Mime/lib/Horde/Mime/Viewer/smil.php
imp/lib/Mime/Viewer/smil.php

index e5078f1..6138a5c 100644 (file)
@@ -24,24 +24,41 @@ class Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_Driver
      *
      * @var string
      */
-    protected $_content = '';
+    protected $_content;
 
     /**
-     * Renders out the contents.
+     * Can this driver render various views?
      *
-     * @param array $params  Any parameters the Viewer may need.
+     * @var boolean
+     */
+    protected $_capability = array(
+        'embedded' => false,
+        'full' => true,
+        'info' => false,
+        'inline' => false
+    );
+
+    /**
+     * Return the full rendered version of the Horde_Mime_Part object.
      *
-     * @return string  The rendered contents.
+     * @return array  See Horde_Mime_Viewer_Driver::render().
      */
-    public function render($params = array())
+    protected function _render()
     {
+        $this->_content = '';
+
         /* Create a new parser and set its default properties. */
         $this->_parser = xml_parser_create();
         xml_set_object($this->_parser, $this);
         xml_set_element_handler($this->_parser, '_startElement', '_endElement');
         xml_set_character_data_handler($this->_parser, '_defaultHandler');
-        xml_parse($this->_parser, $this->mime_part->getContents(), true);
-        return $this->_content;
+        xml_parse($this->_parser, $this->_mimepart->getContents(), true);
+        xml_parser_free($this->_parser);
+
+        return array(
+            'data' => $this->_content,
+            'type' => 'text/html; charset=' . NLS::getCharset()
+        );
     }
 
     /**
@@ -85,14 +102,4 @@ class Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_Driver
             $this->_content .= ' ' . htmlspecialchars($data);
         }
     }
-
-    /**
-     * Return the MIME content type of the rendered content.
-     *
-     * @return string  The content type of the output.
-     */
-    public function getType()
-    {
-        return 'text/html; charset=' . NLS::getCharset();
-    }
 }
index 76b039b..1e79b55 100644 (file)
 class IMP_Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_smil
 {
     /**
-     * The MIME_Contents object, needed for the _callback() function.
-     *
-     * @var MIME_Contents
-     */
-    protected $_contents;
-
-    /**
-     * The list of related parts to the current part.
-     *
-     * @var array
-     */
-    protected  $_related = null;
-
-    /**
-     * Renders out the contents.
-     *
-     * @param array $params  Any parameters the Viewer may need.
-     *
-     * @return string  The rendered contents.
-     */
-    public function render($params)
-    {
-        $this->_contents = &$params[0];
-        return parent::render($params);
-    }
-
-    /**
      * User-defined function callback for start elements.
      *
      * @param object $parser  Handle to the parser instance.
@@ -51,20 +24,16 @@ class IMP_Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_smil
     {
         switch ($name) {
         case 'IMG':
-            if (isset($attrs['SRC'])) {
-                $rp = $this->_getRelatedLink($attrs['SRC']);
-                if ($rp !== false) {
-                    $this->_content .= '<img src="' . $this->_contents->urlView($rp, 'view_attach') . '" alt="" /><br />';
-                }
+            if (isset($attrs['SRC']) &&
+                (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) {
+                $this->_content .= '<img src="' . $this->_params['contents']->urlView($rp, 'view_attach') . '" alt="" /><br />';
             }
             break;
 
         case 'TEXT':
-            if (isset($attrs['SRC'])) {
-                $rp = $this->_getRelatedLink($attrs['SRC']);
-                if ($rp !== false) {
-                    $this->_content .= htmlspecialchars($rp->getContents()) . '<br />';
-                }
+            if (isset($attrs['SRC']) &&
+                (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) {
+                $this->_content .= htmlspecialchars($rp->getContents()) . '<br />';
             }
             break;
         }
@@ -79,21 +48,9 @@ class IMP_Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_smil
      */
     protected function _getRelatedLink($cid)
     {
-        if ($this->_related === null) {
-            $this->_related = false;
-            $related = $this->mime_part->getInformation('related_part');
-            if ($related !== false) {
-                $relatedPart = $this->_contents->getMIMEPart($related);
-                $this->_related = $relatedPart->getCIDList();
-            }
-        }
-
-        if ($this->_related) {
-            $key = array_search('<' . $cid . '>', $this->_related);
-            if ($key !== false) {
-                $cid_part = $this->_contents->getDecodedMIMEPart($key);
-                return $cid_part;
-            }
+        if (isset($this->_params['related_id']) &&
+            (($key = array_search(trim($cid, '<>', $this->_params['related_cids']))) !== false)) {
+            return $this->_param['contents']->getMIMEPart($key);
         }
 
         return false;