[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The MIME_Viewer_images class allows images to be displayed. 4 * 5 * $Horde: framework/MIME/MIME/Viewer/images.php,v 1.18.8.9 2006/01/01 21:28:25 jan Exp $ 6 * 7 * Copyright 2002-2006 Michael Slusarz <slusarz@bigworm.colorado.edu> 8 * 9 * See the enclosed file COPYING for license information (LGPL). If you 10 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 11 * 12 * @author Michael Slusarz <slusarz@bigworm.colorado.edu> 13 * @since Horde 2.2 14 * @package Horde_MIME_Viewer 15 */ 16 class MIME_Viewer_images extends MIME_Viewer { 17 18 /** 19 * Return the content-type. 20 * 21 * @return string The content-type of the output. 22 */ 23 function getType() 24 { 25 $type = $this->mime_part->getType(); 26 if ($GLOBALS['browser']->isBrowser('mozilla') && 27 ($type == 'image/pjpeg')) { 28 /* image/jpeg and image/pjpeg *appear* to be the same 29 * entity, but Mozilla don't seem to want to accept the 30 * latter. For our purposes, we will treat them the 31 * same. */ 32 return 'image/jpeg'; 33 } elseif ($type == 'image/x-png') { 34 /* image/x-png is equivalent to image/png. */ 35 return 'image/png'; 36 } else { 37 return $type; 38 } 39 } 40 41 /** 42 * Generate HTML output for a javascript auto-resize view window. 43 * 44 * @access private 45 * 46 * @param string $url The URL which contains the actual image data. 47 * @param string $title The title to use for the page. 48 * 49 * @return string The HTML output. 50 */ 51 function _popupImageWindow($url, $title) 52 { 53 global $browser; 54 55 $str = <<<EOD 56 <html> 57 <head> 58 <title>$title</title> 59 <style type="text/css"><!-- body { margin:0px; padding:0px; } --></style> 60 EOD; 61 62 /* Only use javascript if we are using a DOM capable browser. */ 63 if ($browser->getFeature('dom')) { 64 /* Translate '&' entities to '&' for JS URL links. */ 65 $url = str_replace('&', '&', $url); 66 67 /* Mozilla and IE determine window dimensions in different ways. */ 68 if ($browser->isBrowser('msie')) { 69 $iWidth_code = 'document.body.clientWidth;'; 70 $iHeight_code = 'document.body.clientHeight;'; 71 } else { 72 $iWidth_code = 'window.innerWidth;'; 73 $iHeight_code = 'window.innerHeight;'; 74 } 75 76 /* Javascript display. */ 77 $loading = _("Loading..."); 78 $str .= <<<EOD 79 <script type="text/javascript"> 80 function resizeWindow() { 81 window.moveTo(0, 0); 82 document.getElementById('splash').style.display = 'none'; 83 document.getElementById('disp_image').style.display = 'block'; 84 var iWidth = document.images[0].width - $iWidth_code 85 var iHeight = document.images[0].height - $iHeight_code 86 window.resizeBy(iWidth, iHeight); 87 self.focus(); 88 } 89 </script></head> 90 <body onload="resizeWindow();"><span id="splash" style="color:gray;font-family:sans-serif;padding:2px;">$loading</span><img id="disp_image" style="display:none;" src="$url" /></body></html> 91 EOD; 92 } else { 93 /* Non-javascript display. */ 94 $img_txt = _("Image"); 95 $str .= <<<EOD 96 </head> 97 <body bgcolor="#ffffff" topmargin="0" marginheight="0" leftmargin="0" marginwidth="0"> 98 <img border="0" src="$url" alt="$img_txt" /> 99 </body> 100 </html> 101 EOD; 102 } 103 104 return $str; 105 } 106 107 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |