MediaWiki
1.23.0
|
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. More... | |
getAllStyleFiles () | |
Returns all style files used by this module. More... | |
getDefinitionSummary (ResourceLoaderContext $context) | |
Get the definition summary for this module. More... | |
getDependencies () | |
Gets list of names of modules this module depends on. More... | |
getFlip ( $context) | |
Get whether CSS for this module should be flipped. More... | |
getGroup () | |
Gets the name of the group this module should be loaded in. More... | |
getLoaderScript () | |
Gets loader script. More... | |
getMessages () | |
Gets list of message keys used by this module. More... | |
getModifiedTime (ResourceLoaderContext $context) | |
Get the last modified timestamp of this module. More... | |
getPosition () | |
getScript (ResourceLoaderContext $context) | |
Gets all scripts for a given context concatenated together. More... | |
getScriptURLsForDebug (ResourceLoaderContext $context) | |
getStyles (ResourceLoaderContext $context) | |
Gets all styles for a given context concatenated together. More... | |
getStyleSheetLang ( $path) | |
Infer the stylesheet language from a stylesheet file path. More... | |
getStyleURLsForDebug (ResourceLoaderContext $context) | |
getTargets () | |
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile']. More... | |
isRaw () | |
supportsURLLoading () | |
Public Member Functions inherited from ResourceLoaderModule | |
getDefinitionMtime (ResourceLoaderContext $context) | |
Helper method for calculating when this module's definition summary was last changed. More... | |
getFileDependencies ( $skin) | |
Get the files this module depends on indirectly for a given skin. More... | |
getHashMtime (ResourceLoaderContext $context) | |
Helper method for calculating when the module's hash (if it has one) changed. More... | |
getModifiedHash (ResourceLoaderContext $context) | |
Get the hash for whatever this module may contain. More... | |
getMsgBlobMtime ( $lang) | |
Get the last modification timestamp of the message blob for this module in a given language. More... | |
getName () | |
Get this module's name. More... | |
getOrigin () | |
Get this module's origin. More... | |
getSource () | |
Get the origin of this module. More... | |
isKnownEmpty (ResourceLoaderContext $context) | |
Check whether this module is known to be empty. More... | |
setFileDependencies ( $skin, $deps) | |
Set preloaded file dependency information. More... | |
setMsgBlobMtime ( $lang, $mtime) | |
Set a preloaded message blob last modification timestamp. More... | |
setName ( $name) | |
Set this module's name. More... | |
setOrigin ( $origin) | |
Set this module's origin. More... | |
Protected Member Functions | |
compileLESSFile ( $fileName) | |
Compile a LESS file into CSS. More... | |
getLocalPath ( $path) | |
getRemotePath ( $path) | |
getScriptFiles (ResourceLoaderContext $context) | |
Gets a list of file paths for all scripts in this module, in order of propper execution. More... | |
getStyleFiles (ResourceLoaderContext $context) | |
Gets a list of file paths for all styles in this module, in order of propper inclusion. More... | |
readScriptFiles (array $scripts) | |
Gets the contents of a list of JavaScript files. More... | |
readStyleFile ( $path, $flip) | |
Reads a style file. More... | |
readStyleFiles (array $styles, $flip) | |
Gets the contents of a list of CSS files. More... | |
Protected Member Functions inherited from ResourceLoaderModule | |
validateScriptFile ( $fileName, $contents) | |
Validate a given script file; if valid returns the original source. More... | |
Static Protected Member Functions | |
static | collateFilePathListByOption (array $list, $option, $default) |
Collates file paths by option (where provided). More... | |
static | getLESSCacheKey ( $fileName) |
Generate a cache key for a LESS file. More... | |
static | tryForKey (array $list, $key, $fallback=null) |
Gets a list of element that match a key, optionally using a fallback key. More... | |
Static Protected Member Functions inherited from ResourceLoaderModule | |
static | javaScriptParser () |
static | safeFilemtime ( $filename) |
Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist but returns 1 instead. More... | |
Protected Attributes | |
$debugRaw = true | |
Boolean: Link to raw files in debug mode. More... | |
$debugScripts = array() | |
Array: List of paths to JavaScript files to include in debug mode. More... | |
$dependencies = array() | |
Array: List of modules this module depends on. More... | |
$group | |
String: Name of group to load this module in. More... | |
$hasGeneratedStyles = false | |
Boolean: Whether getStyleURLsForDebug should return raw file paths, or return load.php urls. More... | |
$languageScripts = array() | |
Array: List of JavaScript files to include when using a specific language. More... | |
$loaderScripts = array() | |
Array: List of paths to JavaScript files to include in the startup module. More... | |
$localBasePath = '' | |
String: Local base path, see __construct() More... | |
$localFileRefs = array() | |
Array: Place where readStyleFile() tracks file dependencies. More... | |
$messages = array() | |
Array: List of message keys used by this module. More... | |
$modifiedTime = array() | |
Array: Cache for mtime. More... | |
$position = 'bottom' | |
String: Position on the page to load this module at. More... | |
$raw = false | |
Boolean: Whether mw.loader.state() call should be omitted. More... | |
$remoteBasePath = '' | |
String: Remote base path, see __construct() More... | |
$scripts = array() | |
Array: List of paths to JavaScript files to always include. More... | |
$skinScripts = array() | |
Array: List of JavaScript files to include when using a specific skin. More... | |
$skinStyles = array() | |
Array: List of paths to CSS files to include when using specific skins. More... | |
$styles = array() | |
Array: List of paths to CSS files to always include. More... | |
$targets = array( 'desktop' ) | |
Protected Attributes inherited from ResourceLoaderModule | |
$fileDeps = array() | |
$msgBlobMtime = array() | |
$name = null | |
$origin = self::ORIGIN_CORE_SITEWIDE | |
$targets = array( 'desktop' ) | |
Additional Inherited Members | |
Public Attributes inherited from ResourceLoaderModule | |
const | ORIGIN_ALL = 10 |
const | ORIGIN_CORE_INDIVIDUAL = 2 |
const | ORIGIN_CORE_SITEWIDE = 1 |
const | ORIGIN_USER_INDIVIDUAL = 4 |
const | ORIGIN_USER_SITEWIDE = 3 |
const | TYPE_COMBINED = 'combined' |
const | TYPE_MESSAGES = 'messages' |
const | TYPE_SCRIPTS = 'scripts' |
const | TYPE_STYLES = 'styles' |
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 $wgScriptPath |
Below is a description for the $options array:
MWException |
Definition at line 195 of file ResourceLoaderFileModule.php.
References $IP, $localBasePath, $options, $remoteBasePath, $value, array(), as, global, PROTO_RELATIVE, and wfExpandUrl().
|
staticprotected |
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 547 of file ResourceLoaderFileModule.php.
References $value, array(), and as.
Referenced by getModifiedTime().
|
protected |
Compile a LESS file into CSS.
If invalid, returns replacement CSS source consisting of the compilation error message encoded as a comment. To save work, we cache a result object which comprises the compiled CSS and the names & mtimes of the files that were processed. lessphp compares the cached & current mtimes and recompiles as necessary.
Exception | If Less encounters a parse error |
MWException | If Less compilation returns unexpection result |
string | $fileName | File path of LESS source |
Definition at line 794 of file ResourceLoaderFileModule.php.
References $cache, $source, CACHE_ANYTHING, getLESSCacheKey(), ResourceLoader\getLessCompiler(), and wfGetCache().
Referenced by readStyleFile().
ResourceLoaderFileModule::getAllStyleFiles | ( | ) |
Returns all style files used by this module.
Definition at line 629 of file ResourceLoaderFileModule.php.
References $files, $path, $value, array(), as, and getLocalPath().
ResourceLoaderFileModule::getDefinitionSummary | ( | ResourceLoaderContext | $context | ) |
Get the definition summary for this module.
Reimplemented from ResourceLoaderModule.
Definition at line 482 of file ResourceLoaderFileModule.php.
ResourceLoaderFileModule::getDependencies | ( | ) |
Gets list of names of modules this module depends on.
Reimplemented from ResourceLoaderModule.
Definition at line 394 of file ResourceLoaderFileModule.php.
References $dependencies.
ResourceLoaderFileModule::getFlip | ( | $context | ) |
Get whether CSS for this module should be flipped.
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 750 of file ResourceLoaderFileModule.php.
Referenced by getStyles().
ResourceLoaderFileModule::getGroup | ( | ) |
Gets the name of the group this module should be loaded in.
Reimplemented from ResourceLoaderModule.
Definition at line 378 of file ResourceLoaderFileModule.php.
References $group.
|
staticprotected |
Generate a cache key for a LESS file.
The cache key varies on the file name and the names and values of global LESS variables.
string | $fileName | File name of root LESS file. |
Definition at line 773 of file ResourceLoaderFileModule.php.
References $hash, $vars, ResourceLoader\getLESSVars(), and wfMemcKey().
Referenced by compileLESSFile().
ResourceLoaderFileModule::getLoaderScript | ( | ) |
Gets loader script.
Reimplemented from ResourceLoaderModule.
Definition at line 304 of file ResourceLoaderFileModule.php.
References readScriptFiles().
|
protected |
string | $path |
Definition at line 515 of file ResourceLoaderFileModule.php.
Referenced by getAllStyleFiles(), readScriptFiles(), and readStyleFile().
ResourceLoaderFileModule::getMessages | ( | ) |
Gets list of message keys used by this module.
Reimplemented from ResourceLoaderModule.
Definition at line 369 of file ResourceLoaderFileModule.php.
References $messages.
ResourceLoaderFileModule::getModifiedTime | ( | ResourceLoaderContext | $context | ) |
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.
Definition at line 419 of file ResourceLoaderFileModule.php.
References $files, $styles, array(), as, collateFilePathListByOption(), ResourceLoaderContext\getDebug(), ResourceLoaderModule\getDefinitionMtime(), ResourceLoaderModule\getFileDependencies(), ResourceLoaderContext\getHash(), ResourceLoaderContext\getLanguage(), ResourceLoaderModule\getMsgBlobMtime(), ResourceLoaderContext\getSkin(), scripts, tryForKey(), wfProfileIn(), and wfProfileOut().
ResourceLoaderFileModule::getPosition | ( | ) |
Reimplemented from ResourceLoaderModule.
Definition at line 385 of file ResourceLoaderFileModule.php.
References $position.
|
protected |
string | $path |
Definition at line 523 of file ResourceLoaderFileModule.php.
Referenced by getScriptURLsForDebug(), getStyleURLsForDebug(), and readStyleFile().
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 275 of file ResourceLoaderFileModule.php.
References $files, getScriptFiles(), and readScriptFiles().
|
protected |
Gets a list of file paths for all scripts in this module, in order of propper execution.
ResourceLoaderContext | $context |
Definition at line 595 of file ResourceLoaderFileModule.php.
References $files, ResourceLoaderContext\getDebug(), ResourceLoaderContext\getLanguage(), ResourceLoaderContext\getSkin(), and scripts.
Referenced by getScript(), and getScriptURLsForDebug().
ResourceLoaderFileModule::getScriptURLsForDebug | ( | ResourceLoaderContext | $context | ) |
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 284 of file ResourceLoaderFileModule.php.
References $file, array(), as, getRemotePath(), and getScriptFiles().
|
protected |
Gets a list of file paths for all styles in this module, in order of propper inclusion.
ResourceLoaderContext | $context |
Definition at line 614 of file ResourceLoaderFileModule.php.
References ResourceLoaderContext\getSkin().
Referenced by getStyles(), and getStyleURLsForDebug().
ResourceLoaderFileModule::getStyles | ( | ResourceLoaderContext | $context | ) |
Gets all styles for a given context concatenated together.
ResourceLoaderContext | $context | Context in which to generate styles |
Reimplemented from ResourceLoaderModule.
Definition at line 317 of file ResourceLoaderFileModule.php.
References $e, $styles, array(), DB_MASTER, FormatJson\encode(), ResourceLoaderModule\getFileDependencies(), getFlip(), ResourceLoaderModule\getName(), ResourceLoaderContext\getSkin(), getStyleFiles(), readStyleFiles(), wfDebugLog(), and wfGetDB().
ResourceLoaderFileModule::getStyleSheetLang | ( | $path | ) |
Infer the stylesheet language from a stylesheet file path.
string | $path |
Definition at line 534 of file ResourceLoaderFileModule.php.
References $path.
Referenced by readStyleFile().
ResourceLoaderFileModule::getStyleURLsForDebug | ( | ResourceLoaderContext | $context | ) |
ResourceLoaderContext | $context |
Reimplemented from ResourceLoaderModule.
Definition at line 346 of file ResourceLoaderFileModule.php.
References $file, array(), as, getRemotePath(), and getStyleFiles().
ResourceLoaderFileModule::getTargets | ( | ) |
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
Reimplemented from ResourceLoaderModule.
Definition at line 759 of file ResourceLoaderFileModule.php.
References $targets.
ResourceLoaderFileModule::isRaw | ( | ) |
Reimplemented from ResourceLoaderModule.
Definition at line 401 of file ResourceLoaderFileModule.php.
References $raw.
|
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 649 of file ResourceLoaderFileModule.php.
References $scripts, as, getLocalPath(), global, and ResourceLoaderModule\validateScriptFile().
Referenced by getLoaderScript(), and getScript().
|
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 |
MWException | if the file doesn't exist |
Definition at line 710 of file ResourceLoaderFileModule.php.
References $dir, $path, compileLESSFile(), CSSMin\getLocalFileReferences(), getLocalPath(), getRemotePath(), getStyleSheetLang(), CSSMin\remap(), CSSJanus\transform(), and wfDebugLog().
Referenced by readStyleFiles().
|
protected |
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 |
MWException |
Definition at line 684 of file ResourceLoaderFileModule.php.
References $file, $files, $styles, array(), as, and readStyleFile().
Referenced by getStyles().
ResourceLoaderFileModule::supportsURLLoading | ( | ) |
Reimplemented from ResourceLoaderModule.
Definition at line 295 of file ResourceLoaderFileModule.php.
References $debugRaw.
|
staticprotected |
Gets 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 577 of file ResourceLoaderFileModule.php.
References $fallback, and array().
Referenced by getModifiedTime().
|
protected |
Boolean: Link to raw files in debug mode.
Definition at line 113 of file ResourceLoaderFileModule.php.
Referenced by supportsURLLoading().
|
protected |
|
protected |
Array: List of modules this module depends on.
Definition at line 99 of file ResourceLoaderFileModule.php.
Referenced by getDependencies().
|
protected |
String: Name of group to load this module in.
Definition at line 109 of file ResourceLoaderFileModule.php.
Referenced by getGroup().
|
protected |
Boolean: Whether getStyleURLsForDebug should return raw file paths, or return load.php urls.
Definition at line 122 of file ResourceLoaderFileModule.php.
|
protected |
|
protected |
Array: List of paths to JavaScript files to include in the startup module.
Definition at line 75 of file ResourceLoaderFileModule.php.
|
protected |
String: Local base path, see __construct()
Definition at line 33 of file ResourceLoaderFileModule.php.
Referenced by __construct().
|
protected |
Array: Place where readStyleFile() tracks file dependencies.
Definition at line 139 of file ResourceLoaderFileModule.php.
|
protected |
Array: List of message keys used by this module.
Definition at line 107 of file ResourceLoaderFileModule.php.
Referenced by getMessages().
|
protected |
Array: Cache for mtime.
Definition at line 131 of file ResourceLoaderFileModule.php.
|
protected |
String: Position on the page to load this module at.
Definition at line 111 of file ResourceLoaderFileModule.php.
Referenced by getPosition().
|
protected |
Boolean: Whether mw.loader.state() call should be omitted.
Definition at line 115 of file ResourceLoaderFileModule.php.
Referenced by isRaw().
|
protected |
String: Remote base path, see __construct()
Definition at line 35 of file ResourceLoaderFileModule.php.
Referenced by __construct().
|
protected |
Array: List of paths to JavaScript files to always include.
Definition at line 43 of file ResourceLoaderFileModule.php.
Referenced by readScriptFiles().
|
protected |
|
protected |
Array: List of paths to CSS files to include when using specific skins.
Definition at line 91 of file ResourceLoaderFileModule.php.
|
protected |
Array: List of paths to CSS files to always include.
Definition at line 83 of file ResourceLoaderFileModule.php.
Referenced by getModifiedTime(), getStyles(), and readStyleFiles().
|
protected |
Definition at line 116 of file ResourceLoaderFileModule.php.
Referenced by getTargets().