3 * ResourceLoader module for skin stylesheets.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 class ResourceLoaderSkinModule
extends ResourceLoaderFileModule
{
26 * All skins are assumed to be compatible with mobile
28 public $targets = [ 'desktop', 'mobile' ];
31 * @param ResourceLoaderContext $context
34 public function getStyles( ResourceLoaderContext
$context ) {
35 $logo = $this->getLogo( $this->getConfig() );
36 $styles = parent
::getStyles( $context );
38 $default = !is_array( $logo ) ?
$logo : $logo['1x'];
39 $styles['all'][] = '.mw-wiki-logo { background-image: ' .
40 CSSMin
::buildUrlValue( $default ) .
43 if ( is_array( $logo ) ) {
44 if ( isset( $logo['1.5x'] ) ) {
46 '(-webkit-min-device-pixel-ratio: 1.5), ' .
47 '(min--moz-device-pixel-ratio: 1.5), ' .
48 '(min-resolution: 1.5dppx), ' .
49 '(min-resolution: 144dpi)'
50 ][] = '.mw-wiki-logo { background-image: ' .
51 CSSMin
::buildUrlValue( $logo['1.5x'] ) . ';' .
52 'background-size: 135px auto; }';
54 if ( isset( $logo['2x'] ) ) {
56 '(-webkit-min-device-pixel-ratio: 2), ' .
57 '(min--moz-device-pixel-ratio: 2),' .
58 '(min-resolution: 2dppx), ' .
59 '(min-resolution: 192dpi)'
60 ][] = '.mw-wiki-logo { background-image: ' .
61 CSSMin
::buildUrlValue( $logo['2x'] ) . ';' .
62 'background-size: 135px auto; }';
71 * @return string|array Single url if no variants are defined
72 * or array of logo urls keyed by dppx in form "<float>x".
73 * Key "1x" is always defined.
75 public static function getLogo( Config
$conf ) {
76 $logo = $conf->get( 'Logo' );
77 $logoHD = $conf->get( 'LogoHD' );
79 $logo1Url = OutputPage
::transformResourcePath( $conf, $logo );
89 // Only 1.5x and 2x are supported
90 if ( isset( $logoHD['1.5x'] ) ) {
91 $logoUrls['1.5x'] = OutputPage
::transformResourcePath(
96 if ( isset( $logoHD['2x'] ) ) {
97 $logoUrls['2x'] = OutputPage
::transformResourcePath(
107 * @param ResourceLoaderContext $context
110 public function isKnownEmpty( ResourceLoaderContext
$context ) {
111 // Regardless of whether the files are specified, we always
112 // provide mw-wiki-logo styles.
116 public function getDefinitionSummary( ResourceLoaderContext
$context ) {
117 $summary = parent
::getDefinitionSummary( $context );
119 'logo' => $this->getConfig()->get( 'Logo' ),
120 'logoHD' => $this->getConfig()->get( 'LogoHD' ),