From 1fb5f6da76b33ef4fa0bda4db1fdc705ba20a5f7 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 12 Nov 2008 11:49:51 -0700 Subject: [PATCH] Update RPM viewer. --- framework/Mime/lib/Horde/Mime/Viewer/rpm.php | 46 +++++++++++++++------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/rpm.php b/framework/Mime/lib/Horde/Mime/Viewer/rpm.php index 8d99d2a8e..fcebc8908 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/rpm.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/rpm.php @@ -14,42 +14,44 @@ class Horde_Mime_Viewer_rpm extends Horde_Mime_Viewer_Driver { /** - * Render out the RPM contents. + * 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']['rpm']['location'])) { - return '
' . sprintf(_("The program used to view this data type (%s) was not found on the system."), $GLOBALS['mime_drivers']['horde']['rpm']['location']) . '
'; + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); } $data = ''; $tmp_rpm = Horde::getTempFile('horde_rpm'); - $fh = fopen($tmp_rpm, 'w'); - fwrite($fh, $this->mime_part->getContents()); - fclose($fh); + file_put_contents($tmp_rpm, $this->_mimepart->getContents()); - $fh = popen($GLOBALS['mime_drivers']['horde']['rpm']['location'] . " -qip $tmp_rpm 2>&1", 'r'); + $fh = popen($this->_conf['location'] . " -qip $tmp_rpm 2>&1", 'r'); while (($rc = fgets($fh, 8192))) { $data .= $rc; } pclose($fh); - return '
' . htmlentities($data) . '
'; - } - - /** - * 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' => '
' . htmlentities($data) . '
', + 'type' => 'text/html; charset=' . NLS::getCharset() + ); } } -- 2.11.0