MediaWiki
REL1_24
|
ResourceLoader module based on local JavaScript/CSS files. More...
Public Member Functions | |
__construct ($options=array(), $localBasePath=null, $remoteBasePath=null) | |
Constructs a new module from an options array. | |
getAllStyleFiles () | |
Returns all style files and all skin style files used by this module. | |
getDefinitionSummary (ResourceLoaderContext $context) | |
Get the definition summary for this module. | |
getDependencies () | |
Gets list of names of modules this module depends on. | |
getFlip ($context) | |
Get whether CSS for this module should be flipped. | |
getGroup () | |
Gets the name of the group this module should be loaded in. | |
getLoaderScript () | |
Get loader script. | |
getMessages () | |
Gets list of message keys used by this module. | |
getModifiedTime (ResourceLoaderContext $context) | |
Get the last modified timestamp of this module. | |
getPosition () | |
getScript (ResourceLoaderContext $context) | |
Gets all scripts for a given context concatenated together. | |
getScriptURLsForDebug (ResourceLoaderContext $context) | |
getSkipFunction () | |
Get the skip function. | |
getStyleFiles (ResourceLoaderContext $context) | |
Get a list of file paths for all styles in this module, in order of proper inclusion. | |
getStyles (ResourceLoaderContext $context) | |
Get all styles for a given context. | |
getStyleSheetLang ($path) | |
Infer the stylesheet language from a stylesheet file path. | |
getStyleURLsForDebug (ResourceLoaderContext $context) | |
getTargets () | |
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile']. | |
isRaw () | |
readStyleFiles (array $styles, $flip, $context=null) | |
Gets the contents of a list of CSS files. | |
supportsURLLoading () | |
Static Public Member Functions | |
static | extractBasePaths ($options=array(), $localBasePath=null, $remoteBasePath=null) |
Extract a pair of local and remote base paths from module definition information. | |
Protected Member Functions | |
compileLessFile ($fileName, $compiler=null) | |
Compile a LESS file into CSS. | |
getAllSkinStyleFiles () | |
Gets a list of file paths for all skin style files in the module, for all available skins. | |
getLessCompiler (ResourceLoaderContext $context=null) | |
Get a LESS compiler instance for this module in given context. | |
getLocalPath ($path) | |
getRemotePath ($path) | |
getScriptFiles (ResourceLoaderContext $context) | |
Get a list of file paths for all scripts in this module, in order of proper execution. | |
getSkinStyleFiles ($skinName) | |
Gets a list of file paths for all skin styles in the module used by the skin. | |
readScriptFiles (array $scripts) | |
Gets the contents of a list of JavaScript files. | |
readStyleFile ($path, $flip, $context=null) | |
Reads a style file. | |
Static Protected Member Functions | |
static | collateFilePathListByOption (array $list, $option, $default) |
Collates file paths by option (where provided). | |
static | tryForKey (array $list, $key, $fallback=null) |
Get a list of element that match a key, optionally using a fallback key. | |
Protected Attributes | |
bool | $debugRaw = true |
Link to raw files in debug mode *. | |
array | $debugScripts = array() |
List of paths to JavaScript files to include in debug mode. | |
array | $dependencies = array() |
List of modules this module depends on. | |
string | $group |
Name of group to load this module in *. | |
bool | $hasGeneratedStyles = false |
Whether getStyleURLsForDebug should return raw file paths, or return load.php urls. | |
array | $languageScripts = array() |
List of JavaScript files to include when using a specific language. | |
array | $loaderScripts = array() |
List of paths to JavaScript files to include in the startup module. | |
string | $localBasePath = '' |
Local base path, see __construct() *. | |
array | $localFileRefs = array() |
Place where readStyleFile() tracks file dependencies. | |
array | $messages = array() |
List of message keys used by this module. | |
array | $modifiedTime = array() |
Cache for mtime. | |
string | $position = 'bottom' |
Position on the page to load this module at *. | |
bool | $raw = false |
Whether mw.loader.state() call should be omitted *. | |
string | $remoteBasePath = '' |
Remote base path, see __construct() *. | |
array | $scripts = array() |
List of paths to JavaScript files to always include. | |
array | $skinScripts = array() |
List of JavaScript files to include when using a specific skin. | |
array | $skinStyles = array() |
List of paths to CSS files to include when using specific skins. | |
string | $skipFunction = null |
File name containing the body of the skip function. | |
array | $styles = array() |
List of paths to CSS files to always include. | |
$targets = array( 'desktop' ) |
ResourceLoader module based on local JavaScript/CSS files.
Definition at line 28 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::__construct | ( | $ | options = array() , |
$ | localBasePath = null , |
||
$ | remoteBasePath = null |
||
) |
Constructs a new module from an options array.
array | $options | List of options; if not given or empty, an empty module will be constructed |
string | $localBasePath | Base path to prepend to all local paths in $options. Defaults to $IP |
string | $remoteBasePath | Base path to prepend to all remote paths in $options. Defaults to $wgResourceBasePath |
Below is a description for the $options array:
MWException |
array( // Base path to prepend to all local paths in $options. Defaults to $IP 'localBasePath' => [base path], // Base path to prepend to all remote paths in $options. Defaults to $wgResourceBasePath 'remoteBasePath' => [base path], // Equivalent of remoteBasePath, but relative to $wgExtensionAssetsPath 'remoteExtPath' => [base path], // Equivalent of remoteBasePath, but relative to $wgStylePath 'remoteSkinPath' => [base path], // Scripts to always include 'scripts' => [file path string or array of file path strings], // Scripts to include in specific language contexts 'languageScripts' => array( [language code] => [file path string or array of file path strings], ), // Scripts to include in specific skin contexts 'skinScripts' => array( [skin name] => [file path string or array of file path strings], ), // Scripts to include in debug contexts 'debugScripts' => [file path string or array of file path strings], // Scripts to include in the startup module 'loaderScripts' => [file path string or array of file path strings], // Modules which must be loaded before this module 'dependencies' => [module name string or array of module name strings], // Styles to always load 'styles' => [file path string or array of file path strings], // Styles to include in specific skin contexts 'skinStyles' => array( [skin name] => [file path string or array of file path strings], ), // Messages to always load 'messages' => [array of message key strings], // Group which this module should be loaded together with 'group' => [group name string], // Position on the page to load this module at 'position' => ['bottom' (default) or 'top'] // Function that, if it returns true, makes the loader skip this module. // The file must contain valid JavaScript for execution in a private function. // The file must not contain the "function () {" and "}" wrapper though. 'skipFunction' => [file path] )
Definition at line 202 of file ResourceLoaderFileModule.php.
static ResourceLoaderFileModule::collateFilePathListByOption | ( | array $ | list, |
$ | option, | ||
$ | default | ||
) | [static, protected] |
Collates file paths by option (where provided).
array | $list | List of file paths in any combination of index/path or path/options pairs |
string | $option | Option name |
mixed | $default | Default value if the option isn't set |
Definition at line 631 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::compileLessFile | ( | $ | fileName, |
$ | compiler = null |
||
) | [protected] |
Compile a LESS file into CSS.
Keeps track of all used files and adds them to localFileRefs.
Exception | If lessc encounters a parse error |
string | $fileName | File path of LESS source |
lessc | $compiler | Compiler to use, if not default |
Definition at line 896 of file ResourceLoaderFileModule.php.
static ResourceLoaderFileModule::extractBasePaths | ( | $ | options = array() , |
$ | localBasePath = null , |
||
$ | remoteBasePath = null |
||
) | [static] |
Extract a pair of local and remote base paths from module definition information.
Implementation note: the amount of global state used in this function is staggering.
array | $options | Module definition |
string | $localBasePath | Path to use if not provided in module definition. Defaults to $IP |
string | $remoteBasePath | Path to use if not provided in module definition. Defaults to $wgResourceBasePath |
Definition at line 278 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getAllSkinStyleFiles | ( | ) | [protected] |
Gets a list of file paths for all skin style files in the module, for all available skins.
Definition at line 730 of file ResourceLoaderFileModule.php.
Returns all style files and all skin style files used by this module.
Definition at line 750 of file ResourceLoaderFileModule.php.
Get the definition summary for this module.
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 557 of file ResourceLoaderFileModule.php.
Gets list of names of modules this module depends on.
Reimplemented from ResourceLoaderModule.
Definition at line 444 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getFlip | ( | $ | context | ) |
Get whether CSS for this module should be flipped.
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 872 of file ResourceLoaderFileModule.php.
Gets the name of the group this module should be loaded in.
Reimplemented from ResourceLoaderModule.
Definition at line 428 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getLessCompiler | ( | ResourceLoaderContext $ | context = null | ) | [protected] |
Get a LESS compiler instance for this module in given context.
Just calls ResourceLoader::getLessCompiler() by default to get a global compiler.
ResourceLoaderContext | $context |
MWException |
Reimplemented in ResourceLoaderEditToolbarModule.
Definition at line 915 of file ResourceLoaderFileModule.php.
References $result.
Get loader script.
Reimplemented from ResourceLoaderModule.
Definition at line 353 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getLocalPath | ( | $ | path | ) | [protected] |
string | ResourceLoaderFilePath | $path |
Definition at line 591 of file ResourceLoaderFileModule.php.
References $summary.
Referenced by isRaw().
Gets list of message keys used by this module.
Reimplemented from ResourceLoaderModule.
Definition at line 419 of file ResourceLoaderFileModule.php.
Get the last modified timestamp of this module.
Last modified timestamps are calculated from the highest last modified timestamp of this module's constituent files as well as the files it depends on. This function is context-sensitive, only performing calculations on files relevant to the given language, skin and debug mode.
ResourceLoaderContext | $context | Context in which to calculate the modified time |
Reimplemented from ResourceLoaderModule.
Reimplemented in ResourceLoaderEditToolbarModule.
Definition at line 490 of file ResourceLoaderFileModule.php.
Reimplemented from ResourceLoaderModule.
Definition at line 435 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getRemotePath | ( | $ | path | ) | [protected] |
string | ResourceLoaderFilePath | $path |
Definition at line 603 of file ResourceLoaderFileModule.php.
References $path.
ResourceLoaderFileModule::getScript | ( | ResourceLoaderContext $ | context | ) |
Gets all scripts for a given context concatenated together.
ResourceLoaderContext | $context | Context in which to generate script |
Reimplemented from ResourceLoaderModule.
Definition at line 324 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getScriptFiles | ( | ResourceLoaderContext $ | context | ) | [protected] |
Get a list of file paths for all scripts in this module, in order of proper execution.
ResourceLoaderContext | $context |
Definition at line 679 of file ResourceLoaderFileModule.php.
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 333 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getSkinStyleFiles | ( | $ | skinName | ) | [protected] |
Gets a list of file paths for all skin styles in the module used by the skin.
string | $skinName | The name of the skin |
Definition at line 716 of file ResourceLoaderFileModule.php.
Get the skip function.
Reimplemented from ResourceLoaderModule.
Definition at line 453 of file ResourceLoaderFileModule.php.
Get a list of file paths for all styles in this module, in order of proper inclusion.
ResourceLoaderContext | $context |
Definition at line 698 of file ResourceLoaderFileModule.php.
References $files, ResourceLoaderContext\getDebug(), ResourceLoaderContext\getLanguage(), ResourceLoaderContext\getSkin(), and scripts.
ResourceLoaderFileModule::getStyles | ( | ResourceLoaderContext $ | context | ) |
Get all styles for a given context.
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 366 of file ResourceLoaderFileModule.php.
References readScriptFiles().
Infer the stylesheet language from a stylesheet file path.
string | $path |
Definition at line 618 of file ResourceLoaderFileModule.php.
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 396 of file ResourceLoaderFileModule.php.
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
Reimplemented from ResourceLoaderModule.
Definition at line 881 of file ResourceLoaderFileModule.php.
Reimplemented from ResourceLoaderModule.
Definition at line 472 of file ResourceLoaderFileModule.php.
References ResourceLoaderModule\getConfig(), getLocalPath(), and ResourceLoaderModule\validateScriptFile().
ResourceLoaderFileModule::readScriptFiles | ( | array $ | scripts | ) | [protected] |
Gets the contents of a list of JavaScript files.
array | $scripts | List of file paths to scripts to read, remap and concetenate |
MWException |
Definition at line 774 of file ResourceLoaderFileModule.php.
Referenced by getStyles().
ResourceLoaderFileModule::readStyleFile | ( | $ | path, |
$ | flip, | ||
$ | context = null |
||
) | [protected] |
Reads a style file.
This method can be used as a callback for array_map()
string | $path | File path of style file to read |
bool | $flip | |
ResourceLoaderContext | $context | (optional) |
MWException | If the file doesn't exist |
Definition at line 835 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::readStyleFiles | ( | array $ | styles, |
$ | flip, | ||
$ | context = null |
||
) |
Gets the contents of a list of CSS files.
array | $styles | List of media type/list of file paths pairs, to read, remap and concetenate |
bool | $flip | |
ResourceLoaderContext | $context | (optional) |
MWException |
Definition at line 808 of file ResourceLoaderFileModule.php.
Reimplemented from ResourceLoaderModule.
Definition at line 344 of file ResourceLoaderFileModule.php.
static ResourceLoaderFileModule::tryForKey | ( | array $ | list, |
$ | key, | ||
$ | fallback = null |
||
) | [static, protected] |
Get a list of element that match a key, optionally using a fallback key.
array | $list | List of lists to select from |
string | $key | Key to look for in $map |
string | $fallback | Key to look for in $list if $key doesn't exist |
Definition at line 661 of file ResourceLoaderFileModule.php.
References array().
bool ResourceLoaderFileModule::$debugRaw = true [protected] |
Link to raw files in debug mode *.
Definition at line 115 of file ResourceLoaderFileModule.php.
List of modules this module depends on.
Definition at line 97 of file ResourceLoaderFileModule.php.
string ResourceLoaderFileModule::$group [protected] |
Name of group to load this module in *.
Definition at line 111 of file ResourceLoaderFileModule.php.
bool ResourceLoaderFileModule::$hasGeneratedStyles = false [protected] |
Whether getStyleURLsForDebug should return raw file paths, or return load.php urls.
Definition at line 124 of file ResourceLoaderFileModule.php.
List of paths to JavaScript files to include in the startup module.
Definition at line 73 of file ResourceLoaderFileModule.php.
string ResourceLoaderFileModule::$localBasePath = '' [protected] |
Local base path, see __construct() *.
Definition at line 31 of file ResourceLoaderFileModule.php.
Place where readStyleFile() tracks file dependencies.
Definition at line 140 of file ResourceLoaderFileModule.php.
Cache for mtime.
array( [hash] => [mtime], [hash] => [mtime], ... )
Definition at line 132 of file ResourceLoaderFileModule.php.
string ResourceLoaderFileModule::$position = 'bottom' [protected] |
Position on the page to load this module at *.
Definition at line 113 of file ResourceLoaderFileModule.php.
bool ResourceLoaderFileModule::$raw = false [protected] |
Whether mw.loader.state() call should be omitted *.
Definition at line 117 of file ResourceLoaderFileModule.php.
string ResourceLoaderFileModule::$remoteBasePath = '' [protected] |
Remote base path, see __construct() *.
Definition at line 33 of file ResourceLoaderFileModule.php.
List of paths to JavaScript files to always include.
Definition at line 41 of file ResourceLoaderFileModule.php.
List of paths to CSS files to include when using specific skins.
Definition at line 89 of file ResourceLoaderFileModule.php.
string ResourceLoaderFileModule::$skipFunction = null [protected] |
File name containing the body of the skip function.
Definition at line 101 of file ResourceLoaderFileModule.php.
List of paths to CSS files to always include.
Definition at line 81 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::$targets = array( 'desktop' ) [protected] |
Reimplemented from ResourceLoaderModule.
Definition at line 119 of file ResourceLoaderFileModule.php.