| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 10 /** 11 * class lmbMimeType. 12 * 13 * @package net 14 * @version $Id: lmbMimeType.class.php 5953 2007-06-06 16:28:38Z wiliam $ 15 */ 16 class lmbMimeType 17 { 18 static protected $mime_types = array( 19 'avi' => 'video/avi', 20 'aif' => 'audio/x-aiff', 21 'aifc' => 'audio/x-aiff', 22 'aiff' => 'audio/x-aiff', 23 'bmp' => 'image/bmp', 24 'doc' => 'application/msword', 25 'flv' => 'video/x-flv', 26 'gif' => 'image/gif', 27 'html' => 'text/html', 28 'jpeg' => 'image/pjpeg', 29 'jpg' => 'image/jpeg', 30 'js' => 'text/javascript', 31 'mpeg' => 'video/mpeg', 32 'mp3' => 'audio/mpeg', 33 'mpg' => 'video/mpeg', 34 'msg' => 'message/rfc822', 35 'pdf' => 'application/pdf', 36 'png' => 'image/png', 37 'ppt' => 'application/vnd.ms-powerpoint', 38 'psd' => 'image/psd', 39 'rtf' => 'text/rtf', 40 'swf' => 'application/x-shockwave-flash', 41 'txt' => 'text/plain', 42 'wav' => 'audio/x-wav', 43 'xls' => 'application/vnd.ms-excel', 44 'zip' => 'application/x-zip-compressed', 45 'zip' => 'application/zip', 46 ); 47 48 static protected $flipped_mime_types = array(); 49 50 static function getExtension($mime_type) 51 { 52 if(!self :: $flipped_mime_types) 53 self :: $flipped_mime_types = array_flip(self :: $mime_types); 54 55 $mime_type = strtolower($mime_type); 56 57 return isset(self :: $flipped_mime_types[$mime_type]) 58 ? self :: $flipped_mime_types[$mime_type] 59 : null; 60 } 61 62 static function getMimeType($extension) 63 { 64 $extension = ltrim(strtolower($extension), '.'); 65 66 return isset(self :: $mime_types[$extension]) 67 ? self :: $mime_types[$extension] 68 : null; 69 } 70 71 static function getFileMimeType($file) 72 { 73 if($info = pathinfo($file)) 74 { 75 if(isset($info['extension'])) 76 return self :: getMimeType($info['extension']); 77 } 78 } 79 } 80 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |