MediaWiki REL1_31
ResourceLoaderSkinModule.php
Go to the documentation of this file.
1<?php
28 public $targets = [ 'desktop', 'mobile' ];
29
35 $logo = $this->getLogoData( $this->getConfig() );
36 $styles = parent::getStyles( $context );
37 $this->normalizeStyles( $styles );
38
39 $default = !is_array( $logo ) ? $logo : $logo['1x'];
40 $styles['all'][] = '.mw-wiki-logo { background-image: ' .
41 CSSMin::buildUrlValue( $default ) .
42 '; }';
43
44 if ( is_array( $logo ) ) {
45 if ( isset( $logo['svg'] ) ) {
46 $styles['all'][] = '.mw-wiki-logo { ' .
47 'background-image: -webkit-linear-gradient(transparent, transparent), ' .
48 CSSMin::buildUrlValue( $logo['svg'] ) . '; ' .
49 'background-image: linear-gradient(transparent, transparent), ' .
50 CSSMin::buildUrlValue( $logo['svg'] ) . ';' .
51 'background-size: 135px auto; }';
52 } else {
53 if ( isset( $logo['1.5x'] ) ) {
54 $styles[
55 '(-webkit-min-device-pixel-ratio: 1.5), ' .
56 '(min--moz-device-pixel-ratio: 1.5), ' .
57 '(min-resolution: 1.5dppx), ' .
58 '(min-resolution: 144dpi)'
59 ][] = '.mw-wiki-logo { background-image: ' .
60 CSSMin::buildUrlValue( $logo['1.5x'] ) . ';' .
61 'background-size: 135px auto; }';
62 }
63 if ( isset( $logo['2x'] ) ) {
64 $styles[
65 '(-webkit-min-device-pixel-ratio: 2), ' .
66 '(min--moz-device-pixel-ratio: 2), ' .
67 '(min-resolution: 2dppx), ' .
68 '(min-resolution: 192dpi)'
69 ][] = '.mw-wiki-logo { background-image: ' .
70 CSSMin::buildUrlValue( $logo['2x'] ) . ';' .
71 'background-size: 135px auto; }';
72 }
73 }
74 }
75
76 return $styles;
77 }
78
87 private function normalizeStyles( &$styles ) {
88 foreach ( $styles as $key => $val ) {
89 if ( !is_array( $val ) ) {
90 $styles[$key] = [ $val ];
91 }
92 }
93 }
94
100 protected function getLogoData( Config $conf ) {
101 return static::getLogo( $conf );
102 }
103
111 public static function getLogo( Config $conf ) {
112 $logo = $conf->get( 'Logo' );
113 $logoHD = $conf->get( 'LogoHD' );
114
115 $logo1Url = OutputPage::transformResourcePath( $conf, $logo );
116
117 if ( !$logoHD ) {
118 return $logo1Url;
119 }
120
121 $logoUrls = [
122 '1x' => $logo1Url,
123 ];
124
125 if ( isset( $logoHD['svg'] ) ) {
126 $logoUrls['svg'] = OutputPage::transformResourcePath(
127 $conf,
128 $logoHD['svg']
129 );
130 } else {
131 // Only 1.5x and 2x are supported
132 if ( isset( $logoHD['1.5x'] ) ) {
133 $logoUrls['1.5x'] = OutputPage::transformResourcePath(
134 $conf,
135 $logoHD['1.5x']
136 );
137 }
138 if ( isset( $logoHD['2x'] ) ) {
139 $logoUrls['2x'] = OutputPage::transformResourcePath(
140 $conf,
141 $logoHD['2x']
142 );
143 }
144 }
145
146 return $logoUrls;
147 }
148
154 // Regardless of whether the files are specified, we always
155 // provide mw-wiki-logo styles.
156 return false;
157 }
158
160 $summary = parent::getDefinitionSummary( $context );
161 $summary[] = [
162 'logo' => $this->getConfig()->get( 'Logo' ),
163 'logoHD' => $this->getConfig()->get( 'LogoHD' ),
164 ];
165 return $summary;
166 }
167}
Object passed around to modules which contains information about the state of a specific loader reque...
ResourceLoader module based on local JavaScript/CSS files.
array $styles
List of paths to CSS files to always include.
$targets
All skins are assumed to be compatible with mobile.
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
normalizeStyles(&$styles)
Ensure all media keys use array values.
getStyles(ResourceLoaderContext $context)
isKnownEmpty(ResourceLoaderContext $context)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2811
Interface for configuration instances.
Definition Config.php:28
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".