2013-12-01 00:49:21 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2021-02-18 04:38:29 +00:00
|
|
|
use Wikimedia\Minify\CSSMin;
|
2013-12-01 00:49:21 +00:00
|
|
|
|
2019-07-08 21:31:25 +00:00
|
|
|
/**
|
2019-09-14 04:32:54 +00:00
|
|
|
* Module for skin stylesheets.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup ResourceLoader
|
|
|
|
|
* @internal
|
2019-07-08 21:31:25 +00:00
|
|
|
*/
|
2020-08-18 18:06:28 +00:00
|
|
|
class ResourceLoaderSkinModule extends ResourceLoaderLessVarFileModule {
|
2017-06-30 19:27:04 +00:00
|
|
|
/**
|
|
|
|
|
* All skins are assumed to be compatible with mobile
|
|
|
|
|
*/
|
|
|
|
|
public $targets = [ 'desktop', 'mobile' ];
|
2013-12-01 00:49:21 +00:00
|
|
|
|
2019-09-25 17:44:05 +00:00
|
|
|
/**
|
|
|
|
|
* Every skin should define which features it would like to reuse for core inside a
|
|
|
|
|
* ResourceLoader module that has set the class to ResourceLoaderSkinModule.
|
|
|
|
|
* For a feature to be valid it must be listed here along with the associated resources
|
|
|
|
|
*
|
|
|
|
|
* The following features are available:
|
|
|
|
|
*
|
|
|
|
|
* "logo":
|
2020-02-27 16:37:02 +00:00
|
|
|
* Adds CSS to style an element with class `mw-wiki-logo` using the value of wgLogos['1x'].
|
2019-09-25 17:44:05 +00:00
|
|
|
* This is enabled by default if no features are added.
|
|
|
|
|
*
|
2020-06-27 00:55:04 +00:00
|
|
|
* "normalize":
|
|
|
|
|
* Styles needed to normalize rendering across different browser rendering engines.
|
|
|
|
|
* All to address bugs and common browser inconsistencies for skins and extensions.
|
|
|
|
|
* Inspired by necolas' normalize.css. This is meant to be kept lean,
|
|
|
|
|
* basic styling beyond normalization should live in one of the following modules.
|
|
|
|
|
*
|
2019-09-25 17:44:05 +00:00
|
|
|
* "elements":
|
|
|
|
|
* The base level that only contains the most basic of common skin styles.
|
|
|
|
|
* Only styles for single elements are included, no styling for complex structures like the
|
|
|
|
|
* TOC is present. This level is for skins that want to implement the entire style of even
|
|
|
|
|
* content area structures like the TOC themselves.
|
|
|
|
|
*
|
|
|
|
|
* "content":
|
2021-05-13 23:13:52 +00:00
|
|
|
* Deprecated. Alias for "content-media".
|
2020-12-09 18:44:47 +00:00
|
|
|
*
|
|
|
|
|
* "content-thumbnails":
|
2021-05-13 23:13:52 +00:00
|
|
|
* Deprecated. Alias for "content-media".
|
2019-09-25 17:44:05 +00:00
|
|
|
*
|
2020-09-15 19:24:11 +00:00
|
|
|
* "content-media":
|
2021-05-13 23:13:52 +00:00
|
|
|
* Styles for thumbnails and floated elements.
|
2021-10-05 21:59:09 +00:00
|
|
|
* Will add styles for the new media structure on wikis where $wgParserEnableLegacyMediaDOM is disabled,
|
|
|
|
|
* or $wgUseContentMediaStyles is enabled.
|
2020-09-15 19:24:11 +00:00
|
|
|
* See https://www.mediawiki.org/wiki/Parsing/Media_structure
|
|
|
|
|
*
|
2020-11-20 18:07:57 +00:00
|
|
|
* "content-links":
|
2021-04-20 22:15:29 +00:00
|
|
|
* The skin will apply optional styling rules for links that should be styled differently
|
|
|
|
|
* to the rules in `elements` and `normalize`. It provides support for .mw-selflink,
|
|
|
|
|
* a.new (red links), a.stub (stub links) and some basic styles for external links.
|
|
|
|
|
* It also provides rules supporting the underline user preference.
|
|
|
|
|
*
|
|
|
|
|
* "content-links-external":
|
2020-11-20 18:07:57 +00:00
|
|
|
* The skin will apply optional styling rules to links to provide icons for different file types.
|
|
|
|
|
*
|
2021-04-05 22:36:00 +00:00
|
|
|
* "content-body":
|
2021-03-14 17:28:27 +00:00
|
|
|
* Styles for the mw-parser-output class.
|
|
|
|
|
*
|
2021-03-25 09:43:38 +00:00
|
|
|
* "content-tables":
|
|
|
|
|
* Styles .wikitable style tables.
|
|
|
|
|
*
|
2019-09-25 17:44:05 +00:00
|
|
|
* "interface":
|
|
|
|
|
* The highest level, this stylesheet contains extra common styles for classes like
|
|
|
|
|
* .firstHeading, #contentSub, et cetera which are not outputted by MediaWiki but are common
|
|
|
|
|
* to skins like MonoBook, Vector, etc... Essentially this level is for styles that are
|
|
|
|
|
* common to MonoBook clones.
|
2019-10-28 20:56:13 +00:00
|
|
|
*
|
2021-03-29 20:10:47 +00:00
|
|
|
* "interface-category":
|
|
|
|
|
* Styles used for styling the categories in a horizontal bar at the bottom of the content.
|
|
|
|
|
*
|
2021-03-23 08:15:33 +00:00
|
|
|
* "interface-message-box":
|
|
|
|
|
* Styles for message boxes.
|
|
|
|
|
*
|
2019-10-28 20:56:13 +00:00
|
|
|
* "i18n-ordered-lists":
|
|
|
|
|
* Styles for ordered lists elements that support mixed language content.
|
|
|
|
|
*
|
|
|
|
|
* "i18n-all-lists-margins":
|
|
|
|
|
* Styles for margins of list elements where LTR and RTL are mixed.
|
|
|
|
|
*
|
|
|
|
|
* "i18n-headings":
|
|
|
|
|
* Styles for line-heights of headings across different languages.
|
|
|
|
|
*
|
|
|
|
|
* "legacy":
|
|
|
|
|
* For backwards compatibility a legacy feature is provided.
|
|
|
|
|
* New skins should not use this if they can avoid doing so.
|
2021-03-23 08:15:33 +00:00
|
|
|
* This feature also contains `interface-message-box` and
|
|
|
|
|
* all `i18n-` prefixed features.
|
2020-08-18 18:06:28 +00:00
|
|
|
*
|
|
|
|
|
* "toc"
|
|
|
|
|
* Styling rules for the table of contents.
|
2020-12-07 19:02:58 +00:00
|
|
|
*
|
|
|
|
|
* NOTE: The order of the keys defines the order in which the styles are output.
|
2019-09-25 17:44:05 +00:00
|
|
|
*/
|
|
|
|
|
private const FEATURE_FILES = [
|
2020-12-07 19:02:58 +00:00
|
|
|
'normalize' => [
|
|
|
|
|
'all' => [ 'resources/src/mediawiki.skinning/normalize.less' ],
|
|
|
|
|
],
|
2020-01-07 22:02:29 +00:00
|
|
|
'logo' => [
|
2020-02-06 02:17:58 +00:00
|
|
|
// Applies the logo and ensures it downloads prior to printing.
|
|
|
|
|
'all' => [ 'resources/src/mediawiki.skinning/logo.less' ],
|
|
|
|
|
// Reserves whitespace for the logo in a pseudo element.
|
2020-01-07 22:02:29 +00:00
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/logo-print.less' ],
|
|
|
|
|
],
|
2021-05-13 23:13:52 +00:00
|
|
|
'content-media' => [
|
2021-09-28 17:59:56 +00:00
|
|
|
'all' => [ 'resources/src/mediawiki.skinning/content.thumbnails-common.less' ],
|
2021-11-30 20:02:04 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/content.thumbnails-screen.less' ],
|
2021-03-31 09:03:39 +00:00
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/content.thumbnails-print.less' ],
|
2019-09-25 17:44:05 +00:00
|
|
|
],
|
2020-11-20 18:07:57 +00:00
|
|
|
'content-links' => [
|
2021-04-20 22:15:29 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/content.links.less' ]
|
|
|
|
|
],
|
|
|
|
|
'content-links-external' => [
|
2020-11-20 18:07:57 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/content.externallinks.less' ]
|
|
|
|
|
],
|
2021-04-05 22:36:00 +00:00
|
|
|
'content-body' => [
|
|
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/content.body.less' ],
|
|
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/content.body-print.less' ],
|
2021-03-14 17:28:27 +00:00
|
|
|
],
|
2021-03-25 09:43:38 +00:00
|
|
|
'content-tables' => [
|
|
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/content.tables.less' ],
|
|
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/content.tables-print.less' ]
|
|
|
|
|
],
|
2019-09-25 17:44:05 +00:00
|
|
|
'interface' => [
|
2020-10-02 18:20:25 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/interface.less' ],
|
2021-03-31 09:03:39 +00:00
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/interface-print.less' ],
|
2019-09-25 17:44:05 +00:00
|
|
|
],
|
2021-03-25 08:38:34 +00:00
|
|
|
'interface-category' => [
|
|
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/interface.category.less' ],
|
2021-03-31 09:03:39 +00:00
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/interface.category-print.less' ],
|
2021-03-25 08:38:34 +00:00
|
|
|
],
|
2021-03-23 08:15:33 +00:00
|
|
|
'interface-message-box' => [
|
|
|
|
|
'all' => [ 'resources/src/mediawiki.skinning/messageBoxes.less' ],
|
|
|
|
|
],
|
2019-09-25 17:44:05 +00:00
|
|
|
'elements' => [
|
2021-03-26 14:45:21 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/elements.less' ],
|
2021-03-31 09:03:39 +00:00
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/elements-print.less' ],
|
2019-09-25 17:44:05 +00:00
|
|
|
],
|
2019-10-28 20:56:13 +00:00
|
|
|
'legacy' => [
|
2020-07-08 16:40:04 +00:00
|
|
|
'all' => [ 'resources/src/mediawiki.skinning/messageBoxes.less' ],
|
2021-03-25 09:43:38 +00:00
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/commonPrint.less' ],
|
2019-10-28 20:56:13 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/legacy.less' ],
|
|
|
|
|
],
|
|
|
|
|
'i18n-ordered-lists' => [
|
|
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/i18n-ordered-lists.less' ],
|
|
|
|
|
],
|
|
|
|
|
'i18n-all-lists-margins' => [
|
2020-06-10 14:09:09 +00:00
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/i18n-all-lists-margins.less' ],
|
2019-10-28 20:56:13 +00:00
|
|
|
],
|
|
|
|
|
'i18n-headings' => [
|
|
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/i18n-headings.less' ],
|
|
|
|
|
],
|
2020-08-18 18:06:28 +00:00
|
|
|
'toc' => [
|
|
|
|
|
'all' => [ 'resources/src/mediawiki.skinning/toc/common.css' ],
|
|
|
|
|
'screen' => [ 'resources/src/mediawiki.skinning/toc/screen.less' ],
|
|
|
|
|
'print' => [ 'resources/src/mediawiki.skinning/toc/print.css' ],
|
|
|
|
|
],
|
2019-09-25 17:44:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/** @var string[] */
|
|
|
|
|
private $features;
|
|
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
/**
|
|
|
|
|
* Defaults for when a 'features' parameter is specified.
|
|
|
|
|
*
|
|
|
|
|
* When these apply, they are the merged into the specified options.
|
|
|
|
|
*
|
|
|
|
|
* @var array<string,bool>
|
|
|
|
|
*/
|
|
|
|
|
private const DEFAULT_FEATURES_SPECIFIED = [
|
2021-04-05 22:36:00 +00:00
|
|
|
'content-body' => true,
|
2020-08-18 18:06:28 +00:00
|
|
|
'toc' => true,
|
|
|
|
|
];
|
|
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
/**
|
|
|
|
|
* Default for when the 'features' parameter is absent.
|
|
|
|
|
*
|
2022-01-09 17:44:44 +00:00
|
|
|
* For backward-compatibility, when the parameter is not declared
|
2021-03-18 03:20:36 +00:00
|
|
|
* only 'logo' and 'legacy' styles are loaded.
|
|
|
|
|
*
|
|
|
|
|
* @var string[]
|
|
|
|
|
*/
|
|
|
|
|
private const DEFAULT_FEATURES_ABSENT = [
|
|
|
|
|
'logo',
|
|
|
|
|
'legacy',
|
|
|
|
|
];
|
|
|
|
|
|
2020-08-18 18:06:28 +00:00
|
|
|
private const LESS_MESSAGES = [
|
2020-11-22 07:26:09 +00:00
|
|
|
// `toc` feature, used in screen.less
|
2020-08-18 18:06:28 +00:00
|
|
|
'hidetoc',
|
|
|
|
|
'showtoc',
|
2020-08-18 17:46:20 +00:00
|
|
|
];
|
|
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
/**
|
|
|
|
|
* @param array $options
|
|
|
|
|
* - features: Map from feature keys to boolean indicating whether to load
|
|
|
|
|
* or not include the associated styles.
|
|
|
|
|
* Keys not specified get their default from self::DEFAULT_FEATURES_SPECIFIED.
|
|
|
|
|
*
|
|
|
|
|
* If this is set to a list of strings, then the defaults do not apply.
|
|
|
|
|
* Use this at your own risk as it means you opt-out from backwards compatibility
|
|
|
|
|
* provided through these defaults. For example, when features are migrated
|
|
|
|
|
* to the SkinModule system from other parts of MediaWiki, those new feature keys
|
|
|
|
|
* may be enabled by default, and opting out means you may be missing some styles
|
|
|
|
|
* after an upgrade until you enable them or implement them by other means.
|
|
|
|
|
*
|
|
|
|
|
* - lessMessages: Interface message keys to export as LESS variables.
|
|
|
|
|
* See also ResourceLoaderLessVarFileModule.
|
|
|
|
|
*
|
|
|
|
|
* @param string|null $localBasePath
|
|
|
|
|
* @param string|null $remoteBasePath
|
|
|
|
|
* @see Additonal options at $wgResourceModules
|
|
|
|
|
*/
|
2019-09-25 17:44:05 +00:00
|
|
|
public function __construct(
|
|
|
|
|
array $options = [],
|
|
|
|
|
$localBasePath = null,
|
|
|
|
|
$remoteBasePath = null
|
|
|
|
|
) {
|
2021-03-18 03:20:36 +00:00
|
|
|
$features = $options['features'] ?? self::DEFAULT_FEATURES_ABSENT;
|
2021-05-24 23:11:32 +00:00
|
|
|
$listMode = array_keys( $features ) === range( 0, count( $features ) - 1 );
|
2021-03-30 21:54:58 +00:00
|
|
|
|
|
|
|
|
$messages = '';
|
2021-03-18 03:20:36 +00:00
|
|
|
// NOTE: Compatibility is only applied when features are provided
|
|
|
|
|
// in map-form. The list-form does not currently get these.
|
2021-03-30 21:54:58 +00:00
|
|
|
$features = $listMode ? self::applyFeaturesCompatibility( array_fill_keys( $features, true ), $messages ) :
|
|
|
|
|
self::applyFeaturesCompatibility( $features, $messages );
|
2020-12-09 18:44:47 +00:00
|
|
|
|
2020-08-18 17:46:20 +00:00
|
|
|
foreach ( $features as $key => $enabled ) {
|
resourceloader: Restore feedback for SkinModule invalid argument
This was added in 381499a675 in response to the issue that when a skin
adopts a feature that was new in MW 1.36, it caused an exception when
that version of the skin is then installed on MW 1.35. That's expected,
and generally helpful because the default support policy requires
like-for-like (MW 1.35 with REL1_35, this applies to all skins and
extensions, except for a few like Translate and SemanticMediaWiki).
However, while supporting LTS within master is unusual, there are
indeed the Translate/SemanticMediaWiki projects, and this problem has
already been solved years ago there by using a conditional with
$wgVersion. The proposed approach on T271441 actually also involves
such a conditional, but late at runtime instead of in the module
definition. Anyway, the way it was fixed in Timeless already solves
the problem by not passing down the invalid feature in the first
place, thus making the 381499a675 patch obsolete. I'm not aware of
any skin in Gerrit having such a compat policy, but if they exist,
they can fix it the same way, by defining the module in code with
a condition, just as Translate/SemanticMediaWiki do.
Bug: T271441
Change-Id: If97b3d04ac1e3355ee4f229db11e524d24ebd27a
2021-03-18 17:22:37 +00:00
|
|
|
if ( !isset( self::FEATURE_FILES[$key] ) ) {
|
|
|
|
|
throw new InvalidArgumentException( "Feature '$key' is not recognised" );
|
2020-12-07 19:02:58 +00:00
|
|
|
}
|
2020-08-18 17:46:20 +00:00
|
|
|
}
|
2021-04-14 21:41:33 +00:00
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
$this->features = $listMode
|
2021-05-24 23:11:32 +00:00
|
|
|
? array_keys( array_filter( $features ) )
|
2021-03-18 03:20:36 +00:00
|
|
|
: array_keys( array_filter( $features + self::DEFAULT_FEATURES_SPECIFIED ) );
|
|
|
|
|
|
|
|
|
|
// Only the `toc` feature makes use of interface messages.
|
|
|
|
|
// For skins not using the `toc` feature, make sure LocalisationCache
|
|
|
|
|
// remains untouched (T270027).
|
2021-04-14 21:41:33 +00:00
|
|
|
if ( in_array( 'toc', $this->features ) ) {
|
2021-03-18 03:20:36 +00:00
|
|
|
$options['lessMessages'] = array_merge(
|
|
|
|
|
$options['lessMessages'] ?? [],
|
|
|
|
|
self::LESS_MESSAGES
|
|
|
|
|
);
|
2021-04-14 21:41:33 +00:00
|
|
|
}
|
2021-03-30 21:54:58 +00:00
|
|
|
|
|
|
|
|
if ( $messages !== '' ) {
|
|
|
|
|
$messages .= 'More information can be found at [[mw:Manual:ResourceLoaderSkinModule]]. ';
|
|
|
|
|
$options['deprecated'] = $messages;
|
|
|
|
|
}
|
2021-04-14 21:41:33 +00:00
|
|
|
parent::__construct( $options, $localBasePath, $remoteBasePath );
|
2019-09-25 17:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
* @param array $features
|
2021-03-30 21:54:58 +00:00
|
|
|
* @param string &$messages to report deprecations
|
2021-03-18 03:20:36 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2021-03-30 21:54:58 +00:00
|
|
|
protected static function applyFeaturesCompatibility( array $features, &$messages = '' ): array {
|
2021-05-13 23:13:52 +00:00
|
|
|
// The `content` feature is mapped to `content-media`.
|
2021-04-20 22:15:29 +00:00
|
|
|
if ( isset( $features[ 'content' ] ) ) {
|
2021-05-13 23:13:52 +00:00
|
|
|
$features[ 'content-media' ] = $features[ 'content' ];
|
2021-04-20 22:15:29 +00:00
|
|
|
unset( $features[ 'content' ] );
|
2021-03-30 21:54:58 +00:00
|
|
|
$messages .= '[1.37] The use of the `content` feature with ResourceLoaderSkinModule'
|
|
|
|
|
. ' is deprecated. Use `content-media` instead. ';
|
2021-04-20 22:15:29 +00:00
|
|
|
}
|
2021-03-18 03:20:36 +00:00
|
|
|
|
2021-05-13 23:13:52 +00:00
|
|
|
// The `content-thumbnails` feature is mapped to `content-media`.
|
|
|
|
|
if ( isset( $features[ 'content-thumbnails' ] ) ) {
|
|
|
|
|
$features[ 'content-media' ] = $features[ 'content-thumbnails' ];
|
2021-03-30 21:54:58 +00:00
|
|
|
$messages .= '[1.37] The use of the `content-thumbnails` feature with ResourceLoaderSkinModule'
|
|
|
|
|
. ' is deprecated. Use `content-media` instead. ';
|
2021-05-13 23:13:52 +00:00
|
|
|
unset( $features[ 'content-thumbnails' ] );
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
// If `content-links` feature is set but no preference for `content-links-external` is set
|
2021-04-20 22:15:29 +00:00
|
|
|
if ( isset( $features[ 'content-links' ] ) && !isset( $features[ 'content-links-external' ] ) ) {
|
2021-03-18 03:20:36 +00:00
|
|
|
// Assume the same true/false preference for both.
|
2021-04-20 22:15:29 +00:00
|
|
|
$features[ 'content-links-external' ] = $features[ 'content-links' ];
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-30 21:54:58 +00:00
|
|
|
// The legacy feature is deprecated (T89981).
|
|
|
|
|
if ( isset( $features['legacy'] ) && $features['legacy'] ) {
|
|
|
|
|
$messages .= '[1.37] The use of the `legacy` feature with ResourceLoaderSkinModule is deprecated'
|
|
|
|
|
. '(T89981). ';
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 03:20:36 +00:00
|
|
|
// The `content-links` feature was split out from `elements`.
|
|
|
|
|
// Make sure skins asking for `elements` also get these by default.
|
2021-04-20 22:15:29 +00:00
|
|
|
if ( isset( $features[ 'element' ] ) && !isset( $features[ 'content-links' ] ) ) {
|
|
|
|
|
$features[ 'content-links' ] = $features[ 'element' ];
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 22:36:00 +00:00
|
|
|
// `content-parser-output` was renamed to `content-body`.
|
|
|
|
|
// No need to go through deprecation process here since content-parser-output added and removed in 1.36.
|
|
|
|
|
// Remove this check when no matches for
|
|
|
|
|
// https://codesearch.wmcloud.org/search/?q=content-parser-output&i=nope&files=&excludeFiles=&repos=
|
|
|
|
|
if ( isset( $features[ 'content-parser-output' ] ) ) {
|
|
|
|
|
$features[ 'content-body' ] = $features[ 'content-parser-output' ];
|
|
|
|
|
unset( $features[ 'content-parser-output' ] );
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-20 22:15:29 +00:00
|
|
|
return $features;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-25 17:44:05 +00:00
|
|
|
/**
|
|
|
|
|
* Get styles defined in the module definition, plus any enabled feature styles.
|
|
|
|
|
*
|
|
|
|
|
* @param ResourceLoaderContext $context
|
2020-10-28 10:01:33 +00:00
|
|
|
* @return string[][]
|
2019-09-25 17:44:05 +00:00
|
|
|
*/
|
|
|
|
|
public function getStyleFiles( ResourceLoaderContext $context ) {
|
|
|
|
|
$styles = parent::getStyleFiles( $context );
|
|
|
|
|
|
2021-03-18 04:08:05 +00:00
|
|
|
// Bypass the current module paths so that these files are served from core,
|
|
|
|
|
// instead of the individual skin's module directory.
|
2019-09-25 17:44:05 +00:00
|
|
|
list( $defaultLocalBasePath, $defaultRemoteBasePath ) =
|
2021-03-18 04:08:05 +00:00
|
|
|
ResourceLoaderFileModule::extractBasePaths(
|
|
|
|
|
[],
|
|
|
|
|
null,
|
|
|
|
|
$this->getConfig()->get( 'ResourceBasePath' )
|
|
|
|
|
);
|
2019-09-25 17:44:05 +00:00
|
|
|
|
2020-09-10 09:00:22 +00:00
|
|
|
$featureFilePaths = [];
|
|
|
|
|
|
2021-09-03 22:28:20 +00:00
|
|
|
foreach ( self::FEATURE_FILES as $feature => $featureFiles ) {
|
2020-12-07 19:02:58 +00:00
|
|
|
if ( in_array( $feature, $this->features ) ) {
|
2021-09-03 22:28:20 +00:00
|
|
|
foreach ( $featureFiles as $mediaType => $files ) {
|
2020-12-07 19:02:58 +00:00
|
|
|
foreach ( $files as $filepath ) {
|
|
|
|
|
$featureFilePaths[$mediaType][] = new ResourceLoaderFilePath(
|
|
|
|
|
$filepath,
|
|
|
|
|
$defaultLocalBasePath,
|
|
|
|
|
$defaultRemoteBasePath
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-09-25 17:44:05 +00:00
|
|
|
}
|
2021-10-05 21:59:09 +00:00
|
|
|
if ( $feature === 'content-media' && (
|
|
|
|
|
!$this->getConfig()->get( 'ParserEnableLegacyMediaDOM' ) ||
|
|
|
|
|
$this->getConfig()->get( 'UseContentMediaStyles' )
|
|
|
|
|
) ) {
|
2021-09-30 01:02:36 +00:00
|
|
|
$featureFilePaths['all'][] = new ResourceLoaderFilePath(
|
|
|
|
|
'resources/src/mediawiki.skinning/content.media-common.less',
|
|
|
|
|
$defaultLocalBasePath,
|
|
|
|
|
$defaultRemoteBasePath
|
|
|
|
|
);
|
2021-05-13 23:13:52 +00:00
|
|
|
$featureFilePaths['screen'][] = new ResourceLoaderFilePath(
|
2021-09-30 01:02:36 +00:00
|
|
|
'resources/src/mediawiki.skinning/content.media-screen.less',
|
|
|
|
|
$defaultLocalBasePath,
|
|
|
|
|
$defaultRemoteBasePath
|
|
|
|
|
);
|
|
|
|
|
$featureFilePaths['print'][] = new ResourceLoaderFilePath(
|
|
|
|
|
'resources/src/mediawiki.skinning/content.media-print.less',
|
2021-05-13 23:13:52 +00:00
|
|
|
$defaultLocalBasePath,
|
|
|
|
|
$defaultRemoteBasePath
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-09-25 17:44:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-08 21:23:29 +00:00
|
|
|
// Styles defines in options are added to the $featureFilePaths to ensure
|
|
|
|
|
// that $featureFilePaths styles precede module defined ones.
|
|
|
|
|
// This is particularly important given the `normalize` styles need to be the first
|
|
|
|
|
// outputted (see T269618).
|
|
|
|
|
foreach ( $styles as $mediaType => $paths ) {
|
|
|
|
|
$featureFilePaths[$mediaType] = array_merge( $featureFilePaths[$mediaType] ?? [], $paths );
|
2020-09-10 09:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-08 21:23:29 +00:00
|
|
|
return $featureFilePaths;
|
2019-09-25 17:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-01 00:49:21 +00:00
|
|
|
/**
|
2016-04-30 10:10:17 +00:00
|
|
|
* @param ResourceLoaderContext $context
|
2013-12-01 00:49:21 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getStyles( ResourceLoaderContext $context ) {
|
2017-05-22 18:12:26 +00:00
|
|
|
$logo = $this->getLogoData( $this->getConfig() );
|
2013-12-01 00:49:21 +00:00
|
|
|
$styles = parent::getStyles( $context );
|
2017-06-16 19:25:41 +00:00
|
|
|
$this->normalizeStyles( $styles );
|
2017-04-12 20:43:57 +00:00
|
|
|
|
2019-09-25 17:44:05 +00:00
|
|
|
$isLogoFeatureEnabled = in_array( 'logo', $this->features );
|
|
|
|
|
if ( $isLogoFeatureEnabled ) {
|
|
|
|
|
$default = !is_array( $logo ) ? $logo : $logo['1x'];
|
|
|
|
|
$styles['all'][] = '.mw-wiki-logo { background-image: ' .
|
2017-04-12 20:43:57 +00:00
|
|
|
CSSMin::buildUrlValue( $default ) .
|
|
|
|
|
'; }';
|
2020-11-22 07:26:09 +00:00
|
|
|
|
2019-09-25 17:44:05 +00:00
|
|
|
if ( is_array( $logo ) ) {
|
|
|
|
|
if ( isset( $logo['svg'] ) ) {
|
|
|
|
|
$styles['all'][] = '.mw-wiki-logo { ' .
|
|
|
|
|
'background-image: -webkit-linear-gradient(transparent, transparent), ' .
|
|
|
|
|
CSSMin::buildUrlValue( $logo['svg'] ) . '; ' .
|
|
|
|
|
'background-image: linear-gradient(transparent, transparent), ' .
|
|
|
|
|
CSSMin::buildUrlValue( $logo['svg'] ) . ';' .
|
|
|
|
|
'background-size: 135px auto; }';
|
|
|
|
|
} else {
|
|
|
|
|
if ( isset( $logo['1.5x'] ) ) {
|
|
|
|
|
$styles[
|
|
|
|
|
'(-webkit-min-device-pixel-ratio: 1.5), ' .
|
2020-11-22 07:26:09 +00:00
|
|
|
'(min-resolution: 1.5dppx), ' .
|
2019-09-25 17:44:05 +00:00
|
|
|
'(min-resolution: 144dpi)'
|
|
|
|
|
][] = '.mw-wiki-logo { background-image: ' .
|
2020-11-22 07:26:09 +00:00
|
|
|
CSSMin::buildUrlValue( $logo['1.5x'] ) . ';' .
|
|
|
|
|
'background-size: 135px auto; }';
|
2019-09-25 17:44:05 +00:00
|
|
|
}
|
|
|
|
|
if ( isset( $logo['2x'] ) ) {
|
|
|
|
|
$styles[
|
|
|
|
|
'(-webkit-min-device-pixel-ratio: 2), ' .
|
|
|
|
|
'(min-resolution: 2dppx), ' .
|
|
|
|
|
'(min-resolution: 192dpi)'
|
|
|
|
|
][] = '.mw-wiki-logo { background-image: ' .
|
2020-11-22 07:26:09 +00:00
|
|
|
CSSMin::buildUrlValue( $logo['2x'] ) . ';' .
|
|
|
|
|
'background-size: 135px auto; }';
|
2019-09-25 17:44:05 +00:00
|
|
|
}
|
2017-05-22 18:12:26 +00:00
|
|
|
}
|
2015-03-09 01:55:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
2017-04-12 20:43:57 +00:00
|
|
|
|
2013-12-01 00:49:21 +00:00
|
|
|
return $styles;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 23:42:42 +00:00
|
|
|
/**
|
|
|
|
|
* @param ResourceLoaderContext $context
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getPreloadLinks( ResourceLoaderContext $context ) {
|
|
|
|
|
return $this->getLogoPreloadlinks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper method for getPreloadLinks()
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2021-07-22 03:11:47 +00:00
|
|
|
private function getLogoPreloadlinks(): array {
|
2020-10-18 20:16:37 +00:00
|
|
|
if ( !in_array( 'logo', $this->features ) ) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 23:42:42 +00:00
|
|
|
$logo = $this->getLogoData( $this->getConfig() );
|
|
|
|
|
|
|
|
|
|
if ( !is_array( $logo ) ) {
|
|
|
|
|
// No media queries required if we only have one variant
|
2020-11-22 07:26:09 +00:00
|
|
|
return [ $logo => [ 'as' => 'image' ] ];
|
2018-08-20 23:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $logo['svg'] ) ) {
|
|
|
|
|
// No media queries required if we only have a 1x and svg variant
|
|
|
|
|
// because all preload-capable browsers support SVGs
|
2020-11-22 07:26:09 +00:00
|
|
|
return [ $logo['svg'] => [ 'as' => 'image' ] ];
|
2018-08-20 23:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-22 07:26:09 +00:00
|
|
|
$logosPerDppx = [];
|
2018-08-20 23:42:42 +00:00
|
|
|
foreach ( $logo as $dppx => $src ) {
|
|
|
|
|
// Keys are in this format: "1.5x"
|
|
|
|
|
$dppx = substr( $dppx, 0, -1 );
|
|
|
|
|
$logosPerDppx[$dppx] = $src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Because PHP can't have floats as array keys
|
2021-02-10 22:31:02 +00:00
|
|
|
uksort( $logosPerDppx, static function ( $a, $b ) {
|
2018-08-20 23:42:42 +00:00
|
|
|
$a = floatval( $a );
|
|
|
|
|
$b = floatval( $b );
|
|
|
|
|
// Sort from smallest to largest (e.g. 1x, 1.5x, 2x)
|
|
|
|
|
return $a <=> $b;
|
|
|
|
|
} );
|
|
|
|
|
|
2020-11-22 07:26:09 +00:00
|
|
|
$logos = [];
|
2018-08-20 23:42:42 +00:00
|
|
|
foreach ( $logosPerDppx as $dppx => $src ) {
|
2019-04-06 12:48:39 +00:00
|
|
|
$logos[] = [
|
|
|
|
|
'dppx' => $dppx,
|
|
|
|
|
'src' => $src
|
|
|
|
|
];
|
2018-08-20 23:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$logosCount = count( $logos );
|
2020-11-22 07:26:09 +00:00
|
|
|
$preloadLinks = [];
|
2018-08-20 23:42:42 +00:00
|
|
|
// Logic must match ResourceLoaderSkinModule:
|
|
|
|
|
// - 1x applies to resolution < 1.5dppx
|
|
|
|
|
// - 1.5x applies to resolution >= 1.5dppx && < 2dppx
|
|
|
|
|
// - 2x applies to resolution >= 2dppx
|
|
|
|
|
// Note that min-resolution and max-resolution are both inclusive.
|
|
|
|
|
for ( $i = 0; $i < $logosCount; $i++ ) {
|
|
|
|
|
if ( $i === 0 ) {
|
|
|
|
|
// Smallest dppx
|
|
|
|
|
// min-resolution is ">=" (larger than or equal to)
|
|
|
|
|
// "not min-resolution" is essentially "<"
|
2019-04-06 12:48:39 +00:00
|
|
|
$media_query = 'not all and (min-resolution: ' . $logos[1]['dppx'] . 'dppx)';
|
2018-08-20 23:42:42 +00:00
|
|
|
} elseif ( $i !== $logosCount - 1 ) {
|
|
|
|
|
// In between
|
|
|
|
|
// Media query expressions can only apply "not" to the entire expression
|
|
|
|
|
// (e.g. can't express ">= 1.5 and not >= 2).
|
|
|
|
|
// Workaround: Use <= 1.9999 in place of < 2.
|
2019-04-06 12:48:39 +00:00
|
|
|
$upper_bound = floatval( $logos[$i + 1]['dppx'] ) - 0.000001;
|
|
|
|
|
$media_query = '(min-resolution: ' . $logos[$i]['dppx'] .
|
2018-08-20 23:42:42 +00:00
|
|
|
'dppx) and (max-resolution: ' . $upper_bound . 'dppx)';
|
|
|
|
|
} else {
|
|
|
|
|
// Largest dppx
|
2019-04-06 12:48:39 +00:00
|
|
|
$media_query = '(min-resolution: ' . $logos[$i]['dppx'] . 'dppx)';
|
2018-08-20 23:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-06 12:48:39 +00:00
|
|
|
$preloadLinks[$logos[$i]['src']] = [
|
|
|
|
|
'as' => 'image',
|
|
|
|
|
'media' => $media_query
|
|
|
|
|
];
|
2018-08-20 23:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $preloadLinks;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-16 19:25:41 +00:00
|
|
|
/**
|
|
|
|
|
* Ensure all media keys use array values.
|
|
|
|
|
*
|
|
|
|
|
* Normalises arrays returned by the ResourceLoaderFileModule::getStyles() method.
|
|
|
|
|
*
|
|
|
|
|
* @param array &$styles Associative array, keys are strings (media queries),
|
|
|
|
|
* values are strings or arrays
|
|
|
|
|
*/
|
2021-07-22 03:11:47 +00:00
|
|
|
private function normalizeStyles( array &$styles ): void {
|
2017-06-16 19:25:41 +00:00
|
|
|
foreach ( $styles as $key => $val ) {
|
|
|
|
|
if ( !is_array( $val ) ) {
|
|
|
|
|
$styles[$key] = [ $val ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 20:40:51 +00:00
|
|
|
/**
|
2022-01-09 17:44:44 +00:00
|
|
|
* Modifies configured logo width/height to ensure they are present and scalable
|
2021-09-08 20:40:51 +00:00
|
|
|
* with different font-sizes.
|
|
|
|
|
* @param array $logoElement with width, height and src keys.
|
|
|
|
|
* @return array modified version of $logoElement
|
|
|
|
|
*/
|
|
|
|
|
private static function getRelativeSizedLogo( array $logoElement ) {
|
|
|
|
|
$width = $logoElement['width'];
|
|
|
|
|
$height = $logoElement['height'];
|
|
|
|
|
$widthRelative = $width / 16;
|
|
|
|
|
$heightRelative = $height / 16;
|
|
|
|
|
// Allow skins to scale the wordmark with browser font size (T207789)
|
|
|
|
|
$logoElement['style'] = 'width: ' . $widthRelative . 'em; height: ' . $heightRelative . 'em;';
|
|
|
|
|
return $logoElement;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 19:18:51 +00:00
|
|
|
/**
|
|
|
|
|
* Return an array of all available logos that a skin may use.
|
|
|
|
|
* @since 1.35
|
|
|
|
|
* @param Config $conf
|
|
|
|
|
* @return array with the following keys:
|
2021-09-08 20:40:51 +00:00
|
|
|
* - 1x(string): a square logo composing the `icon` and `wordmark` (required)
|
|
|
|
|
* - 2x (string): a square logo for HD displays (optional)
|
|
|
|
|
* - wordmark (object): a rectangle logo (wordmark) for print media and skins which desire
|
|
|
|
|
* horizontal logo (optional). Must declare width and height fields, defined in pixels
|
|
|
|
|
* which will be converted to ems based on 16px font-size.
|
|
|
|
|
* - tagline (object): replaces `tagline` message in certain skins. Must declare width and
|
|
|
|
|
* height fields defined in pixels, which are converted to ems based on 16px font-size.
|
|
|
|
|
* - icon (string): a square logo similar to 1x, but without the wordmark. SVG recommended.
|
2020-01-07 19:18:51 +00:00
|
|
|
*/
|
2021-07-22 03:11:47 +00:00
|
|
|
public static function getAvailableLogos( $conf ): array {
|
2020-01-07 19:18:51 +00:00
|
|
|
$logos = $conf->get( 'Logos' );
|
|
|
|
|
if ( $logos === false ) {
|
|
|
|
|
// no logos were defined... this will either
|
|
|
|
|
// 1. Load from wgLogo and wgLogoHD
|
|
|
|
|
// 2. Trigger runtime exception if those are not defined.
|
|
|
|
|
$logos = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If logos['1x'] is not defined, see if we can use wgLogo
|
|
|
|
|
if ( !isset( $logos[ '1x' ] ) ) {
|
|
|
|
|
$logo = $conf->get( 'Logo' );
|
|
|
|
|
if ( $logo ) {
|
|
|
|
|
$logos['1x'] = $logo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$logoHD = $conf->get( 'LogoHD' );
|
|
|
|
|
// make sure not false
|
|
|
|
|
if ( $logoHD ) {
|
2020-02-13 18:41:29 +00:00
|
|
|
// wfDeprecated( __METHOD__ . ' with $wgLogoHD set instead of $wgLogos', '1.35', false, 1 );
|
2020-01-07 19:18:51 +00:00
|
|
|
$logos += $logoHD;
|
|
|
|
|
}
|
|
|
|
|
} catch ( ConfigException $e ) {
|
|
|
|
|
// no backwards compatibility changes needed.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check the configuration is valid
|
|
|
|
|
if ( !isset( $logos['1x'] ) ) {
|
2020-11-22 07:26:09 +00:00
|
|
|
throw new RuntimeException( "The key `1x` is required for wgLogos or wgLogo must be defined." );
|
2020-01-07 19:18:51 +00:00
|
|
|
}
|
2021-09-08 20:40:51 +00:00
|
|
|
|
|
|
|
|
// @todo: Note the beta cluster and other wikis may be using
|
|
|
|
|
// unsupported configuration where these values are set to false.
|
|
|
|
|
// The boolean check can be removed when this has been addressed.
|
|
|
|
|
if ( isset( $logos['wordmark'] ) && $logos['wordmark'] ) {
|
|
|
|
|
// Allow skins to scale the wordmark with browser font size (T207789)
|
|
|
|
|
$logos['wordmark'] = self::getRelativeSizedLogo( $logos['wordmark'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @todo: Note the beta cluster and other wikis may be using
|
|
|
|
|
// unsupported configuration where these values are set to false.
|
|
|
|
|
// The boolean check can be removed when this has been addressed.
|
|
|
|
|
if ( isset( $logos['tagline'] ) && $logos['tagline'] ) {
|
|
|
|
|
$logos['tagline'] = self::getRelativeSizedLogo( $logos['tagline'] );
|
|
|
|
|
}
|
2020-01-07 19:18:51 +00:00
|
|
|
// return the modified logos!
|
|
|
|
|
return $logos;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-22 18:12:26 +00:00
|
|
|
/**
|
|
|
|
|
* @since 1.31
|
2017-04-12 20:43:57 +00:00
|
|
|
* @param Config $conf
|
2017-05-22 18:12:26 +00:00
|
|
|
* @return string|array Single url if no variants are defined,
|
|
|
|
|
* or an array of logo urls keyed by dppx in form "<float>x".
|
|
|
|
|
* Key "1x" is always defined. Key "svg" may also be defined,
|
|
|
|
|
* in which case variants other than "1x" are omitted.
|
2017-04-12 20:43:57 +00:00
|
|
|
*/
|
2018-08-20 23:58:41 +00:00
|
|
|
protected function getLogoData( Config $conf ) {
|
2020-01-07 19:18:51 +00:00
|
|
|
$logoHD = self::getAvailableLogos( $conf );
|
|
|
|
|
$logo = $logoHD['1x'];
|
2017-04-12 20:43:57 +00:00
|
|
|
|
|
|
|
|
$logo1Url = OutputPage::transformResourcePath( $conf, $logo );
|
|
|
|
|
|
|
|
|
|
$logoUrls = [
|
|
|
|
|
'1x' => $logo1Url,
|
|
|
|
|
];
|
|
|
|
|
|
2017-05-22 18:12:26 +00:00
|
|
|
if ( isset( $logoHD['svg'] ) ) {
|
|
|
|
|
$logoUrls['svg'] = OutputPage::transformResourcePath(
|
2017-04-12 20:43:57 +00:00
|
|
|
$conf,
|
2017-05-22 18:12:26 +00:00
|
|
|
$logoHD['svg']
|
2017-04-12 20:43:57 +00:00
|
|
|
);
|
2020-02-05 21:12:02 +00:00
|
|
|
} elseif ( isset( $logoHD['1.5x'] ) || isset( $logoHD['2x'] ) ) {
|
2017-05-22 18:12:26 +00:00
|
|
|
// Only 1.5x and 2x are supported
|
|
|
|
|
if ( isset( $logoHD['1.5x'] ) ) {
|
|
|
|
|
$logoUrls['1.5x'] = OutputPage::transformResourcePath(
|
|
|
|
|
$conf,
|
|
|
|
|
$logoHD['1.5x']
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if ( isset( $logoHD['2x'] ) ) {
|
|
|
|
|
$logoUrls['2x'] = OutputPage::transformResourcePath(
|
|
|
|
|
$conf,
|
|
|
|
|
$logoHD['2x']
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-02-05 21:12:02 +00:00
|
|
|
} else {
|
|
|
|
|
// Return a string rather than a one-element array, getLogoPreloadlinks depends on this
|
|
|
|
|
return $logo1Url;
|
2017-04-12 20:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $logoUrls;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-01 00:49:21 +00:00
|
|
|
/**
|
2016-04-30 10:10:17 +00:00
|
|
|
* @param ResourceLoaderContext $context
|
2014-12-10 05:09:35 +00:00
|
|
|
* @return bool
|
2013-12-01 00:49:21 +00:00
|
|
|
*/
|
|
|
|
|
public function isKnownEmpty( ResourceLoaderContext $context ) {
|
|
|
|
|
// Regardless of whether the files are specified, we always
|
|
|
|
|
// provide mw-wiki-logo styles.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 22:02:29 +00:00
|
|
|
/**
|
|
|
|
|
* Get language-specific LESS variables for this module.
|
|
|
|
|
*
|
|
|
|
|
* @param ResourceLoaderContext $context
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
protected function getLessVars( ResourceLoaderContext $context ) {
|
|
|
|
|
$lessVars = parent::getLessVars( $context );
|
|
|
|
|
$logos = self::getAvailableLogos( $this->getConfig() );
|
|
|
|
|
|
|
|
|
|
if ( isset( $logos['wordmark'] ) ) {
|
|
|
|
|
$logo = $logos['wordmark'];
|
|
|
|
|
$lessVars[ 'logo-enabled' ] = true;
|
|
|
|
|
$lessVars[ 'logo-wordmark-url' ] = CSSMin::buildUrlValue( $logo['src'] );
|
|
|
|
|
$lessVars[ 'logo-wordmark-width' ] = intval( $logo['width'] );
|
|
|
|
|
$lessVars[ 'logo-wordmark-height' ] = intval( $logo['height'] );
|
|
|
|
|
} else {
|
|
|
|
|
$lessVars[ 'logo-enabled' ] = false;
|
|
|
|
|
}
|
|
|
|
|
return $lessVars;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 21:34:18 +00:00
|
|
|
public function getDefinitionSummary( ResourceLoaderContext $context ) {
|
|
|
|
|
$summary = parent::getDefinitionSummary( $context );
|
|
|
|
|
$summary[] = [
|
2020-01-07 19:18:51 +00:00
|
|
|
'logos' => self::getAvailableLogos( $this->getConfig() ),
|
2017-03-28 21:34:18 +00:00
|
|
|
];
|
|
|
|
|
return $summary;
|
2013-12-01 00:49:21 +00:00
|
|
|
}
|
|
|
|
|
}
|