*
* @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()
+ );
}
/**
$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();
- }
}
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.
{
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;
}
*/
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;