class MimeMagic {
/**
- * Mapping of media types to arrays of mime types.
- * This is used by findMediaType and getMediaType, respectively
- */
+ * Mapping of media types to arrays of mime types.
+ * This is used by findMediaType and getMediaType, respectively
+ */
var $mMediaTypes = null;
/** Map of mime type aliases
- */
+ */
var $mMimeTypeAliases = null;
- /** map of mime types to file extensions (as a space seprarated list)
- */
+ /** map of mime types to file extensions (as a space separated list)
+ */
var $mMimeToExt = null;
- /** map of file extensions types to mime types (as a space seprarated list)
- */
+ /** map of file extensions types to mime types (as a space separated list)
+ */
var $mExtToMime = null;
/** IEContentAnalyzer instance
*/
function __construct() {
/**
- * --- load mime.types ---
- */
+ * --- load mime.types ---
+ */
global $wgMimeTypeFile, $IP, $wgLoadFileinfoExtension;
* @return MimeMagic
*/
public static function &singleton() {
- if ( !isset( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new MimeMagic;
}
return self::$instance;
return $m;
}
-
/**
* Tests if the extension matches the given mime type. Returns true if a
* match was found, null if the mime type is unknown, and false if the
$ext = $this->getExtensionsForType( $mime );
if ( !$ext ) {
- return null; // Unknown mime type
+ return null; // Unknown mime type
}
$ext = explode( ' ', $ext );
* If $mime is "application/x-opc+zip" and isMatchingExtension( $ext, $mime )
* gives true, return the result of guessTypesForExtension($ext).
*
- * @param $mime String: the mime type, typically guessed from a file's content.
- * @param $ext String: the file extension, as taken from the file name
+ * @param string $mime the mime type, typically guessed from a file's content.
+ * @param string $ext the file extension, as taken from the file name
*
* @return string the mime type
*/
/**
* 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
+ * file formats that may be missed or misinterpreted by the default mime
* detection (namely XML based formats like XHTML or SVG, as well as ZIP
* based formats like OPC/ODF files).
*
- * @param $file String: the file to check
+ * @param string $file the file to check
* @param $ext Mixed: the file extension, or true (default) to extract it from the filename.
* Set it to false to ignore the extension. DEPRECATED! Set to false, use
* improveTypeFromExtension($mime, $ext) later to improve mime type.
}
if ( $script_type ) {
- if ( $script_type !== "UTF-8" && $script_type !== "ASCII") {
+ if ( $script_type !== "UTF-8" && $script_type !== "ASCII" ) {
// Quick and dirty fold down to ASCII!
$pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' );
$chars = unpack( $pack[$script_type], substr( $head, 2 ) );
* header data. Currently works for OpenDocument and OpenXML types...
* If can't tell, returns 'application/zip'.
*
- * @param $header String: some reasonably-sized chunk of file header
+ * @param string $header some reasonably-sized chunk of file header
* @param $tail String: the tail of the file
* @param $ext Mixed: the file extension, or true to extract it from the filename.
* Set it to false (default) to ignore the extension. DEPRECATED! Set to false,
# TODO: remove the block below, as soon as improveTypeFromExtension is used everywhere
if ( $ext !== true && $ext !== false ) {
/** This is the mode used by getPropsFromPath
- * These mime's are stored in the database, where we don't really want
- * x-opc+zip, because we use it only for internal purposes
- */
+ * These mime's are stored in the database, where we don't really want
+ * x-opc+zip, because we use it only for internal purposes
+ */
if ( $this->isMatchingExtension( $ext, $mime) ) {
/* A known file extension for an OPC file,
- * find the proper mime type for that file extension */
+ * find the proper mime type for that file extension
+ */
$mime = $this->guessTypesForExtension( $ext );
} else {
$mime = "application/zip";
* Internal mime type detection. Detection is done using an external
* program, if $wgMimeDetectorCommand is set. Otherwise, the fileinfo
* extension and mime_content_type are tried (in this order), if they
- * are available. If the dections fails and $ext is not false, the mime
+ * are available. If the detections fails and $ext is not false, the mime
* type is guessed from the file extension, using guessTypesForExtension.
*
* If the mime type is still unknown, getimagesize is used to detect the
* mime type if the file is an image. If no mime type can be determined,
* this function returns 'unknown/unknown'.
*
- * @param $file String: the file to check
+ * @param string $file the file to check
* @param $ext Mixed: the file extension, or true (default) to extract it from the filename.
* Set it to false to ignore the extension. DEPRECATED! Set to false, use
* improveTypeFromExtension($mime, $ext) later to improve mime type.
# 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 Windows, 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 bundled 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.
* @todo analyse file if need be
* @todo look at multiple extension, separately and together.
*
- * @param $path String: full path to the image file, in case we have to look at the contents
+ * @param string $path full path to the image file, in case we have to look at the contents
* (if null, only the mime type is used to determine the media type code).
- * @param $mime String: mime type. If null it will be guessed using guessMimeType.
+ * @param string $mime mime type. If null it will be guessed using guessMimeType.
*
* @return (int?string?) a value to be used with the MEDIATYPE_xxx constants.
*/
* File extensions are represented by a string starting with a dot (.) to
* distinguish them from mime types.
*
- * This funktion relies on the mapping defined by $this->mMediaTypes
+ * This function relies on the mapping defined by $this->mMediaTypes
* @access private
* @return int|string
*/
* Get the MIME types that various versions of Internet Explorer would
* detect from a chunk of the content.
*
- * @param $fileName String: the file name (unused at present)
- * @param $chunk String: the first 256 bytes of the file
- * @param $proposed String: the MIME type proposed by the server
+ * @param string $fileName the file name (unused at present)
+ * @param string $chunk the first 256 bytes of the file
+ * @param string $proposed the MIME type proposed by the server
* @return Array
*/
public function getIEMimeTypes( $fileName, $chunk, $proposed ) {