r36960 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36959‎ | r36960 | r36961 >
Date:23:25, 2 July 2008
Author:demon
Status:old (Comments)
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:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/MimeMagic.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -64,6 +64,8 @@
6565 previously it was choosen based on $wgParserCacheType
6666 * $wgExtensionAliasesFiles option to simplify adding aliases to special pages
6767 provided by extensions, in a similar way to $wgExtensionMessagesFiles
 68+* Added $wgXMLMimeTypes, an array of XML mimetypes we can check for
 69+ with MimeMagic.
6870
6971 === New features in 1.13 ===
7072
Index: trunk/phase3/includes/MimeMagic.php
@@ -457,18 +457,10 @@
458458 */
459459 $xml = new XmlTypeCheck( $file );
460460 if( $xml->wellFormed ) {
461 - $types = array(
462 - 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml',
463 - 'svg' => 'image/svg+xml',
464 - 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram',
465 - 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml?
466 - 'html' => 'text/html', // application/xhtml+xml?
467 - );
468 - if( isset( $types[$xml->rootElement] ) ) {
469 - $mime = $types[$xml->rootElement];
470 - return $mime;
 461+ global $wgXMLMimeTypes;
 462+ if( isset( $wgXMLMimeTypes[$xml->rootElement] ) ) {
 463+ return $wgXMLMimeTypes[$xml->rootElement];
471464 } else {
472 - /// Fixme -- this would be the place to allow additional XML type checks
473465 return 'application/xml';
474466 }
475467 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -367,6 +367,18 @@
368368 $wgTrivialMimeDetection= false;
369369
370370 /**
 371+ * Additional XML types we can allow via mime-detection.
 372+ * array = ( 'rootElement' => 'associatedMimeType' )
 373+ */
 374+$wgXMLMimeTypes = array(
 375+ 'http://www.w3.org/2000/svg:svg' => 'image/svg+xml',
 376+ 'svg' => 'image/svg+xml',
 377+ 'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram',
 378+ 'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml?
 379+ 'html' => 'text/html', // application/xhtml+xml?
 380+);
 381+
 382+/**
371383 * To set 'pretty' URL paths for actions other than
372384 * plain page views, add to this array. For instance:
373385 * 'edit' => "$wgScriptPath/edit/$1"

Comments

#Comment by Josef1124 (talk | contribs)   02:18, 16 July 2013

add.372

#Comment by Josef1124 (talk | contribs)   02:18, 16 July 2013

add.372

Status & tagging log