[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Abstraction for resource loader modules. 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.
Author: | Trevor Parscal |
Author: | Roan Kattouw |
File Size: | 645 lines (20 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
getName() X-Ref |
Get this module's name. This is set when the module is registered with ResourceLoader::register() return: string|null Name (string) or null if no name was set |
setName( $name ) X-Ref |
Set this module's name. This is called by ResourceLoader::register() when registering the module. Other code should not call this. param: string $name Name |
getOrigin() X-Ref |
Get this module's origin. This is set when the module is registered with ResourceLoader::register() return: int ResourceLoaderModule class constant, the subclass default |
setOrigin( $origin ) X-Ref |
Set this module's origin. This is called by ResourceLoader::register() when registering the module. Other code should not call this. param: int $origin Origin |
getFlip( $context ) X-Ref |
param: ResourceLoaderContext $context return: bool |
getScript( ResourceLoaderContext $context ) X-Ref |
Get all JS for this module for a given language and skin. Includes all relevant JS except loader scripts. param: ResourceLoaderContext $context return: string JavaScript code |
getConfig() X-Ref |
return: Config |
setConfig( Config $config ) X-Ref |
param: Config $config |
getScriptURLsForDebug( ResourceLoaderContext $context ) X-Ref |
Get the URL or URLs to load for this module's JS in debug mode. The default behavior is to return a load.php?only=scripts URL for the module, but file-based modules will want to override this to load the files directly. This function is called only when 1) we're in debug mode, 2) there is no only= parameter and 3) supportsURLLoading() returns true. #2 is important to prevent an infinite loop, therefore this function MUST return either an only= URL or a non-load.php URL. param: ResourceLoaderContext $context return: array Array of URLs |
supportsURLLoading() X-Ref |
Whether this module supports URL loading. If this function returns false, getScript() will be used even in cases (debug mode, no only param) where getScriptURLsForDebug() would normally be used instead. return: bool |
getStyles( ResourceLoaderContext $context ) X-Ref |
Get all CSS for this module for a given skin. param: ResourceLoaderContext $context return: array List of CSS strings or array of CSS strings keyed by media type. |
getStyleURLsForDebug( ResourceLoaderContext $context ) X-Ref |
Get the URL or URLs to load for this module's CSS in debug mode. The default behavior is to return a load.php?only=styles URL for the module, but file-based modules will want to override this to load the files directly. See also getScriptURLsForDebug() param: ResourceLoaderContext $context return: array Array( mediaType => array( URL1, URL2, ... ), ... ) |
getMessages() X-Ref |
Get the messages needed for this module. To get a JSON blob with messages, use MessageBlobStore::get() return: array List of message keys. Keys may occur more than once |
getGroup() X-Ref |
Get the group this module is in. return: string Group name |
getSource() X-Ref |
Get the origin of this module. Should only be overridden for foreign modules. return: string Origin name, 'local' for local modules |
getPosition() X-Ref |
Where on the HTML page should this module's JS be loaded? - 'top': in the "<head>" - 'bottom': at the bottom of the "<body>" return: string |
isRaw() X-Ref |
Whether this module's JS expects to work without the client-side ResourceLoader module. Returning true from this function will prevent mw.loader.state() call from being appended to the bottom of the script. return: bool |
getLoaderScript() X-Ref |
Get the loader JS for this module, if set. return: mixed JavaScript loader code as a string or boolean false if no custom loader set |
getDependencies() X-Ref |
Get a list of modules this module depends on. Dependency information is taken into account when loading a module on the client side. To add dependencies dynamically on the client side, use a custom loader script, see getLoaderScript() return: array List of module names as strings |
getTargets() X-Ref |
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'] return: array Array of strings |
getSkipFunction() X-Ref |
Get the skip function. Modules that provide fallback functionality can provide a "skip function". This function, if provided, will be passed along to the module registry on the client. When this module is loaded (either directly or as a dependency of another module), then this function is executed first. If the function returns true, the module will instantly be considered "ready" without requesting the associated module resources. The value returned here must be valid javascript for execution in a private function. It must not contain the "function () {" and "}" wrapper though. return: string|null A JavaScript function body returning a boolean value, or null |
getFileDependencies( $skin ) X-Ref |
Get the files this module depends on indirectly for a given skin. Currently these are only image files referenced by the module's CSS. param: string $skin Skin name return: array List of files |
setFileDependencies( $skin, $deps ) X-Ref |
Set preloaded file dependency information. Used so we can load this information for all modules at once. param: string $skin Skin name param: array $deps Array of file names |
getMsgBlobMtime( $lang ) X-Ref |
Get the last modification timestamp of the message blob for this module in a given language. param: string $lang Language code return: int UNIX timestamp, or 0 if the module doesn't have messages |
setMsgBlobMtime( $lang, $mtime ) X-Ref |
Set a preloaded message blob last modification timestamp. Used so we can load this information for all modules at once. param: string $lang Language code param: int $mtime UNIX timestamp or 0 if there is no such blob |
getModifiedTime( ResourceLoaderContext $context ) X-Ref |
Get this module's last modification timestamp for a given combination of language, skin and debug mode flag. This is typically the highest of each of the relevant components' modification timestamps. Whenever anything happens that changes the module's contents for these parameters, the mtime should increase. NOTE: The mtime of the module's messages is NOT automatically included. If you want this to happen, you'll need to call getMsgBlobMtime() yourself and take its result into consideration. NOTE: The mtime of the module's hash is NOT automatically included. If your module provides a getModifiedHash() method, you'll need to call getHashMtime() yourself and take its result into consideration. param: ResourceLoaderContext $context Context object return: int UNIX timestamp |
getHashMtime( ResourceLoaderContext $context ) X-Ref |
Helper method for calculating when the module's hash (if it has one) changed. param: ResourceLoaderContext $context return: int UNIX timestamp or 0 if no hash was provided |
getModifiedHash( ResourceLoaderContext $context ) X-Ref |
Get the hash for whatever this module may contain. This is the method subclasses should implement if they want to make use of getHashMTime() inside getModifiedTime(). param: ResourceLoaderContext $context return: string|null Hash |
getDefinitionMtime( ResourceLoaderContext $context ) X-Ref |
Helper method for calculating when this module's definition summary was last changed. param: ResourceLoaderContext $context return: int UNIX timestamp or 0 if no definition summary was provided |
getDefinitionSummary( ResourceLoaderContext $context ) X-Ref |
Get the definition summary for this module. This is the method subclasses should implement if they want to make use of getDefinitionMTime() inside getModifiedTime(). Return an array containing values from all significant properties of this module's definition. Be sure to include things that are explicitly ordered, in their actaul order (bug 37812). Avoid including things that are insiginificant (e.g. order of message keys is insignificant and should be sorted to avoid unnecessary cache invalidation). Avoid including things already considered by other methods inside your getModifiedTime(), such as file mtime timestamps. Serialisation is done using json_encode, which means object state is not taken into account when building the hash. This data structure must only contain arrays and scalars as values (avoid object instances) which means it requires abstraction. param: ResourceLoaderContext $context return: array|null |
isKnownEmpty( ResourceLoaderContext $context ) X-Ref |
Check whether this module is known to be empty. If a child class has an easy and cheap way to determine that this module is definitely going to be empty, it should override this method to return true in that case. Callers may optimize the request for this module away if this function returns true. param: ResourceLoaderContext $context return: bool |
validateScriptFile( $fileName, $contents ) X-Ref |
Validate a given script file; if valid returns the original source. If invalid, returns replacement JS source that throws an exception. param: string $fileName param: string $contents return: string JS with the original, or a replacement error |
javaScriptParser() X-Ref |
return: JSParser |
safeFilemtime( $filename ) X-Ref |
Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist but returns 1 instead. param: string $filename File name return: int UNIX timestamp, or 1 if the file doesn't exist |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |