add a version attribute to the <html> tag if RDFa is used with HTML5
authorDaniel Kinzler <daniel@users.mediawiki.org>
Fri, 13 Nov 2009 21:58:39 +0000 (21:58 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Fri, 13 Nov 2009 21:58:39 +0000 (21:58 +0000)
includes/DefaultSettings.php
includes/OutputPage.php
includes/Setup.php
includes/SkinTemplate.php

index d7b3a7c..80b9a89 100644 (file)
@@ -914,6 +914,12 @@ $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
  */
 $wgHtml5 = true;
 
+/**
+ * Defines the value of the version attribute in the &lt;html&gt; tag, if any.
+ * Will be initialized later if not set explicitly.
+ */
+$wgHtml5Version = null;
+
 /**
  * Enabled RDFa attributes for use in wikitext.
  */
index 47e785d..de43865 100644 (file)
@@ -1769,7 +1769,7 @@ class OutputPage {
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
                global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
-               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
+               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
                global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgEnableScriptLoader, $wgHtml5;
 
                $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
@@ -1792,7 +1792,9 @@ class OutputPage {
 
                if ( $wgHtml5 ) {
                        $ret .= "<!DOCTYPE html>\n";
-                       $ret .= "<html lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
+                       $ret .= "<html lang=\"$wgContLanguageCode\" dir=\"$dir\" ";
+                       if ($wgHtml5Version) $ret .= " version=\"$wgHtml5Version\" ";
+                       $ret .= ">\n";
                } else {
                        $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
                        $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
index 67c52c4..2a629c3 100644 (file)
@@ -230,6 +230,13 @@ if( !$wgAllowUserSkin ) {
        $wgHiddenPrefs[] = 'skin';
 }
 
+if ( !$wgHtml5Version && $wgHtml5 && $wgAllowRdfaAttributes ) {
+       # see http://www.w3.org/TR/rdfa-in-html/#document-conformance
+       if ( $wgMimeType == 'application/xhtml+xml' ) $wgHtml5Version = 'XHTML+RDFa 1.0';
+       else $wgHtml5Version = 'HTML+RDFa 1.0';
+}
+
+
 wfProfileOut( $fname.'-misc1' );
 wfProfileIn( $fname.'-memcached' );
 
index 314073f..11fb418 100644 (file)
@@ -129,7 +129,7 @@ class SkinTemplate extends Skin {
                global $wgArticle, $wgUser, $wgLang, $wgContLang;
                global $wgScript, $wgStylePath, $wgContLanguageCode;
                global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
-               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
+               global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
                global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
@@ -208,6 +208,7 @@ class SkinTemplate extends Skin {
 
                        $tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace );
                        $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
+                       $tpl->set( 'html5version', $wgHtml5Version );
                        $tpl->set( 'headlinks', $out->getHeadLinks() );
                        $tpl->set( 'csslinks', $out->buildCssLinks() );