MediaWiki r36960 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r36959‎ | r36960 (on ViewVC)‎ | r36961 >
Date:23:25, 2 July 2008
Author:demon
Status:old
Tags:
Comment:
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. :)
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/MimeMagic.php
===================================================================
--- trunk/phase3/includes/MimeMagic.php	(revision 36959)
+++ trunk/phase3/includes/MimeMagic.php	(revision 36960)
@@ -457,18 +457,10 @@
 		 */
 		$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';
 			}
 		}
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 36959)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 36960)
@@ -367,6 +367,18 @@
 $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:
  *   'edit' => "$wgScriptPath/edit/$1"
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 36959)
+++ trunk/phase3/RELEASE-NOTES	(revision 36960)
@@ -64,6 +64,8 @@
   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 ===
 

Status & tagging log

  • 15:28, 12 September 2011 Meno25 (Talk | contribs) changed the status of r36960 [removed: ok added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox