1: <?php
2: /**
3: * The Horde_Mime_Viewer_Report class is a wrapper used to load the
4: * appropriate Horde_Mime_Viewer for multipart/report data (RFC 3462).
5: *
6: * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
14: * @package Mime_Viewer
15: */
16: class Horde_Mime_Viewer_Report extends Horde_Mime_Viewer_Base
17: {
18: /**
19: * Constructor.
20: *
21: * @param Horde_Mime_Part $mime_part The object with the data to be
22: * rendered.
23: * @param array $conf Configuration:
24: * <pre>
25: * 'viewer_callback' - (callback) A callback to a factory that will
26: * return the appropriate viewer for the embedded
27: * MIME type. Is passed three parameters: the
28: * current driver object, the MIME part object, and
29: * the MIME type to use.
30: * </pre>
31: */
32: public function __construct(Horde_Mime_Part $part, array $conf = array())
33: {
34: parent::__construct($part, $conf);
35: }
36:
37: /**
38: * Return the underlying MIME Viewer for this part.
39: *
40: * @return mixed A Horde_Mime_Viewer object, or false if not found.
41: */
42: protected function _getViewer()
43: {
44: if (!($callback = $this->getConfigParam('viewer_callback'))) {
45: return false;
46: }
47:
48: if (!($type = $this->_mimepart->getContentTypeParameter('report-type'))) {
49: /* This is a broken RFC 3462 message, since 'report-type' is
50: * mandatory. Try to determine the report-type by looking at the
51: * sub-type of the second body part. */
52: $parts = $this->_mimepart->getParts();
53: if (!isset($parts[1])) {
54: return false;
55: }
56: $type = $parts[1]->getSubType();
57: }
58:
59: return call_user_func($callback, $this, $this->_mimepart, 'message/' . Horde_String::lower($type));
60: }
61:
62: }
63: