Implements #7667 : allow XHTML namespaces customization. Patch by Evan Miller
authorAntoine Musso <hashar@users.mediawiki.org>
Sun, 7 Jan 2007 22:31:07 +0000 (22:31 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sun, 7 Jan 2007 22:31:07 +0000 (22:31 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/OutputPage.php
includes/SkinTemplate.php
skins/MonoBook.php

index ce60388..564c39c 100644 (file)
@@ -478,6 +478,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 3706) Allow users to be exempted from IP blocks. The ipblock-exempt permission
   key has been added to enable this behaviour, by default assigned to sysops.
 * (bug 7948) importDump.php now warn that Recentchanges need to be rebuild.
+* (bug 7667) allow XHTML namespaces customization
 
 
 == Languages updated ==
index 00a375b..c2aa24a 100644 (file)
@@ -687,6 +687,15 @@ $wgMimeType                        = 'text/html';
 $wgJsMimeType                  = 'text/javascript';
 $wgDocType                     = '-//W3C//DTD XHTML 1.0 Transitional//EN';
 $wgDTD                         = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd';
+$wgXhtmlDefaultNamespace       = 'http://www.w3.org/1999/xhtml';
+
+# Permit other namespaces in addition to the w3.org default.
+# Use the prefix for the key and the namespace for the value. For
+# example:
+# $wgXhtmlNamespaces['svg'] = 'http://www.w3.org/2000/svg';
+# Normally we wouldn't have to define this in the root <html>
+# element, but IE needs it there in some circumstances.
+$wgXhtmlNamespaces             = array();
 
 /** Enable to allow rewriting dates in page text.
  * DOES NOT FORMAT CORRECTLY FOR MOST LANGUAGES */
index d83e1e1..4ca9e88 100644 (file)
@@ -1043,6 +1043,7 @@ class OutputPage {
         */
        public function headElement() {
                global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
+               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
                global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion;
 
                if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
@@ -1058,7 +1059,11 @@ class OutputPage {
                }
 
                $rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
-               $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
+               $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
+               foreach($wgXhtmlNamespaces as $tag => $ns) {
+                       $ret .= "xmlns:{$tag}=\"{$ns}\" ";
+               }
+               $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
                $ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
                array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
 
index ac020b7..ff09547 100644 (file)
@@ -135,6 +135,7 @@ class SkinTemplate extends Skin {
                global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
                global $wgScript, $wgStylePath, $wgContLanguageCode;
                global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
+               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
                global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks;
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
@@ -246,6 +247,8 @@ class SkinTemplate extends Skin {
                        $tpl->set( 'trackbackhtml', null );
                }
 
+               $tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace );
+               $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
                $tpl->setRef( 'mimetype', $wgMimeType );
                $tpl->setRef( 'jsmimetype', $wgJsMimeType );
                $tpl->setRef( 'charset', $wgOutputEncoding );
index 390a0c1..b490418 100644 (file)
@@ -51,7 +51,10 @@ class MonoBookTemplate extends QuickTemplate {
                wfSuppressWarnings();
 
 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
+<html xmlns="<?php $this->text('xhtmldefaultnamespace') ?>" <?php 
+       foreach($this->data['xhtmlnamespaces'] as $tag => $ns) {
+               ?>xmlns:<?php echo "{$tag}=\"{$ns}\" ";
+       } ?>xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
        <head>
                <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
                <?php $this->html('headlinks') ?>