From ba41a77d7a4691df7ce8c45ed26309ef88ea0bea Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 11 Nov 2008 00:38:55 -0700 Subject: [PATCH] Clean up images Driver to new API. --- framework/Mime/lib/Horde/Mime/Viewer/images.php | 98 +++++++++---------------- 1 file changed, 33 insertions(+), 65 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/images.php b/framework/Mime/lib/Horde/Mime/Viewer/images.php index 3cc13714a..cb72df398 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/images.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/images.php @@ -13,83 +13,51 @@ class Horde_Mime_Viewer_images extends Horde_Mime_Viewer_Driver { /** - * Return the content-type. + * Can this driver render various views? * - * @return string The content-type of the output. + * @var boolean */ - public function getType() + protected $_capability = array( + 'embedded' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() { - $type = $this->mime_part->getType(); - if ($GLOBALS['browser']->isBrowser('mozilla') && - ($type == 'image/pjpeg')) { - /* image/jpeg and image/pjpeg *appear* to be the same - * entity, but Mozilla don't seem to want to accept the - * latter. For our purposes, we will treat them the - * same. */ - return 'image/jpeg'; - } elseif ($type == 'image/x-png') { - /* image/x-png is equivalent to image/png. */ - return 'image/png'; - } else { - return $type; - } + return array( + 'data' => $this->_mimepart->getContents(), + 'type' => $this->_getType() + ); } /** - * Generate HTML output for a javascript auto-resize view window. + * Return the content-type to use for the image. * - * @param string $url The URL which contains the actual image data. - * @param string $title The title to use for the page. - * - * @return string The HTML output. + * @return string The content-type of the image. */ - protected function _popupImageWindow($url, $title) + protected function _getType() { - global $browser; - - $str = << - -$title - -EOD; + $type = $this->_mimepart->getType(); - /* Only use javascript if we are using a DOM capable browser. */ - if ($browser->getFeature('dom')) { - /* Translate '&' entities to '&' for JS URL links. */ - $url = str_replace('&', '&', $url); + switch ($type) { + case 'image/pjpeg': + /* image/jpeg and image/pjpeg *appear* to be the same entity, but + * Mozilla (for one) don't seem to want to accept the latter. */ + return 'image/jpeg'; - /* Javascript display. */ - $loading = _("Loading..."); - $str .= << -function resizeWindow() -{ + case 'image/x-png': + /* image/x-png == image/png. */ + return 'image/png'; - var h, img = document.getElementById('disp_image'), w; - document.getElementById('splash').style.display = 'none'; - img.style.display = 'block'; - window.moveTo(0, 0); - h = img.height - (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)); - w = img.width - (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth)); - window.resizeBy(w, h); - self.focus(); -} - -$loading -EOD; - } else { - /* Non-javascript display. */ - $img_txt = _("Image"); - $str .= << - -$img_txt - - -EOD; + default: + return $type; } - - return $str; } } -- 2.11.0