From: Chad Horohoe Date: Wed, 2 Jul 2008 23:25:20 +0000 (+0000) Subject: Trying this again. Define XML mimetypes in new global called $wgXMLMimeTypes. Used... X-Git-Tag: 1.31.0-rc.0~46787 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=53914531b83f5bfb2cf6baaeb3417c3ffbd2f5b0;p=lhc%2Fweb%2Fwiklou.git Trying this again. Define XML mimetypes in new global called $wgXMLMimeTypes. Used for MimeMagic detection of svg, etc. Now with less code and more documentation. :) --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a6e1dd87b7..23c776b40c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -64,6 +64,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN previously it was choosen based on $wgParserCacheType * $wgExtensionAliasesFiles option to simplify adding aliases to special pages provided by extensions, in a similar way to $wgExtensionMessagesFiles +* Added $wgXMLMimeTypes, an array of XML mimetypes we can check for + with MimeMagic. === New features in 1.13 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6aae1d6578..07423a461c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -366,6 +366,18 @@ $wgMimeDetectorCommand= NULL; # use internal mime_content_type function, availab */ $wgTrivialMimeDetection= false; +/** + * Additional XML types we can allow via mime-detection. + * array = ( 'rootElement' => 'associatedMimeType' ) + */ +$wgXMLMimeTypes = array( + 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml', + 'svg' => 'image/svg+xml', + 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram', + 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml? + 'html' => 'text/html', // application/xhtml+xml? +); + /** * To set 'pretty' URL paths for actions other than * plain page views, add to this array. For instance: diff --git a/includes/MimeMagic.php b/includes/MimeMagic.php index 01d33c7e6a..ec4505ab28 100644 --- a/includes/MimeMagic.php +++ b/includes/MimeMagic.php @@ -457,18 +457,10 @@ class MimeMagic { */ $xml = new XmlTypeCheck( $file ); if( $xml->wellFormed ) { - $types = array( - 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml', - 'svg' => 'image/svg+xml', - 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram', - 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml? - 'html' => 'text/html', // application/xhtml+xml? - ); - if( isset( $types[$xml->rootElement] ) ) { - $mime = $types[$xml->rootElement]; - return $mime; + global $wgXMLMimeTypes; + if( isset( $wgXMLMimeTypes[$xml->rootElement] ) ) { + return $wgXMLMimeTypes[$xml->rootElement]; } else { - /// Fixme -- this would be the place to allow additional XML type checks return 'application/xml'; } }