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 '<pre>' . sprintf(_("The program used to view this data type (%s) was not found on the system."), $GLOBALS['mime_drivers']['horde']['wordperfect']['location']) . '</pre>';
+ /* 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()
+ );
}
}