diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 20:21:25 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 20:21:25 +0000 |
commit | d81f562b712f2387fa02290bf2ca86392ab356f2 (patch) | |
tree | d666cdefbe6ac320827a2c6cb473581b46e22c4c /includes/MimeMagic.php | |
parent | 183851b06bd6c52f3cae5375f433da720d410447 (diff) |
Aktualisierung auf Version 1.8.1
Diffstat (limited to 'includes/MimeMagic.php')
-rw-r--r-- | includes/MimeMagic.php | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 30861ba3..dd197c31 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -74,7 +74,7 @@ if ($wgLoadFileinfoExtension) { * file extension, * * Instances of this class are stateles, there only needs to be one global instance -* of MimeMagic. Please use wfGetMimeMagic to get that instance. +* of MimeMagic. Please use MimeMagic::singleton() to get that instance. * @package MediaWiki */ class MimeMagic { @@ -97,8 +97,11 @@ class MimeMagic { */ var $mExtToMime= NULL; - /** Initializes the MimeMagic object. This is called by wfGetMimeMagic when instantiation - * the global MimeMagic singleton object. + /** The singleton instance + */ + private static $instance; + + /** Initializes the MimeMagic object. This is called by MimeMagic::singleton(). * * This constructor parses the mime.types and mime.info files and build internal mappings. */ @@ -227,6 +230,16 @@ class MimeMagic { } + /** + * Get an instance of this class + */ + static function &singleton() { + if ( !isset( self::$instance ) ) { + self::$instance = new MimeMagic; + } + return self::$instance; + } + /** returns a list of file extensions for a given mime type * as a space separated string. */ @@ -497,13 +510,22 @@ class MimeMagic { # NOTE: this function is available since PHP 4.3.0, but only if # PHP was compiled with --with-mime-magic or, before 4.3.2, with --enable-mime-magic. # - # On Winodws, you must set mime_magic.magicfile in php.ini to point to the mime.magic file bundeled with PHP; + # On Windows, you must set mime_magic.magicfile in php.ini to point to the mime.magic file bundeled with PHP; # sometimes, this may even be needed under linus/unix. # # Also note that this has been DEPRECATED in favor of the fileinfo extension by PECL, see above. # see http://www.php.net/manual/en/ref.mime-magic.php for details. $m= mime_content_type($file); + + if ( $m == 'text/plain' ) { + // mime_content_type sometimes considers DJVU files to be text/plain. + $deja = new DjVuImage( $file ); + if( $deja->isValid() ) { + wfDebug("$fname: (re)detected $file as image/vnd.djvu\n"); + $m = 'image/vnd.djvu'; + } + } } else wfDebug("$fname: no magic mime detector found!\n"); |