From 4e3a77083d40706887165d5b70f5caa1e8cd2485 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 12 Nov 2008 11:51:40 -0700 Subject: [PATCH] Update wordperfect Viewer. --- .../Mime/lib/Horde/Mime/Viewer/wordperfect.php | 53 ++++++++++++---------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php b/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php index 588af5232..3090eb995 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php @@ -16,43 +16,46 @@ class Horde_Mime_Viewer_wordperfect extends Horde_Mime_Viewer_Driver { /** - * Render out the current data using wpd2html. + * 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() { - /* Check to make sure the program actually exists. */ - if (!file_exists($GLOBALS['mime_drivers']['horde']['wordperfect']['location'])) { - return '
' . sprintf(_("The program used to view this data type (%s) was not found on the system."), $GLOBALS['mime_drivers']['horde']['wordperfect']['location']) . '
'; + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); } $tmp_wpd = Horde::getTempFile('wpd'); $tmp_output = Horde::getTempFile('wpd'); - $args = " $tmp_wpd > $tmp_output"; - $fh = fopen($tmp_wpd, 'w'); - fwrite($fh, $this->mime_part->getContents()); - fclose($fh); + file_put_contents($tmp_wpd, $this->_mimepart->getContents()); - exec($GLOBALS['mime_drivers']['horde']['wordperfect']['location'] . $args); + exec($this->_conf['location'] . " $tmp_wpd > $tmp_output"); - if (!file_exists($tmp_output)) { - return _("Unable to translate this WordPerfect document"); + if (file_exists($tmp_output)) { + $data = file_get_contents($tmp_output); + } else { + $data = _("Unable to translate this WordPerfect document"); } - return file_get_contents($tmp_output); - } - - /** - * 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(); + return array( + 'data' => $data, + 'type' => 'text/html; charset=' . NLS::getCharset() + ); } } -- 2.11.0