Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -109,7 +109,12 @@ |
110 | 110 | * addStyle() and draws from the /skins folder. |
111 | 111 | */ |
112 | 112 | public function addExtensionStyle( $url ) { |
113 | | - $linkarr = array( 'rel' => 'stylesheet', 'href' => $url, 'type' => 'text/css' ); |
| 113 | + global $wgHtml5; |
| 114 | + $linkarr = array( 'rel' => 'stylesheet', 'href' => $url ); |
| 115 | + if ( !$wgHtml5 ) { |
| 116 | + # type attribute is mandatory in XHTML 1.0 Transitional |
| 117 | + $linkarr['type'] = 'text/css'; |
| 118 | + } |
114 | 119 | array_push( $this->mExtStyles, $linkarr ); |
115 | 120 | } |
116 | 121 | |
— | — | @@ -118,7 +123,7 @@ |
119 | 124 | * @param string $file filename in skins/common or complete on-server path (/foo/bar.js) |
120 | 125 | */ |
121 | 126 | function addScriptFile( $file ) { |
122 | | - global $wgStylePath, $wgStyleVersion, $wgJsMimeType, $wgScript, $wgUser; |
| 127 | + global $wgStylePath, $wgStyleVersion, $wgJsMimeType, $wgScript, $wgUser, $wgHtml5; |
123 | 128 | global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgEnableScriptLoader, $wgScriptPath; |
124 | 129 | |
125 | 130 | if( substr( $file, 0, 1 ) == '/' ) { |
— | — | @@ -163,15 +168,11 @@ |
164 | 169 | } |
165 | 170 | |
166 | 171 | // if the script loader did not find a way to add the script than add using addScript |
167 | | - $this->addScript( |
168 | | - Xml::element( 'script', |
169 | | - array( |
170 | | - 'type' => $wgJsMimeType, |
171 | | - 'src' => wfAppendQuery( $path, $this->getURIDparam() ), |
172 | | - ), |
173 | | - '', false |
174 | | - ) |
175 | | - ); |
| 172 | + $attrs = array( 'src' => wfAppendQuery( $path, $this->getURIDparam() ) ); |
| 173 | + if ( !$wgHtml5 ) { |
| 174 | + $attrs['type'] = $wgJsMimeType; |
| 175 | + } |
| 176 | + $this->addScript( Xml::element( 'script', $attrs, '', false ) ); |
176 | 177 | } |
177 | 178 | |
178 | 179 | /** |
— | — | @@ -180,7 +181,8 @@ |
181 | 182 | * different page load types (edit, upload, view, etc) |
182 | 183 | */ |
183 | 184 | function addCoreScripts2Top(){ |
184 | | - global $wgEnableScriptLoader, $wgStyleVersion, $wgJSAutoloadLocalClasses, $wgJsMimeType, $wgScriptPath, $wgEnableJS2system; |
| 185 | + global $wgEnableScriptLoader, $wgStyleVersion, $wgJSAutoloadLocalClasses, |
| 186 | + $wgJsMimeType, $wgScriptPath, $wgEnableJS2system, $wgHtml5; |
185 | 187 | //@@todo we should deprecate wikibits in favor of mv_embed and native jQuery functions |
186 | 188 | |
187 | 189 | if( $wgEnableJS2system ){ |
— | — | @@ -195,12 +197,11 @@ |
196 | 198 | $so = ''; |
197 | 199 | foreach( $core_classes as $s ){ |
198 | 200 | if( isset( $wgJSAutoloadLocalClasses[$s] ) ){ |
199 | | - $so.= Xml::element( 'script', array( |
200 | | - 'type' => $wgJsMimeType, |
201 | | - 'src' => "{$wgScriptPath}/{$wgJSAutoloadLocalClasses[$s]}?" . $this->getURIDparam() |
202 | | - ), |
203 | | - '', false |
204 | | - ); |
| 201 | + $attrs = array( 'src' => "{$wgScriptPath}/{$wgJSAutoloadLocalClasses[$s]}?" . $this->getURIDparam() ); |
| 202 | + if ( !$wgHtml5 ) { |
| 203 | + $attrs['type'] = $wgJsMimeType; |
| 204 | + } |
| 205 | + $so.= Xml::element( 'script', $attrs, '', false ); |
205 | 206 | } |
206 | 207 | } |
207 | 208 | $this->mScripts = $so . $this->mScripts; |
— | — | @@ -213,7 +214,7 @@ |
214 | 215 | */ |
215 | 216 | function addScriptClass( $js_class ){ |
216 | 217 | global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses, |
217 | | - $wgJsMimeType, $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath; |
| 218 | + $wgJsMimeType, $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgHtml5; |
218 | 219 | |
219 | 220 | if( isset( $wgJSAutoloadClasses[$js_class] ) || isset( $wgJSAutoloadLocalClasses[$js_class] ) ){ |
220 | 221 | if( $wgEnableScriptLoader ){ |
— | — | @@ -228,16 +229,12 @@ |
229 | 230 | }else if( isset( $wgJSAutoloadLocalClasses[$js_class] ) ){ |
230 | 231 | $path.= $wgJSAutoloadLocalClasses[$js_class]; |
231 | 232 | } |
232 | | - $urlApend = ( $wgDebugJavaScript) ? time() : $wgStyleVersion; |
233 | | - $this->addScript( |
234 | | - Xml::element( 'script', |
235 | | - array( |
236 | | - 'type' => $wgJsMimeType, |
237 | | - 'src' => "$path?" . $urlApend, |
238 | | - ), |
239 | | - '', false |
240 | | - ) |
241 | | - ); |
| 233 | + $urlAppend = ( $wgDebugJavaScript) ? time() : $wgStyleVersion; |
| 234 | + $attrs = array( 'src' => "$path?$urlAppend" ); |
| 235 | + if ( !$wgHtml5 ) { |
| 236 | + $attrs['type'] = $wgJsMimeType; |
| 237 | + } |
| 238 | + $this->addScript( Xml::element( 'script', $attrs, '', false ) ); |
242 | 239 | } |
243 | 240 | return true; |
244 | 241 | } |
— | — | @@ -250,7 +247,7 @@ |
251 | 248 | * @param $forcClassAry Boolean: false by default |
252 | 249 | */ |
253 | 250 | function getScriptLoaderJs( $forceClassAry = false ){ |
254 | | - global $wgJsMimeType, $wgStyleVersion, $wgRequest, $wgDebugJavaScript; |
| 251 | + global $wgJsMimeType, $wgStyleVersion, $wgRequest, $wgDebugJavaScript, $wgHtml5; |
255 | 252 | |
256 | 253 | if( !$forceClassAry ){ |
257 | 254 | $class_list = implode( ',', $this->mScriptLoaderClassList ); |
— | — | @@ -268,14 +265,11 @@ |
269 | 266 | |
270 | 267 | //generate the unique request param (combine with the most recent revision id of any wiki page with the $wgStyleVersion var) |
271 | 268 | |
272 | | - |
273 | | - return Xml::element( 'script', |
274 | | - array( |
275 | | - 'type' => $wgJsMimeType, |
276 | | - 'src' => wfScript( 'mwScriptLoader' ) . "?class={$class_list}{$debug_param}&".$this->getURIDparam(), |
277 | | - ), |
278 | | - '', false |
279 | | - ); |
| 269 | + $attrs = array( 'src' => wfScript( 'mwScriptLoader' ) . "?class={$class_list}{$debug_param}&".$this->getURIDparam() ); |
| 270 | + if ( !$wgHtml5 ) { |
| 271 | + $attrs['type'] = $wgJsMimeType; |
| 272 | + } |
| 273 | + return Xml::element( 'script', $attrs, '', false ); |
280 | 274 | } |
281 | 275 | |
282 | 276 | function getURIDparam(){ |
— | — | @@ -304,8 +298,9 @@ |
305 | 299 | * @param string $script JavaScript text, no <script> tags |
306 | 300 | */ |
307 | 301 | function addInlineScript( $script ) { |
308 | | - global $wgJsMimeType; |
309 | | - $this->mScripts .= "\t\t<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n\t\t$script\n\t\t/*]]>*/</script>\n"; |
| 302 | + global $wgJsMimeType, $wgHtml5; |
| 303 | + $this->mScripts .= "\t\t<script" . ($wgHtml5 ? '' : " type=\"$wgJsMimeType\"") |
| 304 | + . ">/*<![CDATA[*/\n\t\t$script\n\t\t/*]]>*/</script>\n"; |
310 | 305 | } |
311 | 306 | |
312 | 307 | function getScript() { |
— | — | @@ -1940,8 +1935,24 @@ |
1941 | 1936 | return "\t" . implode( "\n\t", $links ); |
1942 | 1937 | } |
1943 | 1938 | |
| 1939 | + /** |
| 1940 | + * Return a <link rel="stylesheet"> with the given parameters. |
| 1941 | + * |
| 1942 | + * @param $style string Relative or absolute URL. If $style begins with |
| 1943 | + * '/', 'http:', or 'https:' it's used for the href as-is. Otherwise, |
| 1944 | + * it's assumed to refer to some file within $wgStylePath, so the URL |
| 1945 | + * used is "$wgStylePath/$style?$wgStyleVersion". |
| 1946 | + * @param $options array Associative array with the following possible |
| 1947 | + * keys: |
| 1948 | + * 'dir': 'rtl' or 'ltr'. If the site language direction doesn't match |
| 1949 | + * this, the empty string is returned. |
| 1950 | + * 'media': Contents of the media attribute (will be mangled a bit, |
| 1951 | + * e.g. 'screen' -> 'screen,projection' so Opera fullscreen works) |
| 1952 | + * 'condition': Wrap in an IE conditional comment, e.g., 'lt IE 7'. |
| 1953 | + * @return string Raw HTML |
| 1954 | + */ |
1944 | 1955 | protected function styleLink( $style, $options ) { |
1945 | | - global $wgRequest; |
| 1956 | + global $wgRequest, $wgHtml5; |
1946 | 1957 | |
1947 | 1958 | if( isset( $options['dir'] ) ) { |
1948 | 1959 | global $wgContLang; |
— | — | @@ -1970,9 +1981,11 @@ |
1971 | 1982 | |
1972 | 1983 | $attribs = array( |
1973 | 1984 | 'rel' => 'stylesheet', |
1974 | | - 'href' => $url, |
1975 | | - 'type' => 'text/css' ); |
1976 | | - if( $media ) { |
| 1985 | + 'href' => $url ); |
| 1986 | + if ( !$wgHtml5 ) { |
| 1987 | + $attribs['type'] = 'text/css'; |
| 1988 | + } |
| 1989 | + if ( $media ) { |
1977 | 1990 | $attribs['media'] = $media; |
1978 | 1991 | } |
1979 | 1992 | |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -333,9 +333,10 @@ |
334 | 334 | } |
335 | 335 | |
336 | 336 | static function makeVariablesScript( $data ) { |
337 | | - global $wgJsMimeType; |
| 337 | + global $wgJsMimeType, $wgHtml5; |
338 | 338 | |
339 | | - $r = array( "<script type=\"$wgJsMimeType\">/*<![CDATA[*/" ); |
| 339 | + $r = array( "<script" . ( $wgHtml5 ? '' : " type=\"$wgJsMimeType\"" ) |
| 340 | + . ">/*<![CDATA[*/" ); |
340 | 341 | foreach ( $data as $name => $value ) { |
341 | 342 | $encValue = Xml::encodeJsVar( $value ); |
342 | 343 | $r[] = "var $name = $encValue;"; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -198,6 +198,7 @@ |
199 | 199 | numbers outside the permitted ranges), etc. |
200 | 200 | ** The summary attribute has been removed from tables of contents. summary is |
201 | 201 | obsolete in HTML 5 and wasn't useful here anyway. |
| 202 | +** Remove unnecessary type="" for CSS/JS in HTML 5 output |
202 | 203 | * New hook SpecialRandomBeforeSQL allows extensions to modify or replace the SQL |
203 | 204 | query used in Special:Random and subclasses, deprecating the $wgExtraRandompageSQL |
204 | 205 | config variable |