Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2079,9 +2079,8 @@ |
2080 | 2080 | * @return String: The doctype, opening <html>, and head element. |
2081 | 2081 | */ |
2082 | 2082 | public function headElement( Skin $sk, $includeStyle = true ) { |
2083 | | - global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; |
2084 | | - global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version; |
2085 | | - global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5, $wgWellFormedXml; |
| 2083 | + global $wgContLanguageCode, $wgOutputEncoding, $wgMimeType; |
| 2084 | + global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5; |
2086 | 2085 | global $wgUser, $wgRequest, $wgLang; |
2087 | 2086 | |
2088 | 2087 | if ( $sk->commonPrintStylesheet() ) { |
— | — | @@ -2089,58 +2088,29 @@ |
2090 | 2089 | } |
2091 | 2090 | $sk->setupUserCss( $this ); |
2092 | 2091 | |
2093 | | - $ret = ''; |
| 2092 | + $dir = $wgContLang->getDir(); |
| 2093 | + $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir ); |
| 2094 | + $ret = Html::htmlHeader( $htmlAttribs ); |
2094 | 2095 | |
2095 | | - if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) { |
2096 | | - $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n"; |
2097 | | - } |
2098 | | - |
2099 | 2096 | if ( $this->getHTMLTitle() == '' ) { |
2100 | 2097 | $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) ); |
2101 | 2098 | } |
2102 | 2099 | |
2103 | | - $dir = $wgContLang->getDir(); |
2104 | | - |
2105 | | - $htmlAttribs = array( 'lang' => $wgContLanguageCode, 'dir' => $dir ); |
2106 | 2100 | if ( $wgHtml5 ) { |
2107 | | - if ( $wgWellFormedXml ) { |
2108 | | - # Unknown elements and attributes are okay in XML, but unknown |
2109 | | - # named entities are well-formedness errors and will break XML |
2110 | | - # parsers. Thus we need a doctype that gives us appropriate |
2111 | | - # entity definitions. The HTML5 spec permits four legacy |
2112 | | - # doctypes as obsolete but conforming, so let's pick one of |
2113 | | - # those, although it makes our pages look like XHTML1 Strict. |
2114 | | - # Isn't compatibility great? |
2115 | | - $ret .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; |
2116 | | - } else { |
2117 | | - # Much saner. |
2118 | | - $ret .= "<!doctype html>\n"; |
2119 | | - } |
2120 | | - if ( $wgHtml5Version ) { |
2121 | | - $htmlAttribs['version'] = $wgHtml5Version; |
2122 | | - } |
| 2101 | + # More succinct than <meta http-equiv=Content-Type>, has the |
| 2102 | + # same effect |
| 2103 | + $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n"; |
2123 | 2104 | } else { |
2124 | | - $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n"; |
2125 | | - $htmlAttribs['xmlns'] = $wgXhtmlDefaultNamespace; |
2126 | | - foreach ( $wgXhtmlNamespaces as $tag => $ns ) { |
2127 | | - $htmlAttribs["xmlns:$tag"] = $ns; |
2128 | | - } |
2129 | 2105 | $this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" ); |
2130 | 2106 | } |
2131 | | - $ret .= Html::openElement( 'html', $htmlAttribs ) . "\n"; |
2132 | 2107 | |
2133 | 2108 | $openHead = Html::openElement( 'head' ); |
2134 | 2109 | if ( $openHead ) { |
2135 | 2110 | # Don't bother with the newline if $head == '' |
2136 | 2111 | $ret .= "$openHead\n"; |
2137 | 2112 | } |
2138 | | - $ret .= "<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n"; |
| 2113 | + $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n"; |
2139 | 2114 | |
2140 | | - if ( $wgHtml5 ) { |
2141 | | - # More succinct than <meta http-equiv=Content-Type>, has the |
2142 | | - # same effect |
2143 | | - $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n"; |
2144 | | - } |
2145 | 2115 | |
2146 | 2116 | $ret .= implode( "\n", array( |
2147 | 2117 | $this->getHeadLinks(), |
Index: trunk/phase3/includes/Html.php |
— | — | @@ -561,4 +561,66 @@ |
562 | 562 | } |
563 | 563 | return self::element( 'textarea', $attribs, $value ); |
564 | 564 | } |
| 565 | + |
| 566 | + /** |
| 567 | + * Constructs the opening html-tag with necessary doctypes depending on |
| 568 | + * global variables. |
| 569 | + * |
| 570 | + * @param $attribs array Associative array of miscellaneous extra |
| 571 | + * attributes, passed to Html::element() of html tag. |
| 572 | + * @return string Raw HTML |
| 573 | + */ |
| 574 | + public static function htmlHeader( $attribs = array() ) { |
| 575 | + $ret = ''; |
| 576 | + |
| 577 | + global $wgMimeType, $wgOutputEncoding; |
| 578 | + if ( self::isXmlMimeType( $wgMimeType ) ) { |
| 579 | + $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n"; |
| 580 | + } |
| 581 | + |
| 582 | + global $wgHtml5, $wgHtml5Version, $wgWellFormedXml, $wgDocType, $wgDTD; |
| 583 | + global $wgXhtmlNamespaces, $wgXhtmlDefaultNamespace; |
| 584 | + if ( $wgHtml5 ) { |
| 585 | + if ( $wgWellFormedXml ) { |
| 586 | + # Unknown elements and attributes are okay in XML, but unknown |
| 587 | + # named entities are well-formedness errors and will break XML |
| 588 | + # parsers. Thus we need a doctype that gives us appropriate |
| 589 | + # entity definitions. The HTML5 spec permits four legacy |
| 590 | + # doctypes as obsolete but conforming, so let's pick one of |
| 591 | + # those, although it makes our pages look like XHTML1 Strict. |
| 592 | + # Isn't compatibility great? |
| 593 | + $ret .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; |
| 594 | + } else { |
| 595 | + # Much saner. |
| 596 | + $ret .= "<!doctype html>\n"; |
| 597 | + } |
| 598 | + if ( $wgHtml5Version ) { |
| 599 | + $attribs['version'] = $wgHtml5Version; |
| 600 | + } |
| 601 | + } else { |
| 602 | + $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\" \"$wgDTD\">\n"; |
| 603 | + $attribs['xmlns'] = $wgXhtmlDefaultNamespace; |
| 604 | + foreach ( $wgXhtmlNamespaces as $tag => $ns ) { |
| 605 | + $attribs["xmlns:$tag"] = $ns; |
| 606 | + } |
| 607 | + } |
| 608 | + return $ret . Html::openElement( 'html', $attribs ) . "\n"; |
| 609 | + } |
| 610 | + |
| 611 | + /** |
| 612 | + * Determines if the given mime type is xml. |
| 613 | + * |
| 614 | + * @param $mimetype string MimeType |
| 615 | + * @return Boolean |
| 616 | + */ |
| 617 | + public static function isXmlMimeType( $mimetype ) { |
| 618 | + switch ( $mimetype ) { |
| 619 | + case 'text/xml': |
| 620 | + case 'application/xhtml+xml': |
| 621 | + case 'application/xml': |
| 622 | + return true; |
| 623 | + default: |
| 624 | + return false; |
| 625 | + } |
| 626 | + } |
565 | 627 | } |
Index: trunk/phase3/includes/installer/WebInstallerOutput.php |
— | — | @@ -79,6 +79,21 @@ |
80 | 80 | return 'rtl'; |
81 | 81 | } |
82 | 82 | |
| 83 | + function getLanguageCode() { |
| 84 | + global $wgLang; |
| 85 | + if( !is_object( $wgLang ) ) |
| 86 | + return 'en'; |
| 87 | + else |
| 88 | + return $wgLang->getCode(); |
| 89 | + } |
| 90 | + |
| 91 | + function getHeadAttribs() { |
| 92 | + return array( |
| 93 | + 'dir' => $this->getDir(), |
| 94 | + 'lang' => $this->getLanguageCode(), |
| 95 | + ); |
| 96 | + } |
| 97 | + |
83 | 98 | function headerDone() { |
84 | 99 | return $this->headerDone; |
85 | 100 | } |
— | — | @@ -99,24 +114,20 @@ |
100 | 115 | } |
101 | 116 | |
102 | 117 | ?> |
103 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
104 | | -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
| 118 | +<?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?> |
105 | 119 | <head> |
106 | 120 | <meta name="robots" content="noindex, nofollow" /> |
107 | 121 | <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
108 | 122 | <title><?php $this->outputTitle(); ?></title> |
109 | | - <link rel="stylesheet" type="text/css" href="../skins/common/shared.css"/> |
110 | | - <link rel="stylesheet" type="text/css" href="../skins/monobook/main.css"/> |
111 | | - <link rel="stylesheet" type="text/css" href="../skins/common/config.css"/> |
112 | | - <script type="text/javascript"><!-- |
113 | | -<?php echo "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) . ";\n"; ?> |
114 | | - // --> |
115 | | - </script> |
116 | | - <?php $this->outputJQuery(); ?> |
117 | | - <script type="text/javascript" src="../skins/common/config.js"></script> |
| 123 | + <?php echo Html::linkedStyle( '../skins/common/shared.css' ) . "\n"; ?> |
| 124 | + <?php echo Html::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?> |
| 125 | + <?php echo Html::linkedStyle( '../skins/common/config.css' ) . "\n"; ?> |
| 126 | + <?php echo Html::inlineScript( "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) ) . "\n"; ?> |
| 127 | + <?php $this->outputJQuery() . "\n"; ?> |
| 128 | + <?php echo Html::linkedScript( '../skins/common/config.js' ) . "\n"; ?> |
118 | 129 | </head> |
119 | 130 | |
120 | | -<body class="<?php print $this->getDir(); ?>"> |
| 131 | +<?php echo Html::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?> |
121 | 132 | <noscript> |
122 | 133 | <style type="text/css"> |
123 | 134 | .config-help-message { display: block; } |
— | — | @@ -168,18 +179,16 @@ |
169 | 180 | } |
170 | 181 | |
171 | 182 | function outputShortHeader() { |
172 | | - |
173 | 183 | ?> |
174 | | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
175 | | -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
| 184 | +<?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?> |
176 | 185 | <head> |
177 | 186 | <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
178 | 187 | <meta name="robots" content="noindex, nofollow" /> |
179 | 188 | <title><?php $this->outputTitle(); ?></title> |
180 | | - <link rel="stylesheet" type="text/css" href="../skins/monobook/main.css"/> |
181 | | - <link rel="stylesheet" type="text/css" href="../skins/common/config.css"/> |
| 189 | + <?php echo Html::linkedStyle( '../skins/monobook/main.css' ) . "\n"; ?> |
| 190 | + <?php echo Html::linkedStyle( '../skins/common/config.css' ) . "\n"; ?> |
182 | 191 | <?php $this->outputJQuery(); ?> |
183 | | - <script type="text/javascript" src="../skins/common/config.js"></script> |
| 192 | + <?php echo Html::linkedScript( '../skins/common/config.js' ); ?> |
184 | 193 | </head> |
185 | 194 | |
186 | 195 | <body style="background-image: none"> |
— | — | @@ -193,8 +202,7 @@ |
194 | 203 | |
195 | 204 | function outputJQuery() { |
196 | 205 | global $wgJQueryVersion; |
197 | | - echo '<script type="text/javascript" src="../skins/common/jquery-' . |
198 | | - $wgJQueryVersion . '.min.js"></script>'; |
| 206 | + echo Html::linkedScript( "../skins/common/jquery-$wgJQueryVersion.min.js" ); |
199 | 207 | } |
200 | 208 | |
201 | 209 | function outputWarnings() { |