Add $wgAdditionalXMLTypes, an array of XML mimetypes we can check for with MimeMagic.
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 30 Jun 2008 14:46:19 +0000 (14:46 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 30 Jun 2008 14:46:19 +0000 (14:46 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/MimeMagic.php

index 717e4e4..0b31962 100644 (file)
@@ -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 $wgAdditionalXMLTypes, an array of XML mimetypes we can check for
+  with MimeMagic.
 
 === New features in 1.13 ===
 
index 6aae1d6..6abdd95 100644 (file)
@@ -366,6 +366,11 @@ $wgMimeDetectorCommand= NULL; # use internal mime_content_type function, availab
  */
 $wgTrivialMimeDetection= false;
 
+/**
+ * Additional XML types we can allow via mime-detection.
+ */
+$wgAdditionalXMLTypes = array();
+
 /**
  * To set 'pretty' URL paths for actions other than
  * plain page views, add to this array. For instance:
index 01d33c7..aa495f6 100644 (file)
@@ -457,6 +457,7 @@ class MimeMagic {
                 */
                $xml = new XmlTypeCheck( $file );
                if( $xml->wellFormed ) {
+                       global $wgAdditionalXMLTypes;
                        $types = array(
                                'http://www.w3.org/2000/svg:svg'                => 'image/svg+xml',
                                'svg'                                           => 'image/svg+xml',
@@ -464,11 +465,12 @@ class MimeMagic {
                                '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;
+                               return $types[$xml->rootElement];
+                       } elseif( isset( $wgAdditionalXMLTypes[$xml->rootElement] ) ) {
+                               return $wgAdditionalXMLTypes[$xml->rootElement];
                        } else {
-                               /// Fixme -- this would be the place to allow additional XML type checks
                                return 'application/xml';
                        }
                }