global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5, $wgWellFormedXml;
global $wgUser, $wgRequest, $wgLang;
- $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
if ( $sk->commonPrintStylesheet() ) {
$this->addStyle( 'common/wikiprintable.css', 'print' );
}
$dir = $wgContLang->getDir();
+ $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir );
if ( $wgHtml5 ) {
if ( $wgWellFormedXml ) {
# Unknown elements and attributes are okay in XML, but unknown
# Much saner.
$ret .= "<!doctype html>\n";
}
- $ret .= "<html lang=\"$wgContLanguageCode\" dir=\"$dir\"";
if ( $wgHtml5Version ) {
- $ret .= " version=\"$wgHtml5Version\"";
+ $htmlAttribs['version'] = $wgHtml5Version;
}
- $ret .= ">\n";
} else {
$ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
- $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
+ $htmlAttribs['xmlns'] = $wgXhtmlDefaultNamespace;
foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
- $ret .= "xmlns:{$tag}=\"{$ns}\" ";
+ $htmlAttribs["xmlns:$tag"] = $ns;
}
- $ret .= "lang=\"$wgContLanguageCode\" dir=\"$dir\">\n";
+ $this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" );
}
+ $ret .= Html::element( 'html', $htmlAttribs ) . "\n";
- $ret .= "<head>\n";
+ $openHead = Html::openElement( 'head' );
+ if ( $openHead ) {
+ # Don't bother with the newline if $head == ''
+ $ret .= "$openHead\n";
+ }
$ret .= "<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
+
+ if ( $wgHtml5 ) {
+ # More succinct than <meta http-equiv=Content-Type>, has the
+ # same effect
+ $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n";
+ }
+
$ret .= implode( "\n", array(
$this->getHeadLinks(),
$this->buildCssLinks(),
$ret .= $this->getTitle()->trackbackRDF();
}
- $ret .= "</head>\n";
+ $closeHead = Html::closeElement( 'head' );
+ if ( $closeHead ) {
+ $ret .= "$closeHead\n";
+ }
$bodyAttrs = array();