87 'all' => [
'resources/src/mediawiki.skinning/logo.less' ],
89 'print' => [
'resources/src/mediawiki.skinning/logo-print.less' ],
92 'screen' => [
'resources/src/mediawiki.skinning/content.css' ],
95 'screen' => [
'resources/src/mediawiki.skinning/interface.css' ],
98 'screen' => [
'resources/src/mediawiki.skinning/normalize.less' ],
101 'screen' => [
'resources/src/mediawiki.skinning/elements.css' ],
104 'all' => [
'resources/src/mediawiki.skinning/messageBoxes.less' ],
105 'print' => [
'resources/src/mediawiki.skinning/commonPrint.css' ],
106 'screen' => [
'resources/src/mediawiki.skinning/legacy.less' ],
108 'i18n-ordered-lists' => [
109 'screen' => [
'resources/src/mediawiki.skinning/i18n-ordered-lists.less' ],
111 'i18n-all-lists-margins' => [
112 'screen' => [
'resources/src/mediawiki.skinning/i18n-all-lists-margins.less' ],
115 'screen' => [
'resources/src/mediawiki.skinning/i18n-headings.less' ],
123 private const DEFAULT_FEATURES = [
126 'interface' =>
false,
129 'i18n-ordered-lists' =>
false,
130 'i18n-all-lists-margins' =>
false,
131 'i18n-headings' =>
false,
146 $enabledFeatures = [];
147 $compatibilityMode =
false;
148 foreach (
$features as $key => $enabled ) {
149 if ( is_bool( $enabled ) ) {
150 $enabledFeatures[$key] = $enabled;
153 $enabledFeatures[$enabled] =
true;
154 $compatibilityMode =
true;
159 if ( !$compatibilityMode ) {
160 foreach ( self::DEFAULT_FEATURES as $key => $enabled ) {
161 if ( !isset( $enabledFeatures[$key] ) ) {
162 $enabledFeatures[$key] = $enabled;
166 $this->features = array_filter(
167 array_keys( $enabledFeatures ),
168 function ( $key ) use ( $enabledFeatures ) {
169 return $enabledFeatures[ $key ];
181 $styles = parent::getStyleFiles( $context );
183 list( $defaultLocalBasePath, $defaultRemoteBasePath ) =
186 foreach ( $this->features as $feature ) {
187 if ( !isset( self::FEATURE_FILES[$feature] ) ) {
191 foreach ( self::FEATURE_FILES[$feature] as $mediaType => $files ) {
192 if ( !isset(
$styles[$mediaType] ) ) {
195 foreach ( $files as $filepath ) {
198 $defaultLocalBasePath,
199 $defaultRemoteBasePath
214 $styles = parent::getStyles( $context );
217 $isLogoFeatureEnabled = in_array(
'logo', $this->features );
218 if ( $isLogoFeatureEnabled ) {
219 $default = !is_array( $logo ) ? $logo : $logo[
'1x'];
220 $styles[
'all'][] =
'.mw-wiki-logo { background-image: ' .
223 if ( is_array( $logo ) ) {
224 if ( isset( $logo[
'svg'] ) ) {
225 $styles[
'all'][] =
'.mw-wiki-logo { ' .
226 'background-image: -webkit-linear-gradient(transparent, transparent), ' .
228 'background-image: linear-gradient(transparent, transparent), ' .
230 'background-size: 135px auto; }';
232 if ( isset( $logo[
'1.5x'] ) ) {
234 '(-webkit-min-device-pixel-ratio: 1.5), ' .
235 '(min--moz-device-pixel-ratio: 1.5), ' .
236 '(min-resolution: 1.5dppx), ' .
237 '(min-resolution: 144dpi)'
238 ][] =
'.mw-wiki-logo { background-image: ' .
240 'background-size: 135px auto; }';
242 if ( isset( $logo[
'2x'] ) ) {
244 '(-webkit-min-device-pixel-ratio: 2), ' .
245 '(min--moz-device-pixel-ratio: 2), ' .
246 '(min-resolution: 2dppx), ' .
247 '(min-resolution: 192dpi)'
248 ][] =
'.mw-wiki-logo { background-image: ' .
250 'background-size: 135px auto; }';
279 if ( !is_array( $logo ) ) {
281 $preloadLinks[$logo] = [
'as' =>
'image' ];
282 return $preloadLinks;
285 if ( isset( $logo[
'svg'] ) ) {
288 $preloadLinks[$logo[
'svg']] = [
'as' =>
'image' ];
289 return $preloadLinks;
292 foreach ( $logo as $dppx => $src ) {
294 $dppx = substr( $dppx, 0, -1 );
295 $logosPerDppx[$dppx] = $src;
299 uksort( $logosPerDppx,
function ( $a, $b ) {
306 foreach ( $logosPerDppx as $dppx => $src ) {
313 $logosCount = count( $logos );
319 for ( $i = 0; $i < $logosCount; $i++ ) {
324 $media_query =
'not all and (min-resolution: ' . $logos[1][
'dppx'] .
'dppx)';
325 } elseif ( $i !== $logosCount - 1 ) {
330 $upper_bound = floatval( $logos[$i + 1][
'dppx'] ) - 0.000001;
331 $media_query =
'(min-resolution: ' . $logos[$i][
'dppx'] .
332 'dppx) and (max-resolution: ' . $upper_bound .
'dppx)';
335 $media_query =
'(min-resolution: ' . $logos[$i][
'dppx'] .
'dppx)';
338 $preloadLinks[$logos[$i][
'src']] = [
340 'media' => $media_query
344 return $preloadLinks;
356 foreach ( $styles as $key => $val ) {
357 if ( !is_array( $val ) ) {
358 $styles[$key] = [ $val ];
374 $logos = $conf->get(
'Logos' );
375 if ( $logos ===
false ) {
383 if ( !isset( $logos[
'1x' ] ) ) {
384 $logo = $conf->get(
'Logo' );
386 $logos[
'1x'] = $logo;
391 $logoHD = $conf->get(
'LogoHD' );
402 if ( !isset( $logos[
'1x'] ) ) {
403 throw new \RuntimeException(
"The key `1x` is required for wgLogos or wgLogo must be defined." );
418 $logoHD = self::getAvailableLogos( $conf );
419 $logo = $logoHD[
'1x'];
421 $logo1Url = OutputPage::transformResourcePath( $conf, $logo );
427 if ( isset( $logoHD[
'svg'] ) ) {
428 $logoUrls[
'svg'] = OutputPage::transformResourcePath(
432 } elseif ( isset( $logoHD[
'1.5x'] ) || isset( $logoHD[
'2x'] ) ) {
434 if ( isset( $logoHD[
'1.5x'] ) ) {
435 $logoUrls[
'1.5x'] = OutputPage::transformResourcePath(
440 if ( isset( $logoHD[
'2x'] ) ) {
441 $logoUrls[
'2x'] = OutputPage::transformResourcePath(
471 $lessVars = parent::getLessVars( $context );
472 $logos = self::getAvailableLogos( $this->getConfig() );
474 if ( isset( $logos[
'wordmark'] ) ) {
475 $logo = $logos[
'wordmark'];
476 $lessVars[
'logo-enabled' ] =
true;
478 $lessVars[
'logo-wordmark-width' ] = intval( $logo[
'width'] );
479 $lessVars[
'logo-wordmark-height' ] = intval( $logo[
'height'] );
481 $lessVars[
'logo-enabled' ] =
false;
487 $summary = parent::getDefinitionSummary( $context );
489 'logos' => self::getAvailableLogos( $this->getConfig() ),
static buildUrlValue( $url)
Build a CSS 'url()' value for the given URL, quoting parentheses (and other funny characters) and esc...
Exceptions for config failures.
Context object that contains information about the state of a specific ResourceLoader web request.
Module based on local JavaScript/CSS files.
string $localBasePath
Local base path, see __construct()
static extractBasePaths(array $options=[], $localBasePath=null, $remoteBasePath=null)
Extract a pair of local and remote base paths from module definition information.
array $styles
List of paths to CSS files to always include.
string $remoteBasePath
Remote base path, see __construct()
An object to represent a path to a JavaScript/CSS file, along with a remote and local base path,...
Module for skin stylesheets.
const FEATURE_FILES
Every skin should define which features it would like to reuse for core inside a ResourceLoader modul...
$targets
All skins are assumed to be compatible with mobile.
normalizeStyles(array &$styles)
Ensure all media keys use array values.
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
getStyleFiles(ResourceLoaderContext $context)
Get styles defined in the module definition, plus any enabled feature styles.
getStyles(ResourceLoaderContext $context)
getPreloadLinks(ResourceLoaderContext $context)
getLessVars(ResourceLoaderContext $context)
Get language-specific LESS variables for this module.
static getAvailableLogos( $conf)
Return an array of all available logos that a skin may use.
isKnownEmpty(ResourceLoaderContext $context)
getLogoData(Config $conf)
getLogoPreloadlinks()
Helper method for getPreloadLinks()
__construct(array $options=[], $localBasePath=null, $remoteBasePath=null)
Constructs a new module from an options array.
Interface for configuration instances.