diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-05-16 20:58:53 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-05-16 20:58:53 +0000 |
commit | cecb985bee3bdd252e1b8dc0bd500b37cd52be01 (patch) | |
tree | 17266aa237742640aabee7856f0202317a45d540 /includes/MimeMagic.php | |
parent | 0bac06c301f2a83edb0236e4c2434da16848d549 (diff) |
Aktualisierung auf MediaWiki 1.10.0
Plugins angepasst und verbessert
kleine Korrekturen am Design
Diffstat (limited to 'includes/MimeMagic.php')
-rw-r--r-- | includes/MimeMagic.php | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index ca05dbb3..db35535d 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -1,7 +1,6 @@ <?php /** Module defining helper functions for detecting and dealing with mime types. * - * @package MediaWiki */ /** Defines a set of well known mime types @@ -23,9 +22,10 @@ image/x-bmp bmp image/gif gif image/jpeg jpeg jpg jpe image/png png -image/svg+xml svg +image/svg+xml image/svg svg image/tiff tiff tif image/vnd.djvu djvu +image/x-portable-pixmap ppm text/plain txt text/html html htm video/ogg ogm ogg @@ -51,9 +51,10 @@ image/x-bmp image/bmp [BITMAP] image/gif [BITMAP] image/jpeg [BITMAP] image/png [BITMAP] -image/svg image/svg+xml [DRAWING] +image/svg+xml [DRAWING] image/tiff [BITMAP] image/vnd.djvu [BITMAP] +image/x-portable-pixmap [BITMAP] text/plain [TEXT] text/html [TEXT] video/ogg [VIDEO] @@ -70,13 +71,13 @@ if ($wgLoadFileinfoExtension) { if(!extension_loaded('fileinfo')) dl('fileinfo.' . PHP_SHLIB_SUFFIX); } -/** Implements functions related to mime types such as detection and mapping to -* file extension, -* -* Instances of this class are stateles, there only needs to be one global instance -* of MimeMagic. Please use MimeMagic::singleton() to get that instance. -* @package MediaWiki -*/ +/** + * Implements functions related to mime types such as detection and mapping to + * file extension. + * + * Instances of this class are stateles, there only needs to be one global instance + * of MimeMagic. Please use MimeMagic::singleton() to get that instance. + */ class MimeMagic { /** @@ -105,7 +106,7 @@ class MimeMagic { * * This constructor parses the mime.types and mime.info files and build internal mappings. */ - function MimeMagic() { + function __construct() { /* * --- load mime.types --- */ @@ -149,7 +150,7 @@ class MimeMagic { if (empty($ext)) continue; - if (@$this->mMimeToExt[$mime]) $this->mMimeToExt[$mime] .= ' '.$ext; + if ( !empty($this->mMimeToExt[$mime])) $this->mMimeToExt[$mime] .= ' '.$ext; else $this->mMimeToExt[$mime]= $ext; $extensions= explode(' ',$ext); @@ -158,7 +159,7 @@ class MimeMagic { $e= trim($e); if (empty($e)) continue; - if (@$this->mExtToMime[$e]) $this->mExtToMime[$e] .= ' '.$mime; + if ( !empty($this->mExtToMime[$e])) $this->mExtToMime[$e] .= ' '.$mime; else $this->mExtToMime[$e]= $mime; } } @@ -262,7 +263,7 @@ class MimeMagic { function getTypesForExtension($ext) { $ext= strtolower($ext); - $r= @$this->mExtToMime[$ext]; + $r= isset( $this->mExtToMime[$ext] ) ? $this->mExtToMime[$ext] : null; return $r; } @@ -341,7 +342,7 @@ class MimeMagic { } - /** mime type detection. This uses detectMimeType to detect the mim type of the file, + /** mime type detection. This uses detectMimeType to detect the mime type of the file, * but applies additional checks to determine some well known file formats that may be missed * or misinterpreter by the default mime detection (namely xml based formats like XHTML or SVG). * @@ -399,8 +400,8 @@ class MimeMagic { #print "<br>ANALYSING $file ($mime): doctype= $doctype; tag= $tag<br>"; - if (strpos($doctype,"-//W3C//DTD SVG")===0) $mime= "image/svg"; - elseif ($tag==="svg") $mime= "image/svg"; + if (strpos($doctype,"-//W3C//DTD SVG")===0) $mime= "image/svg+xml"; + elseif ($tag==="svg") $mime= "image/svg+xml"; elseif (strpos($doctype,"-//W3C//DTD XHTML")===0) $mime= "text/html"; elseif ($tag==="html") $mime= "text/html"; } @@ -424,7 +425,9 @@ class MimeMagic { $match= array(); $prog= ""; - if (preg_match('%/?([^\s]+/)(w+)%sim',$head,$match)) $script= $match[2]; + if (preg_match('%/?([^\s]+/)(w+)%sim',$head,$match)) { + $script= $match[2]; // FIXME: $script variable not used; should this be "$prog = $match[2];" instead? + } $mime= "application/x-$prog"; } |