Completed
Branch master (939199)
by
unknown
39:35
created

resourceloader/ResourceLoaderSkinModule.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * ResourceLoader module for skin stylesheets.
4
 *
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.
9
 *
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.
14
 *
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
19
 *
20
 * @file
21
 * @author Timo Tijhof
22
 */
23
24
class ResourceLoaderSkinModule extends ResourceLoaderFileModule {
25
26
	/* Methods */
27
28
	/**
29
	 * @param ResourceLoaderContext $context
30
	 * @return array
31
	 */
32
	public function getStyles( ResourceLoaderContext $context ) {
33
		$conf = $this->getConfig();
34
		$logo = $conf->get( 'Logo' );
35
		$logoHD = $conf->get( 'LogoHD' );
36
37
		$logo1 = OutputPage::transformResourcePath( $conf, $logo );
38
		$logo15 = OutputPage::transformResourcePath( $conf, $logoHD['1.5x'] );
39
		$logo2 = OutputPage::transformResourcePath( $conf, $logoHD['2x'] );
40
41
		$styles = parent::getStyles( $context );
42
		$styles['all'][] = '.mw-wiki-logo { background-image: ' .
43
			CSSMin::buildUrlValue( $logo1 ) .
44
			'; }';
45
		if ( $logoHD ) {
46 View Code Duplication
			if ( isset( $logoHD['1.5x'] ) ) {
47
				$styles[
48
					'(-webkit-min-device-pixel-ratio: 1.5), ' .
49
					'(min--moz-device-pixel-ratio: 1.5), ' .
50
					'(min-resolution: 1.5dppx), ' .
51
					'(min-resolution: 144dpi)'
52
				][] = '.mw-wiki-logo { background-image: ' .
53
				CSSMin::buildUrlValue( $logo15 ) . ';' .
54
				'background-size: 135px auto; }';
55
			}
56 View Code Duplication
			if ( isset( $logoHD['2x'] ) ) {
57
				$styles[
58
					'(-webkit-min-device-pixel-ratio: 2), ' .
59
					'(min--moz-device-pixel-ratio: 2),' .
60
					'(min-resolution: 2dppx), ' .
61
					'(min-resolution: 192dpi)'
62
				][] = '.mw-wiki-logo { background-image: ' .
63
				CSSMin::buildUrlValue( $logo2 ) . ';' .
64
				'background-size: 135px auto; }';
65
			}
66
		}
67
		return $styles;
68
	}
69
70
	/**
71
	 * @param ResourceLoaderContext $context
72
	 * @return bool
73
	 */
74
	public function isKnownEmpty( ResourceLoaderContext $context ) {
75
		// Regardless of whether the files are specified, we always
76
		// provide mw-wiki-logo styles.
77
		return false;
78
	}
79
80
	/**
81
	 * @param ResourceLoaderContext $context
82
	 * @return string: Hash
0 ignored issues
show
The doc-type string: could not be parsed: Unknown type name "string:" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
83
	 */
84
	public function getModifiedHash( ResourceLoaderContext $context ) {
85
		$logo = $this->getConfig()->get( 'Logo' );
86
		$logoHD = $this->getConfig()->get( 'LogoHD' );
87
		return md5( parent::getModifiedHash( $context ) . $logo . json_encode( $logoHD ) );
88
	}
89
}
90