X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fresourceloader%2FResourceLoaderSkinModule.php;h=de25d32e5458eeb5a586ff96095fca77084bfc97;hb=9c185ca85c3c58f96e866c9347c2b7f031ddb289;hp=ca6e59f2bf1bd81397bec61bff1967b54cf6994a;hpb=4427b84407e03275bdb62ca58a0fde14f3dc7be6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderSkinModule.php b/includes/resourceloader/ResourceLoaderSkinModule.php index ca6e59f2bf..de25d32e54 100644 --- a/includes/resourceloader/ResourceLoaderSkinModule.php +++ b/includes/resourceloader/ResourceLoaderSkinModule.php @@ -32,7 +32,7 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule { * @return array */ public function getStyles( ResourceLoaderContext $context ) { - $logo = $this->getLogo( $this->getConfig() ); + $logo = $this->getLogoData( $this->getConfig() ); $styles = parent::getStyles( $context ); $this->normalizeStyles( $styles ); @@ -42,25 +42,34 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule { '; }'; if ( is_array( $logo ) ) { - if ( isset( $logo['1.5x'] ) ) { - $styles[ - '(-webkit-min-device-pixel-ratio: 1.5), ' . - '(min--moz-device-pixel-ratio: 1.5), ' . + if ( isset( $logo['svg'] ) ) { + $styles['all'][] = '.mw-wiki-logo { ' . + 'background-image: -webkit-linear-gradient(transparent, transparent), ' . + CSSMin::buildUrlValue( $logo['svg'] ) . '; ' . + 'background-image: linear-gradient(transparent, transparent), ' . + CSSMin::buildUrlValue( $logo['svg'] ) . ';' . + 'background-size: 135px auto; }'; + } else { + if ( isset( $logo['1.5x'] ) ) { + $styles[ + '(-webkit-min-device-pixel-ratio: 1.5), ' . + '(min--moz-device-pixel-ratio: 1.5), ' . '(min-resolution: 1.5dppx), ' . - '(min-resolution: 144dpi)' - ][] = '.mw-wiki-logo { background-image: ' . - CSSMin::buildUrlValue( $logo['1.5x'] ) . ';' . - 'background-size: 135px auto; }'; - } - if ( isset( $logo['2x'] ) ) { - $styles[ - '(-webkit-min-device-pixel-ratio: 2), ' . - '(min--moz-device-pixel-ratio: 2),' . - '(min-resolution: 2dppx), ' . - '(min-resolution: 192dpi)' - ][] = '.mw-wiki-logo { background-image: ' . - CSSMin::buildUrlValue( $logo['2x'] ) . ';' . - 'background-size: 135px auto; }'; + '(min-resolution: 144dpi)' + ][] = '.mw-wiki-logo { background-image: ' . + CSSMin::buildUrlValue( $logo['1.5x'] ) . ';' . + 'background-size: 135px auto; }'; + } + if ( isset( $logo['2x'] ) ) { + $styles[ + '(-webkit-min-device-pixel-ratio: 2), ' . + '(min--moz-device-pixel-ratio: 2), ' . + '(min-resolution: 2dppx), ' . + '(min-resolution: 192dpi)' + ][] = '.mw-wiki-logo { background-image: ' . + CSSMin::buildUrlValue( $logo['2x'] ) . ';' . + 'background-size: 135px auto; }'; + } } } @@ -83,11 +92,24 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule { } } + /** + * Non-static proxy to ::getLogo (for overloading in sub classes or tests). + * + * @codeCoverageIgnore + * @since 1.31 + * @param Config $conf + * @return string|array + */ + protected function getLogoData( Config $conf ) { + return static::getLogo( $conf ); + } + /** * @param Config $conf - * @return string|array Single url if no variants are defined - * or array of logo urls keyed by dppx in form "x". - * Key "1x" is always defined. + * @return string|array Single url if no variants are defined, + * or an array of logo urls keyed by dppx in form "x". + * Key "1x" is always defined. Key "svg" may also be defined, + * in which case variants other than "1x" are omitted. */ public static function getLogo( Config $conf ) { $logo = $conf->get( 'Logo' ); @@ -103,18 +125,25 @@ class ResourceLoaderSkinModule extends ResourceLoaderFileModule { '1x' => $logo1Url, ]; - // Only 1.5x and 2x are supported - if ( isset( $logoHD['1.5x'] ) ) { - $logoUrls['1.5x'] = OutputPage::transformResourcePath( - $conf, - $logoHD['1.5x'] - ); - } - if ( isset( $logoHD['2x'] ) ) { - $logoUrls['2x'] = OutputPage::transformResourcePath( + if ( isset( $logoHD['svg'] ) ) { + $logoUrls['svg'] = OutputPage::transformResourcePath( $conf, - $logoHD['2x'] + $logoHD['svg'] ); + } else { + // Only 1.5x and 2x are supported + if ( isset( $logoHD['1.5x'] ) ) { + $logoUrls['1.5x'] = OutputPage::transformResourcePath( + $conf, + $logoHD['1.5x'] + ); + } + if ( isset( $logoHD['2x'] ) ) { + $logoUrls['2x'] = OutputPage::transformResourcePath( + $conf, + $logoHD['2x'] + ); + } } return $logoUrls;