Merge "Don't check namespace in SpecialWantedtemplates"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderSkinModule.php
1 <?php
2 /**
3 * Resource loader 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 $context ResourceLoaderContext
30 * @return array
31 */
32 public function getStyles( ResourceLoaderContext $context ) {
33 $logo = $this->getConfig()->get( 'Logo' );
34 $logoHD = $this->getConfig()->get( 'LogoHD' );
35 $styles = parent::getStyles( $context );
36 $styles['all'][] = '.mw-wiki-logo { background-image: ' .
37 CSSMin::buildUrlValue( $logo ) .
38 '; }';
39 if ( $logoHD ) {
40 if ( isset( $logoHD['1.5x'] ) ) {
41 $styles[
42 '(-webkit-min-device-pixel-ratio: 1.5), ' .
43 '(min--moz-device-pixel-ratio: 1.5), ' .
44 '(min-resolution: 1.5dppx), ' .
45 '(min-resolution: 144dpi)'
46 ][] = '.mw-wiki-logo { background-image: ' .
47 CSSMin::buildUrlValue( $logoHD['1.5x'] ) . ';' .
48 'background-size: 135px auto; }';
49 }
50 if ( isset( $logoHD['2x'] ) ) {
51 $styles[
52 '(-webkit-min-device-pixel-ratio: 2), ' .
53 '(min--moz-device-pixel-ratio: 2),' .
54 '(min-resolution: 2dppx), ' .
55 '(min-resolution: 192dpi)'
56 ][] = '.mw-wiki-logo { background-image: ' .
57 CSSMin::buildUrlValue( $logoHD['2x'] ) . ';' .
58 'background-size: 135px auto; }';
59 }
60 }
61 return $styles;
62 }
63
64 /**
65 * @param $context ResourceLoaderContext
66 * @return bool
67 */
68 public function isKnownEmpty( ResourceLoaderContext $context ) {
69 // Regardless of whether the files are specified, we always
70 // provide mw-wiki-logo styles.
71 return false;
72 }
73
74 /**
75 * @param $context ResourceLoaderContext
76 * @return string: Hash
77 */
78 public function getModifiedHash( ResourceLoaderContext $context ) {
79 $logo = $this->getConfig()->get( 'Logo' );
80 $logoHD = $this->getConfig()->get( 'LogoHD' );
81 return md5( parent::getModifiedHash( $context ) . $logo . json_encode( $logoHD ) );
82 }
83 }