MediaWiki master
|
Module for codex that has direction-specific style files and a static helper function for embedding icons in package modules. More...
Inherits MediaWiki\ResourceLoader\FileModule.
Public Member Functions | ||||
__construct (array $options=[], $localBasePath=null, $remoteBasePath=null) | ||||
getDefinitionSummary (Context $context) | ||||
Get the definition summary for this module.
| ||||
getMessages () | ||||
Get message keys used by this module.
| ||||
getPackageFiles (Context $context) | ||||
Resolve the package files definition and generate the content of each package file.
| ||||
getStyleFiles (Context $context) | ||||
Get a list of file paths for all styles in this module, in order of proper inclusion.
| ||||
supportsURLLoading () | ||||
| ||||
![]() | ||||
__construct (array $options=[], ?string $localBasePath=null, ?string $remoteBasePath=null) | ||||
Construct a new module from an options array. | ||||
enableModuleContentVersion () | ||||
Disable module content versioning. | ||||
getAllStyleFiles () | ||||
Get 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. | ||||
getScript (Context $context) | ||||
Get all JS for this module for a given language and skin.Includes all relevant JS except loader scripts.For multi-file modules where require() is used to load one file from another file, this should return an array structured as follows: [ 'files' => [ 'file1.js' => [ 'type' => 'script', 'content' => 'JS code' ], 'file2.js' => [ 'type' => 'script', 'content' => 'JS code' ], 'data.json' => [ 'type' => 'data', 'content' => array ] ], 'main' => 'file1.js' ]For plain concatenated scripts, this can either return a string, or an associative array similar to the one used for package files: [ 'plainScripts' => [ [ 'content' => 'JS code' ], [ 'content' => 'JS code' ], ], ]
| ||||
getSkipFunction () | ||||
getStyles (Context $context) | ||||
Get all styles for a given context. | ||||
getStyleSheetLang ( $path) | ||||
Infer the stylesheet language from a stylesheet file path. | ||||
getStyleURLsForDebug (Context $context) | ||||
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.If the client does not support ES6, attempting to load a module that requires ES6 will result in an error.
| ||||
setSkinStylesOverride (array $moduleSkinStyles) | ||||
Provide overrides for skinStyles to modules that support that. | ||||
shouldSkipStructureTest () | ||||
Whether to skip the structure test ResourcesTest::testRespond() for this module.
| ||||
![]() | ||||
getConfig () | ||||
getDeprecationWarning () | ||||
Get the deprecation warning, if any. | ||||
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. | ||||
isKnownEmpty (Context $context) | ||||
Check whether this module is known to be empty. | ||||
setConfig (Config $config) | ||||
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 | getIcons (?Context $context, Config $config, array $iconNames=[]) |
Retrieve the specified icon definitions from codex-icons.json. | |
![]() | |
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 | 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. | |
Protected Member Functions | |||||||||||||
processStyle ( $style, $styleLang, $path, Context $context) | |||||||||||||
Process a CSS/LESS string.This method performs the following processing steps:
| |||||||||||||
![]() | |||||||||||||
compileLessString ( $style, $stylePath, Context $context) | |||||||||||||
Compile a LESS string into CSS. | |||||||||||||
getAllSkinStyleFiles () | |||||||||||||
Get 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) | |||||||||||||
Get a list of file paths for all skin styles in the module used by the skin. | |||||||||||||
getVueComponentParser () | |||||||||||||
readStyleFile ( $path, Context $context) | |||||||||||||
Read and process a style file. | |||||||||||||
stripBom ( $input) | |||||||||||||
Take an input string and remove the UTF-8 BOM character if present. | |||||||||||||
![]() | |||||||||||||
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. | |||||||||||||
getLessVars (Context $context) | |||||||||||||
Get module-specific LESS variables, if any. | |||||||||||||
getLogger () | |||||||||||||
getMessageBlob (Context $context) | |||||||||||||
Get the hash of the message blob. | |||||||||||||
getPreloadLinks (Context $context) | |||||||||||||
Get a list of resources that web browsers may preload. | |||||||||||||
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. | |||||||||||||
Protected Attributes | |
const | CODEX_DEFAULT_LIBRARY_DIR = 'resources/lib/codex' |
![]() | |
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. | |
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. | |
bool | $skipStructureTest = false |
Whether to skip the structure test ResourcesTest::testRespond() | |
array< int, string|FilePath > | $styles = [] |
List of CSS file files to always include. | |
array< int|string, string|FilePath > | $templates = [] |
List of the named templates used by this module. | |
VueComponentParser null | $vueComponentParser = null |
Lazy-created by getVueComponentParser() | |
![]() | |
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. | |
array | $versionHash = [] |
Map of (context hash => cached module version hash) | |
Additional Inherited Members | |
![]() | |
static | tryForKey (array $list, $key, $fallback=null) |
Get a list of element that match a key, optionally using a fallback key. | |
![]() | |
static | safeFileHash ( $filePath) |
Compute a non-cryptographic string hash of a file's contents. | |
Module for codex that has direction-specific style files and a static helper function for embedding icons in package modules.
This module also contains logic to support code-splitting (aka tree-shaking) of the Codex library to return only a subset of component JS and/or CSS files.
Definition at line 40 of file CodexModule.php.
MediaWiki\ResourceLoader\CodexModule::__construct | ( | array | $options = [], |
$localBasePath = null, | |||
$remoteBasePath = null ) |
array | $options | [optional]
|
string | null | $localBasePath | [optional] |
string | null | $remoteBasePath | [optional] |
Definition at line 84 of file CodexModule.php.
References MediaWiki\ResourceLoader\FileModule\$localBasePath, and MediaWiki\ResourceLoader\FileModule\$remoteBasePath.
MediaWiki\ResourceLoader\CodexModule::getDefinitionSummary | ( | Context | $context | ) |
Get the definition summary for this module.
Context | $context |
Reimplemented from MediaWiki\ResourceLoader\FileModule.
Definition at line 231 of file CodexModule.php.
|
static |
Retrieve the specified icon definitions from codex-icons.json.
Intended as a convenience function to be used in packageFiles definitions.
Example: "packageFiles": [ { "name": "icons.json", "callback": "MediaWiki\\\\ResourceLoader\\\\CodexModule::getIcons", "callbackParam": [ "cdxIconClear", "cdxIconTrash" ] } ]
Context | null | $context | |
Config | $config | |
string[] | $iconNames | Names of icons to fetch |
Definition at line 163 of file CodexModule.php.
Referenced by MediaWiki\Api\ApiQueryCodexIcons\execute().
MediaWiki\ResourceLoader\CodexModule::getMessages | ( | ) |
Get message keys used by this module.
Reimplemented from MediaWiki\ResourceLoader\FileModule.
Definition at line 185 of file CodexModule.php.
MediaWiki\ResourceLoader\CodexModule::getPackageFiles | ( | Context | $context | ) |
Resolve the package files definition and generate the content of each package file.
Context | $context |
Reimplemented from MediaWiki\ResourceLoader\FileModule.
Definition at line 203 of file CodexModule.php.
MediaWiki\ResourceLoader\CodexModule::getStyleFiles | ( | Context | $context | ) |
Get a list of file paths for all styles in this module, in order of proper inclusion.
Context | $context |
Reimplemented from MediaWiki\ResourceLoader\FileModule.
Definition at line 209 of file CodexModule.php.
|
protected |
Process a CSS/LESS string.This method performs the following processing steps:
string | $style | CSS or LESS code |
string | $styleLang | Language of $style code ('css' or 'less') |
string | FilePath | $path | Path to code file, used for resolving relative file paths |
Context | $context |
Reimplemented from MediaWiki\ResourceLoader\FileModule.
Definition at line 215 of file CodexModule.php.
References $path, and MediaWiki\ResourceLoader\FilePath\getLocalPath().
MediaWiki\ResourceLoader\CodexModule::supportsURLLoading | ( | ) |
Reimplemented from MediaWiki\ResourceLoader\FileModule.
Definition at line 237 of file CodexModule.php.
|
protected |
Definition at line 41 of file CodexModule.php.