Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | var $mLastModified = '', $mETag = false; |
25 | 25 | var $mCategoryLinks = array(), $mCategories = array(), $mLanguageLinks = array(); |
26 | 26 | |
27 | | - var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array(); |
| 27 | + var $mScripts = '', $mInlineStyles = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array(); |
28 | 28 | var $mModules = array(), $mModuleScripts = array(), $mModuleStyles = array(), $mModuleMessages = array(); |
29 | 29 | var $mResourceLoader; |
30 | 30 | var $mInlineMsg = array(); |
— | — | @@ -2268,12 +2268,9 @@ |
2269 | 2269 | |
2270 | 2270 | $ret .= implode( "\n", array( |
2271 | 2271 | $this->getHeadLinks( $sk ), |
2272 | | - $this->buildCssLinks(), |
2273 | | - $this->getHeadItems(), |
| 2272 | + $this->buildCssLinks( $sk ), |
| 2273 | + $this->getHeadItems() |
2274 | 2274 | ) ); |
2275 | | - if ( $sk->usercss ) { |
2276 | | - $ret .= Html::inlineStyle( $sk->usercss ); |
2277 | | - } |
2278 | 2275 | |
2279 | 2276 | if ( $wgUseTrackbacks && $this->isArticleRelated() ) { |
2280 | 2277 | $ret .= $this->getTitle()->trackbackRDF(); |
— | — | @@ -2623,29 +2620,6 @@ |
2624 | 2621 | } |
2625 | 2622 | } |
2626 | 2623 | } |
2627 | | - |
2628 | | - // Split the styles into three groups |
2629 | | - $styles = array( 'other' => array(), 'user' => array(), 'site' => array() ); |
2630 | | - $resourceLoader = $this->getResourceLoader(); |
2631 | | - foreach ( $this->getModuleStyles() as $name ) { |
2632 | | - $group = $resourceLoader->getModule( $name )->getGroup(); |
2633 | | - // Modules in groups named "other" or anything different than "user" or "site" will |
2634 | | - // be placed in the "other" group |
2635 | | - $styles[isset( $styles[$group] ) ? $group : 'other'][] = $name; |
2636 | | - } |
2637 | | - |
2638 | | - // We want site and user styles to override dynamically added styles from modules, but we want |
2639 | | - // dynamically added styles to override statically added styles from other modules. So the order |
2640 | | - // has to be other, dynamic, site, user |
2641 | | - // Add statically added styles for other modules |
2642 | | - $tags[] = $this->makeResourceLoaderLink( $sk, $styles['other'], 'styles' ); |
2643 | | - // Add marker tag to mark the place where the client-side loader should inject dynamic styles |
2644 | | - // We use a <meta> tag with a made-up name for this because that's valid HTML |
2645 | | - $tags[] = Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ); |
2646 | | - // Add site and user styles |
2647 | | - $tags[] = $this->makeResourceLoaderLink( |
2648 | | - $sk, array_merge( $styles['site'], $styles['user'] ), 'styles' |
2649 | | - ); |
2650 | 2624 | return implode( "\n", $tags ); |
2651 | 2625 | } |
2652 | 2626 | |
— | — | @@ -2696,15 +2670,42 @@ |
2697 | 2671 | * @param $style_css Mixed: inline CSS |
2698 | 2672 | */ |
2699 | 2673 | public function addInlineStyle( $style_css ){ |
2700 | | - $this->mScripts .= Html::inlineStyle( $style_css ); |
| 2674 | + $this->mInlineStyles .= Html::inlineStyle( $style_css ); |
2701 | 2675 | } |
2702 | 2676 | |
2703 | 2677 | /** |
2704 | 2678 | * Build a set of <link>s for the stylesheets specified in the $this->styles array. |
2705 | 2679 | * These will be applied to various media & IE conditionals. |
| 2680 | + * @param $sk Skin object |
2706 | 2681 | */ |
2707 | | - public function buildCssLinks() { |
2708 | | - return implode( "\n", $this->buildCssLinksArray() ); |
| 2682 | + public function buildCssLinks( $sk ) { |
| 2683 | + $ret = ''; |
| 2684 | + // Add ResourceLoader styles |
| 2685 | + // Split the styles into three groups |
| 2686 | + $styles = array( 'other' => array(), 'user' => array(), 'site' => array() ); |
| 2687 | + $resourceLoader = $this->getResourceLoader(); |
| 2688 | + foreach ( $this->getModuleStyles() as $name ) { |
| 2689 | + $group = $resourceLoader->getModule( $name )->getGroup(); |
| 2690 | + // Modules in groups named "other" or anything different than "user" or "site" will |
| 2691 | + // be placed in the "other" group |
| 2692 | + $styles[isset( $styles[$group] ) ? $group : 'other'][] = $name; |
| 2693 | + } |
| 2694 | + |
| 2695 | + // We want site and user styles to override dynamically added styles from modules, but we want |
| 2696 | + // dynamically added styles to override statically added styles from other modules. So the order |
| 2697 | + // has to be other, dynamic, site, user |
| 2698 | + // Add statically added styles for other modules |
| 2699 | + $ret .= $this->makeResourceLoaderLink( $sk, $styles['other'], 'styles' ); |
| 2700 | + // Add normal styles added through addStyle()/addInlineStyle() here |
| 2701 | + $ret .= implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles; |
| 2702 | + // Add marker tag to mark the place where the client-side loader should inject dynamic styles |
| 2703 | + // We use a <meta> tag with a made-up name for this because that's valid HTML |
| 2704 | + $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ); |
| 2705 | + // Add site and user styles |
| 2706 | + $ret .= $this->makeResourceLoaderLink( |
| 2707 | + $sk, array_merge( $styles['site'], $styles['user'] ), 'styles' |
| 2708 | + ); |
| 2709 | + return $ret; |
2709 | 2710 | } |
2710 | 2711 | |
2711 | 2712 | public function buildCssLinksArray() { |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -219,7 +219,7 @@ |
220 | 220 | $tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces ); |
221 | 221 | $tpl->set( 'html5version', $wgHtml5Version ); |
222 | 222 | $tpl->set( 'headlinks', $out->getHeadLinks( $this ) ); |
223 | | - $tpl->set( 'csslinks', $out->buildCssLinks() ); |
| 223 | + $tpl->set( 'csslinks', $out->buildCssLinks( $this ) ); |
224 | 224 | |
225 | 225 | if( $wgUseTrackbacks && $out->isArticleRelated() ) { |
226 | 226 | $tpl->set( 'trackbackhtml', $out->getTitle()->trackbackRDF() ); |