[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Base class for resource loading system. 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: | Roan Kattouw |
Author: | Trevor Parscal |
File Size: | 1496 lines (50 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
ResourceLoader:: (39 methods):
preloadModuleInfo()
filter()
__construct()
getConfig()
register()
registerTestModules()
addSource()
getModuleNames()
getTestModuleNames()
getModule()
isFileModule()
getSources()
getLoadScript()
respond()
sendResponseHeaders()
tryRespondLastModified()
tryRespondFromFileCache()
makeComment()
formatException()
makeModuleResponse()
makeLoaderImplementScript()
makeMessageSetScript()
makeCombinedStyles()
makeLoaderStateScript()
makeCustomLoaderScript()
makeLoaderRegisterScript()
makeLoaderSourcesScript()
makeLoaderConditionalScript()
makeConfigSetScript()
makePackedModulesString()
inDebugMode()
clearCache()
createLoaderURL()
makeLoaderURL()
createLoaderQuery()
makeLoaderQuery()
isValidModuleName()
getLessCompiler()
getLessVars()
Class: ResourceLoader - X-Ref
Dynamic JavaScript and CSS resource loading system.preloadModuleInfo( array $modules, ResourceLoaderContext $context ) X-Ref |
Load information stored in the database about modules. This method grabs modules dependencies from the database and updates modules objects. This is not inside the module code because it is much faster to request all of the information at once than it is to have each module requests its own information. This sacrifice of modularity yields a substantial performance improvement. param: array $modules List of module names to preload information for param: ResourceLoaderContext $context Context to load the information within |
filter( $filter, $data, $cacheReport = true ) X-Ref |
Run JavaScript or CSS data through a filter, caching the filtered result for future calls. Available filters are: - minify-js \see JavaScriptMinifier::minify - minify-css \see CSSMin::minify If $data is empty, only contains whitespace or the filter was unknown, $data is returned unmodified. param: string $filter Name of filter to run param: string $data Text to filter, such as JavaScript or CSS text param: string $cacheReport Whether to include the cache key report return: string Filtered data, or a comment containing an error message |
__construct( Config $config = null ) X-Ref |
Register core modules and runs registration hooks. param: Config|null $config |
getConfig() X-Ref |
return: Config |
register( $name, $info = null ) X-Ref |
Register a module with the ResourceLoader system. param: mixed $name Name of module as a string or List of name/object pairs as an array param: array $info Module info array. For backwards compatibility with 1.17alpha, return: bool False if there were any errors, in which case one or more modules were |
registerTestModules() X-Ref |
No description |
addSource( $id, $loadUrl = null ) X-Ref |
Add a foreign source of modules. param: array|string $id Source ID (string), or array( id1 => loadUrl, id2 => loadUrl, ... ) param: string|array $loadUrl load.php url (string), or array with loadUrl key for |
getModuleNames() X-Ref |
Get a list of module names. return: array List of module names |
getTestModuleNames( $framework = 'all' ) X-Ref |
Get a list of test module names for one (or all) frameworks. If the given framework id is unknkown, or if the in-object variable is not an array, then it will return an empty array. param: string $framework Get only the test module names for one return: array |
getModule( $name ) X-Ref |
Get the ResourceLoaderModule object for a given module name. If an array of module parameters exists but a ResourceLoaderModule object has not yet been instantiated, this method will instantiate and cache that object such that subsequent calls simply return the same object. param: string $name Module name return: ResourceLoaderModule|null If module has been registered, return a |
isFileModule( $name ) X-Ref |
Return whether the definition of a module corresponds to a simple ResourceLoaderFileModule. param: string $name Module name return: bool |
getSources() X-Ref |
Get the list of sources. return: array Like array( id => load.php url, .. ) |
getLoadScript( $source ) X-Ref |
Get the URL to the load.php endpoint for the given ResourceLoader source param: string $source return: string |
respond( ResourceLoaderContext $context ) X-Ref |
Output a response to a load request, including the content-type header. param: ResourceLoaderContext $context Context in which a response should be formed |
sendResponseHeaders( ResourceLoaderContext $context, $mtime, $errors ) X-Ref |
Send content type and last modified headers to the client. param: ResourceLoaderContext $context param: string $mtime TS_MW timestamp to use for last-modified param: bool $errors Whether there are commented-out errors in the response return: void |
tryRespondLastModified( ResourceLoaderContext $context, $mtime ) X-Ref |
Respond with 304 Last Modified if appropiate. If there's an If-Modified-Since header, respond with a 304 appropriately and clear out the output buffer. If the client cache is too old then do nothing. param: ResourceLoaderContext $context param: string $mtime The TS_MW timestamp to check the header against return: bool True if 304 header sent and output handled |
tryRespondFromFileCache(ResourceFileCache $fileCache, ResourceLoaderContext $context) X-Ref |
Send out code for a response from file cache if possible. param: ResourceFileCache $fileCache Cache object for this request URL param: ResourceLoaderContext $context Context in which to generate a response return: bool If this found a cache file and handled the response |
makeComment( $text ) X-Ref |
Generate a CSS or JS comment block. Only use this for public data, not error message details. param: string $text return: string |
formatException( $e ) X-Ref |
Handle exception display. param: Exception $e Exception to be shown to the user return: string Sanitized text that can be returned to the user |
makeModuleResponse( ResourceLoaderContext $context,array $modules, array $missing = array() X-Ref |
Generate code for a response. param: ResourceLoaderContext $context Context in which to generate a response param: array $modules List of module objects keyed by module name param: array $missing List of requested module names that are unregistered (optional) return: string Response data |
makeLoaderImplementScript( $name, $scripts, $styles, $messages ) X-Ref |
Return JS code that calls mw.loader.implement with given module properties. param: string $name Module name param: mixed $scripts List of URLs to JavaScript files or String of JavaScript code param: mixed $styles Array of CSS strings keyed by media type, or an array of lists of URLs param: mixed $messages List of messages associated with this module. May either be an return: string |
makeMessageSetScript( $messages ) X-Ref |
Returns JS code which, when called, will register a given list of messages. param: mixed $messages Either an associative array mapping message key to value, or a return: string |
makeCombinedStyles( array $stylePairs ) X-Ref |
Combines an associative array mapping media type to CSS into a single stylesheet with "@media" blocks. param: array $stylePairs Array keyed by media type containing (arrays of) CSS strings return: array |
makeLoaderStateScript( $name, $state = null ) X-Ref |
Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value. Has two calling conventions: - ResourceLoader::makeLoaderStateScript( $name, $state ): Set the state of a single module called $name to $state - ResourceLoader::makeLoaderStateScript( array( $name => $state, ... ) ): Set the state of modules with the given names to the given states param: string $name param: string $state return: string |
makeCustomLoaderScript( $name, $version, $dependencies,$group, $source, $script) X-Ref |
Returns JS code which calls the script given by $script. The script will be called with local variables name, version, dependencies and group, which will have values corresponding to $name, $version, $dependencies and $group as supplied. param: string $name Module name param: int $version Module version number as a timestamp param: array $dependencies List of module names on which this module depends param: string $group Group which the module is in. param: string $source Source of the module, or 'local' if not foreign. param: string $script JavaScript code return: string |
makeLoaderRegisterScript( $name, $version = null,$dependencies = null, $group = null, $source = null, $skip = null) X-Ref |
Returns JS code which calls mw.loader.register with the given parameters. Has three calling conventions: - ResourceLoader::makeLoaderRegisterScript( $name, $version, $dependencies, $group, $source, $skip ): Register a single module. - ResourceLoader::makeLoaderRegisterScript( array( $name1, $name2 ) ): Register modules with the given names. - ResourceLoader::makeLoaderRegisterScript( array( array( $name1, $version1, $dependencies1, $group1, $source1, $skip1 ), array( $name2, $version2, $dependencies1, $group2, $source2, $skip2 ), ... ) ): Registers modules with the given names and parameters. param: string $name Module name param: int $version Module version number as a timestamp param: array $dependencies List of module names on which this module depends param: string $group Group which the module is in param: string $source Source of the module, or 'local' if not foreign param: string $skip Script body of the skip function return: string |
makeLoaderSourcesScript( $id, $properties = null ) X-Ref |
Returns JS code which calls mw.loader.addSource() with the given parameters. Has two calling conventions: - ResourceLoader::makeLoaderSourcesScript( $id, $properties ): Register a single source - ResourceLoader::makeLoaderSourcesScript( array( $id1 => $loadUrl, $id2 => $loadUrl, ... ) ); Register sources with the given IDs and properties. param: string $id Source ID param: array $properties Source properties (see addSource()) return: string |
makeLoaderConditionalScript( $script ) X-Ref |
Returns JS code which runs given JS code if the client-side framework is present. param: string $script JavaScript code return: string |
makeConfigSetScript( array $configuration ) X-Ref |
Returns JS code which will set the MediaWiki configuration array to the given value. param: array $configuration List of configuration values keyed by variable name return: string |
makePackedModulesString( $modules ) X-Ref |
Convert an array of module names to a packed query string. For example, array( 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ) becomes 'foo.bar,baz|bar.baz,quux' param: array $modules List of module names (strings) return: string Packed query string |
inDebugMode() X-Ref |
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie, 3) $wg setting return: bool |
clearCache() X-Ref |
Reset static members used for caching. Global state and $wgRequest are evil, but we're using it right now and sometimes we need to be able to force ResourceLoader to re-evaluate the context because it has changed (e.g. in the test suite). |
createLoaderURL( $source, ResourceLoaderContext $context,$extraQuery = array() X-Ref |
Build a load.php URL param: string $source Name of the ResourceLoader source param: ResourceLoaderContext $context param: array $extraQuery return: string URL to load.php. May be protocol-relative (if $wgLoadScript is procol-relative) |
makeLoaderURL( $modules, $lang, $skin, $user = null,$version = null, $debug = false, $only = null, $printable = false,$handheld = false, $extraQuery = array() X-Ref |
Build a load.php URL param: array $modules Array of module names (strings) param: string $lang Language code param: string $skin Skin name param: string|null $user User name. If null, the &user= parameter is omitted param: string|null $version Versioning timestamp param: bool $debug Whether the request should be in debug mode param: string|null $only &only= parameter param: bool $printable Printable mode param: bool $handheld Handheld mode param: array $extraQuery Extra query parameters to add return: string URL to load.php. May be protocol-relative (if $wgLoadScript is procol-relative) |
createLoaderQuery( ResourceLoaderContext $context, $extraQuery = array() X-Ref |
Helper for createLoaderURL() param: ResourceLoaderContext $context param: array $extraQuery return: array |
makeLoaderQuery( $modules, $lang, $skin, $user = null,$version = null, $debug = false, $only = null, $printable = false,$handheld = false, $extraQuery = array() X-Ref |
Build a query array (array representation of query string) for load.php. Helper function for makeLoaderURL(). param: array $modules param: string $lang param: string $skin param: string $user param: string $version param: bool $debug param: string $only param: bool $printable param: bool $handheld param: array $extraQuery return: array |
isValidModuleName( $moduleName ) X-Ref |
Check a module name for validity. Module names may not contain pipes (|), commas (,) or exclamation marks (!) and can be at most 255 bytes. param: string $moduleName Module name to check return: bool Whether $moduleName is a valid module name |
getLessCompiler( Config $config ) X-Ref |
Returns LESS compiler set up for use with MediaWiki param: Config $config return: lessc |
getLessVars( Config $config ) X-Ref |
Get global LESS variables. param: Config $config return: array Map of variable names to string CSS values. |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |