1: <?php
2: /**
3: * The Horde_Mime_Viewer_Mspowerpoint class renders out Microsoft Powerpoint
4: * documents in HTML format by using the xlHtml package.
5: *
6: * Copyright 1999-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 Anil Madhavapeddy <anil@recoil.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_Mspowerpoint extends Horde_Mime_Viewer_Base
17: {
18: /**
19: * This driver's display capabilities.
20: *
21: * @var array
22: */
23: protected $_capability = array(
24: 'full' => true,
25: 'info' => false,
26: 'inline' => false,
27: 'raw' => false
28: );
29:
30: /**
31: * Constructor.
32: *
33: * @param Horde_Mime_Part $mime_part The object with the data to be
34: * rendered.
35: * @param array $conf Configuration:
36: * <pre>
37: * 'location' - (string) Location of the ppthtml binary.
38: * </pre>
39: *
40: * @throws InvalidArgumentException
41: */
42: public function __construct(Horde_Mime_Part $part, array $conf = array())
43: {
44: $this->_required = array_merge($this->_required, array(
45: 'location'
46: ));
47:
48: parent::__construct($part, $conf);
49: }
50:
51: /**
52: * Return the full rendered version of the Horde_Mime_Part object.
53: *
54: * @return array See parent::render().
55: */
56: protected function _render()
57: {
58: /* Check to make sure the viewer program exists. */
59: if (!($location = $this->getConfigParam('location')) ||
60: !file_exists($location)) {
61: return array();
62: }
63:
64: $data = '';
65:
66: $tmp_ppt = $this->_getTempFile();
67: file_put_contents($tmp_ppt, $this->_mimepart->getContents());
68:
69: $fh = popen($location . ' ' . $tmp_ppt . ' 2>&1', 'r');
70: while (($rc = fgets($fh, 8192))) {
71: $data .= $rc;
72: }
73: pclose($fh);
74:
75: return $this->_renderReturn(
76: $data,
77: 'text/html; charset=UTF-8'
78: );
79: }
80:
81: }
82: