MediaWiki REL1_39
MediaWiki\ResourceLoader\SkinModule Class Reference

Module for skin stylesheets. More...

Inheritance diagram for MediaWiki\ResourceLoader\SkinModule:
Collaboration diagram for MediaWiki\ResourceLoader\SkinModule:

Public Member Functions

 __construct (array $options=[], $localBasePath=null, $remoteBasePath=null)
 
 getDefinitionSummary (Context $context)
 Get the definition summary for this module.
 
 getPreloadLinks (Context $context)
 
 getStyleFiles (Context $context)
 Get styles defined in the module definition, plus any enabled feature styles.
 
 getStyles (Context $context)
 
 isKnownEmpty (Context $context)
 
- Public Member Functions inherited from MediaWiki\ResourceLoader\LessVarFileModule
 getMessages ()
 Get message keys used by this module.
Returns
string[] List of message keys

 
- Public Member Functions inherited from MediaWiki\ResourceLoader\FileModule
 __construct (array $options=[], string $localBasePath=null, string $remoteBasePath=null)
 Constructs a new module from an options array.
 
 enableModuleContentVersion ()
 Disable module content versioning.
 
 getAllStyleFiles ()
 Returns all style files and all skin style files used by this module.
 
 getDependencies (Context $context=null)
 Get names of modules this module depends on.
 
 getFlip (Context $context)
 Get whether CSS for this module should be flipped.
 
 getGroup ()
 Get the name of the group this module should be loaded in.
 
 getPackageFiles (Context $context)
 Resolve the package files definition and generates the content of each package file.
 
 getScript (Context $context)
 Gets all scripts for a given context concatenated together.
 
 getScriptURLsForDebug (Context $context)
 
 getSkipFunction ()
 
 getStyleSheetLang ( $path)
 Infer the stylesheet language from a stylesheet file path.
 
 getStyleURLsForDebug (Context $context)
 
 getTargets ()
 Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
 
 getTemplates ()
 Get content of named templates for this module.
 
 getType ()
 Get the module's load type.
 
 readStyleFiles (array $styles, Context $context)
 Read the contents of a list of CSS files and remap and concatenate these.
 
 requiresES6 ()
 Whether the module requires ES6 support in the client.
 
 setSkinStylesOverride (array $moduleSkinStyles)
 Provide overrides for skinStyles to modules that support that.
 
 supportsURLLoading ()
 
- Public Member Functions inherited from MediaWiki\ResourceLoader\Module
 getConfig ()
 
 getDeprecationInformation (Context $context)
 Get JS representing deprecation information for the current module if available.
 
 getHeaders (Context $context)
 Get headers to send as part of a module web response.
 
 getModuleContent (Context $context)
 Get an array of this module's resources.
 
 getName ()
 Get this module's name.
 
 getOrigin ()
 Get this module's origin.
 
 getSkins ()
 Get list of skins for which this module must be available to load.
 
 getSource ()
 Get the source of this module.
 
 getVersionHash (Context $context)
 Get a string identifying the current version of this module in a given context.
 
 setConfig (Config $config)
 
 setDependencyAccessCallbacks (callable $loadCallback, callable $saveCallback)
 Inject the functions that load/save the indirect file path dependency list from storage.
 
 setFileDependencies (Context $context, array $paths)
 Set the indirect dependencies for this module pursuant to the skin/language context.
 
 setHookContainer (HookContainer $hookContainer)
 
 setLogger (LoggerInterface $logger)
 
 setMessageBlob ( $blob, $lang)
 Set in-object cache for message blobs.
 
 setName ( $name)
 Set this module's name.
 
 shouldEmbedModule (Context $context)
 Check whether this module should be embedded rather than linked.
 

Static Public Member Functions

static getAvailableLogos (Config $conf, string $lang=null)
 Return an array of all available logos that a skin may use.
 
- Static Public Member Functions inherited from MediaWiki\ResourceLoader\FileModule
static extractBasePaths (array $options=[], $localBasePath=null, $remoteBasePath=null)
 Extract a pair of local and remote base paths from module definition information.
 
static getPackageFileType ( $path)
 Infer the file type from a package file path.
 
- Static Public Member Functions inherited from MediaWiki\ResourceLoader\Module
static expandRelativePaths (array $filePaths)
 Expand directories relative to $IP.
 
static getRelativePaths (array $filePaths)
 Make file paths relative to MediaWiki directory.
 
static getVary (Context $context)
 Get vary string.
 

Public Attributes

 $targets = [ 'desktop', 'mobile' ]
 All skins are assumed to be compatible with mobile.
 

Protected Member Functions

 getLessVars (Context $context)
 Get language-specific LESS variables for this module.
 
 getLogoData (Config $conf, string $lang=null)
 
- Protected Member Functions inherited from MediaWiki\ResourceLoader\LessVarFileModule
 getMessageBlob (Context $context)
 Get the hash of the message blob.
Stability: stable
to override
Since
1.27
Parameters
Context$context
Returns
string|null JSON blob or null if module has no messages

 
- Protected Member Functions inherited from MediaWiki\ResourceLoader\FileModule
 compileLessString ( $style, $stylePath, Context $context)
 Compile a LESS string into CSS.
 
 getAllSkinStyleFiles ()
 Gets a list of file paths for all skin style files in the module, for all available skins.
 
 getLocalPath ( $path)
 
 getPath ( $path)
 
 getRemotePath ( $path)
 
 getSkinStyleFiles ( $skinName)
 Gets a list of file paths for all skin styles in the module used by the skin.
 
 getVueComponentParser ()
 
 processStyle ( $style, $styleLang, $path, Context $context)
 Process a CSS/LESS string.
 
 readStyleFile ( $path, Context $context)
 Read and process a style file.
 
 stripBom ( $input)
 Takes an input string and removes the UTF-8 BOM character if present.
 
- Protected Member Functions inherited from MediaWiki\ResourceLoader\Module
 buildContent (Context $context)
 Bundle all resources attached to this module into an array.
 
 getFileDependencies (Context $context)
 Get the indirect dependencies for this module pursuant to the skin/language context.
 
 getHookRunner ()
 Get a HookRunner for running core hooks.
 
 getLogger ()
 
 saveFileDependencies (Context $context, array $curFileRefs)
 Save the indirect dependencies for this module pursuant to the skin/language context.
 
 validateScriptFile ( $fileName, $contents)
 Validate a user-provided JavaScript blob.
 

Static Protected Member Functions

static applyFeaturesCompatibility (array $features, bool $addUnspecifiedFeatures=true, &$messages='')
 
- Static Protected Member Functions inherited from MediaWiki\ResourceLoader\FileModule
static tryForKey (array $list, $key, $fallback=null)
 Get a list of element that match a key, optionally using a fallback key.
 
- Static Protected Member Functions inherited from MediaWiki\ResourceLoader\Module
static safeFileHash ( $filePath)
 Compute a non-cryptographic string hash of a file's contents.
 

Additional Inherited Members

- Protected Attributes inherited from MediaWiki\ResourceLoader\LessVarFileModule
 $lessVariables = []
 
- Protected Attributes inherited from MediaWiki\ResourceLoader\FileModule
bool $debugRaw = true
 Link to raw files in debug mode.
 
array< int, string|FilePath$debugScripts = []
 List of paths to JavaScript files to include in debug mode.
 
string[] $dependencies = []
 List of modules this module depends on.
 
bool $es6 = false
 Whether this module requires the client to support ES6.
 
null string $group = null
 Name of group to load this module in.
 
bool $hasGeneratedStyles = false
 Whether getStyleURLsForDebug should return raw file paths, or return load.php urls.
 
array< string, array< int, string|FilePath > > $languageScripts = []
 Lists of JavaScript files by language code.
 
string $localBasePath = ''
 Local base path, see __construct()
 
string[] $localFileRefs = []
 Place where readStyleFile() tracks file dependencies.
 
string[] $messages = []
 List of message keys used by this module.
 
string[] $missingLocalFileRefs = []
 Place where readStyleFile() tracks file dependencies for non-existent files.
 
bool $noflip = false
 Whether CSSJanus flipping should be skipped for this module.
 
null array $packageFiles = null
 Packaged files definition, to bundle and make available client-side via require().
 
string $remoteBasePath = ''
 Remote base path, see __construct()
 
array< int, string|FilePath$scripts = []
 List of JavaScript file paths to always include.
 
array< string, array< int, string|FilePath > > $skinScripts = []
 Lists of JavaScript files by skin name.
 
array< string, array< int, string|FilePath > > $skinStyles = []
 Lists of CSS files by skin name.
 
null string $skipFunction = null
 File name containing the body of the skip function.
 
array< int, string|FilePath$styles = []
 List of CSS file files to always include.
 
string[] $targets = [ 'desktop' ]
 
array< int|string, string|FilePath$templates = []
 List of the named templates used by this module.
 
VueComponentParser null $vueComponentParser = null
 Lazy-created by getVueComponentParser()
 
- Protected Attributes inherited from MediaWiki\ResourceLoader\Module
Config $config
 
array $contents = []
 Map of (context hash => cached module content)
 
string bool $deprecated = false
 Deprecation string or true if deprecated; false otherwise.
 
array $fileDeps = []
 Map of (variant => indirect file dependencies)
 
LoggerInterface $logger
 
array $msgBlobs = []
 Map of (language => in-object cache for message blob)
 
string null $name = null
 Module name.
 
int $origin = self::ORIGIN_CORE_SITEWIDE
 Script and style modules form a hierarchy of trustworthiness, with core modules like skins and jQuery as most trustworthy, and user scripts as least trustworthy.
 
string[] null $skins = null
 Skin names.
 
string[] $targets = [ 'desktop' ]
 What client platforms the module targets (e.g.
 
array $versionHash = []
 Map of (context hash => cached module version hash)
 

Detailed Description

Module for skin stylesheets.

Access: internal

Definition at line 35 of file SkinModule.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\ResourceLoader\SkinModule::__construct ( array $options = [],
$localBasePath = null,
$remoteBasePath = null )
Parameters
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.
string | null$localBasePath
string | null$remoteBasePath
See also
Additonal options at $wgResourceModules

Reimplemented from MediaWiki\ResourceLoader\LessVarFileModule.

Definition at line 278 of file SkinModule.php.

References MediaWiki\ResourceLoader\FileModule\$localBasePath, MediaWiki\ResourceLoader\FileModule\$messages, MediaWiki\ResourceLoader\FileModule\$remoteBasePath, and MediaWiki\ResourceLoader\SkinModule\applyFeaturesCompatibility().

Member Function Documentation

◆ applyFeaturesCompatibility()

static MediaWiki\ResourceLoader\SkinModule::applyFeaturesCompatibility ( array $features,
bool $addUnspecifiedFeatures = true,
& $messages = '' )
staticprotected
Access: internal
Parameters
array$features
bool$addUnspecifiedFeatureswhether to add new features if missing
string&$messagesto report deprecations
Returns
array

Definition at line 327 of file SkinModule.php.

References MediaWiki\ResourceLoader\FileModule\$messages.

Referenced by MediaWiki\ResourceLoader\SkinModule\__construct().

◆ getAvailableLogos()

static MediaWiki\ResourceLoader\SkinModule::getAvailableLogos ( Config $conf,
string $lang = null )
static

Return an array of all available logos that a skin may use.

Since
1.35
Parameters
Config$conf
string | null$langLanguage code for logo variant, since 1.39
Returns
array with the following keys:
  • 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.

Definition at line 633 of file SkinModule.php.

◆ getDefinitionSummary()

MediaWiki\ResourceLoader\SkinModule::getDefinitionSummary ( Context $context)

Get the definition summary for this module.

Parameters
Context$context
Returns
array

Reimplemented from MediaWiki\ResourceLoader\FileModule.

Definition at line 755 of file SkinModule.php.

◆ getLessVars()

MediaWiki\ResourceLoader\SkinModule::getLessVars ( Context $context)
protected

Get language-specific LESS variables for this module.

Parameters
Context$context
Returns
array

Reimplemented from MediaWiki\ResourceLoader\LessVarFileModule.

Definition at line 739 of file SkinModule.php.

◆ getLogoData()

MediaWiki\ResourceLoader\SkinModule::getLogoData ( Config $conf,
string $lang = null )
protected
Since
1.31
Parameters
Config$conf
string | null$langLanguage code for logo variant, since 1.39
Returns
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.

Definition at line 686 of file SkinModule.php.

References $lang.

◆ getPreloadLinks()

MediaWiki\ResourceLoader\SkinModule::getPreloadLinks ( Context $context)
Parameters
Context$context
Returns
array

Reimplemented from MediaWiki\ResourceLoader\Module.

Definition at line 510 of file SkinModule.php.

◆ getStyleFiles()

MediaWiki\ResourceLoader\SkinModule::getStyleFiles ( Context $context)

Get styles defined in the module definition, plus any enabled feature styles.

Parameters
Context$context
Returns
string[][]

Reimplemented from MediaWiki\ResourceLoader\FileModule.

Definition at line 395 of file SkinModule.php.

References MediaWiki\ResourceLoader\FileModule\extractBasePaths(), MediaWiki\MainConfigNames\ParserEnableLegacyMediaDOM, MediaWiki\MainConfigNames\ResourceBasePath, and MediaWiki\MainConfigNames\UseContentMediaStyles.

◆ getStyles()

MediaWiki\ResourceLoader\SkinModule::getStyles ( Context $context)
Parameters
Context$context
Returns
array

Reimplemented from MediaWiki\ResourceLoader\FileModule.

Definition at line 458 of file SkinModule.php.

References MediaWiki\ResourceLoader\Context\getLanguage().

◆ isKnownEmpty()

MediaWiki\ResourceLoader\SkinModule::isKnownEmpty ( Context $context)
Parameters
Context$context
Returns
bool

Reimplemented from MediaWiki\ResourceLoader\Module.

Definition at line 727 of file SkinModule.php.

Member Data Documentation

◆ $targets

MediaWiki\ResourceLoader\SkinModule::$targets = [ 'desktop', 'mobile' ]

All skins are assumed to be compatible with mobile.

Definition at line 39 of file SkinModule.php.


The documentation for this class was generated from the following file: