1: <?php
2: /**
3: * Copyright 2006-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2006-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Renderer for SMIL documents to very basic HTML.
16: *
17: * @author Jan Schneider <jan@horde.org>
18: * @author Michael Slusarz <slusarz@horde.org>
19: * @category Horde
20: * @copyright 2006-2014 Horde LLC
21: * @license http://www.horde.org/licenses/gpl GPL
22: * @package IMP
23: */
24: class IMP_Mime_Viewer_Smil extends Horde_Mime_Viewer_Smil
25: {
26: /**
27: * User-defined function callback for start elements.
28: *
29: * @param object $parser Handle to the parser instance (not used).
30: * @param string $name The name of this XML element.
31: * @param array $attrs List of this element's attributes.
32: */
33: protected function _startElement($parser, $name, $attrs)
34: {
35: switch ($name) {
36: case 'IMG':
37: if (isset($attrs['SRC']) &&
38: (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) {
39: $this->_content .= '<img src="' . $this->getConfigParam('imp_contents')->urlView($rp, 'view_attach', array('params' => array('imp_img_view' => 'data'))) . '" /><br />';
40: }
41: break;
42:
43: case 'TEXT':
44: if (isset($attrs['SRC']) &&
45: (($rp = $this->_getRelatedLink($attrs['SRC'])) !== false)) {
46: $this->_content .= htmlspecialchars($rp->getContents()) . '<br />';
47: }
48: break;
49: }
50: }
51:
52: /**
53: * Get related parts.
54: *
55: * @param string $cid The CID to search for.
56: *
57: * @return mixed Either the related MIME_Part or false.
58: */
59: protected function _getRelatedLink($cid)
60: {
61: return (($related_part = $this->getConfigParam('imp_contents')->findMimeType($this->_mimepart->getMimeId(), 'multipart/related')) &&
62: (($key = $related_part->getMetadata('related_ob')->cidSearch($cid)) !== false))
63: ? $this->getConfigParam('imp_contents')->getMIMEPart($key)
64: : false;
65: }
66:
67: }
68: