resourceloader: Avoid deprecated getModifiedHash() in SkinModule
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderSkinModule.php
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 /**
27 * @param ResourceLoaderContext $context
28 * @return array
29 */
30 public function getStyles( ResourceLoaderContext $context ) {
31 $conf = $this->getConfig();
32 $logo = $conf->get( 'Logo' );
33 $logoHD = $conf->get( 'LogoHD' );
34
35 $logo1 = OutputPage::transformResourcePath( $conf, $logo );
36 $logo15 = OutputPage::transformResourcePath( $conf, $logoHD['1.5x'] );
37 $logo2 = OutputPage::transformResourcePath( $conf, $logoHD['2x'] );
38
39 $styles = parent::getStyles( $context );
40 $styles['all'][] = '.mw-wiki-logo { background-image: ' .
41 CSSMin::buildUrlValue( $logo1 ) .
42 '; }';
43 if ( $logoHD ) {
44 if ( isset( $logoHD['1.5x'] ) ) {
45 $styles[
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( $logo15 ) . ';' .
52 'background-size: 135px auto; }';
53 }
54 if ( isset( $logoHD['2x'] ) ) {
55 $styles[
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( $logo2 ) . ';' .
62 'background-size: 135px auto; }';
63 }
64 }
65 return $styles;
66 }
67
68 /**
69 * @param ResourceLoaderContext $context
70 * @return bool
71 */
72 public function isKnownEmpty( ResourceLoaderContext $context ) {
73 // Regardless of whether the files are specified, we always
74 // provide mw-wiki-logo styles.
75 return false;
76 }
77
78 public function getDefinitionSummary( ResourceLoaderContext $context ) {
79 $summary = parent::getDefinitionSummary( $context );
80 $summary[] = [
81 'logo' => $this->getConfig()->get( 'Logo' ),
82 'logoHD' => $this->getConfig()->get( 'LogoHD' ),
83 ];
84 return $summary;
85 }
86 }