Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2221,7 +2221,7 @@ |
2222 | 2222 | */ |
2223 | 2223 | protected function makeResourceLoaderLink( Skin $skin, $modules, $only, $useESI = false ) { |
2224 | 2224 | global $wgUser, $wgLang, $wgLoadScript, $wgResourceLoaderUseESI, |
2225 | | - $wgResourceLoaderInlinePrivateModules; |
| 2225 | + $wgResourceLoaderInlinePrivateModules, $wgRequest; |
2226 | 2226 | // Lazy-load ResourceLoader |
2227 | 2227 | // TODO: Should this be a static function of ResourceLoader instead? |
2228 | 2228 | // TODO: Divide off modules starting with "user", and add the user parameter to them |
— | — | @@ -2231,6 +2231,13 @@ |
2232 | 2232 | 'skin' => $skin->getSkinName(), |
2233 | 2233 | 'only' => $only, |
2234 | 2234 | ); |
| 2235 | + // Propagate printable and handheld parameters if present |
| 2236 | + if ( $wgRequest->getBool( 'printable' ) ) { |
| 2237 | + $query['printable'] = 1; |
| 2238 | + } |
| 2239 | + if ( $wgRequest->getBool( 'handheld' ) ) { |
| 2240 | + $query['handheld'] = 1; |
| 2241 | + } |
2235 | 2242 | |
2236 | 2243 | if ( !count( $modules ) ) { |
2237 | 2244 | return ''; |
— | — | @@ -2615,7 +2622,7 @@ |
2616 | 2623 | } |
2617 | 2624 | |
2618 | 2625 | if( isset( $options['media'] ) ) { |
2619 | | - $media = $this->transformCssMedia( $options['media'] ); |
| 2626 | + $media = self::transformCssMedia( $options['media'] ); |
2620 | 2627 | if( is_null( $media ) ) { |
2621 | 2628 | return ''; |
2622 | 2629 | } |
— | — | @@ -2647,7 +2654,7 @@ |
2648 | 2655 | * @param $media String: current value of the "media" attribute |
2649 | 2656 | * @return String: modified value of the "media" attribute |
2650 | 2657 | */ |
2651 | | - function transformCssMedia( $media ) { |
| 2658 | + public static function transformCssMedia( $media ) { |
2652 | 2659 | global $wgRequest, $wgHandheldForIPhone; |
2653 | 2660 | |
2654 | 2661 | // Switch in on-screen display for media testing |
Index: trunk/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -558,7 +558,18 @@ |
559 | 559 | public static function makeCombinedStyles( array $styles ) { |
560 | 560 | $out = ''; |
561 | 561 | foreach ( $styles as $media => $style ) { |
562 | | - $out .= "@media $media {\n" . str_replace( "\n", "\n\t", "\t" . $style ) . "\n}\n"; |
| 562 | + // Transform the media type based on request params and config |
| 563 | + // The way that this relies on $wgRequest to propagate request params is slightly evil |
| 564 | + $media = OutputPage::transformCssMedia( $media ); |
| 565 | + |
| 566 | + if ( $media === null ) { |
| 567 | + // Skip |
| 568 | + } else if ( $media === '' || $media == 'all' ) { |
| 569 | + // Don't output invalid or frivolous @media statements |
| 570 | + $out .= "$style\n"; |
| 571 | + } else { |
| 572 | + $out .= "@media $media {\n" . str_replace( "\n", "\n\t", "\t" . $style ) . "\n}\n"; |
| 573 | + } |
563 | 574 | } |
564 | 575 | return $out; |
565 | 576 | } |