*/
protected function makeResourceLoaderLink( Skin $skin, $modules, $only, $useESI = false ) {
global $wgUser, $wgLang, $wgLoadScript, $wgResourceLoaderUseESI,
- $wgResourceLoaderInlinePrivateModules;
+ $wgResourceLoaderInlinePrivateModules, $wgRequest;
// Lazy-load ResourceLoader
// TODO: Should this be a static function of ResourceLoader instead?
// TODO: Divide off modules starting with "user", and add the user parameter to them
'skin' => $skin->getSkinName(),
'only' => $only,
);
+ // Propagate printable and handheld parameters if present
+ if ( $wgRequest->getBool( 'printable' ) ) {
+ $query['printable'] = 1;
+ }
+ if ( $wgRequest->getBool( 'handheld' ) ) {
+ $query['handheld'] = 1;
+ }
if ( !count( $modules ) ) {
return '';
}
if( isset( $options['media'] ) ) {
- $media = $this->transformCssMedia( $options['media'] );
+ $media = self::transformCssMedia( $options['media'] );
if( is_null( $media ) ) {
return '';
}
* @param $media String: current value of the "media" attribute
* @return String: modified value of the "media" attribute
*/
- function transformCssMedia( $media ) {
+ public static function transformCssMedia( $media ) {
global $wgRequest, $wgHandheldForIPhone;
// Switch in on-screen display for media testing
public static function makeCombinedStyles( array $styles ) {
$out = '';
foreach ( $styles as $media => $style ) {
- $out .= "@media $media {\n" . str_replace( "\n", "\n\t", "\t" . $style ) . "\n}\n";
+ // Transform the media type based on request params and config
+ // The way that this relies on $wgRequest to propagate request params is slightly evil
+ $media = OutputPage::transformCssMedia( $media );
+
+ if ( $media === null ) {
+ // Skip
+ } else if ( $media === '' || $media == 'all' ) {
+ // Don't output invalid or frivolous @media statements
+ $out .= "$style\n";
+ } else {
+ $out .= "@media $media {\n" . str_replace( "\n", "\n\t", "\t" . $style ) . "\n}\n";
+ }
}
return $out;
}