From fe00a6a4bd075fac13af4c2bad25baaf020e8fb2 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 12 Nov 2008 11:50:23 -0700 Subject: [PATCH] Update smil Viewer. --- framework/Mime/lib/Horde/Mime/Viewer/smil.php | 41 ++++++++++-------- imp/lib/Mime/Viewer/smil.php | 61 ++++----------------------- 2 files changed, 33 insertions(+), 69 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/smil.php b/framework/Mime/lib/Horde/Mime/Viewer/smil.php index e5078f1d3..6138a5c7e 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/smil.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/smil.php @@ -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(); - } } diff --git a/imp/lib/Mime/Viewer/smil.php b/imp/lib/Mime/Viewer/smil.php index 76b039b85..1e79b55c7 100644 --- a/imp/lib/Mime/Viewer/smil.php +++ b/imp/lib/Mime/Viewer/smil.php @@ -14,33 +14,6 @@ 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 .= '
'; - } + if (isset($attrs['SRC']) && + (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) { + $this->_content .= '
'; } break; case 'TEXT': - if (isset($attrs['SRC'])) { - $rp = $this->_getRelatedLink($attrs['SRC']); - if ($rp !== false) { - $this->_content .= htmlspecialchars($rp->getContents()) . '
'; - } + if (isset($attrs['SRC']) && + (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) { + $this->_content .= htmlspecialchars($rp->getContents()) . '
'; } 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; -- 2.11.0