Go to the documentation of this file.
198 global $IP, $wgScriptPath, $wgResourceBasePath;
203 $this->remoteBasePath = $wgResourceBasePath ===
null ? $wgScriptPath : $wgResourceBasePath;
206 if ( isset(
$options[
'remoteExtPath'] ) ) {
207 global $wgExtensionAssetsPath;
208 $this->remoteBasePath = $wgExtensionAssetsPath .
'/' .
$options[
'remoteExtPath'];
216 case 'loaderScripts':
218 $this->{$member} = (
array)$option;
221 case 'languageScripts':
224 if ( !is_array( $option ) ) {
226 "Invalid collated file path list error. " .
227 "'$option' given, array expected."
230 foreach ( $option
as $key =>
$value ) {
231 if ( !is_string( $key ) ) {
233 "Invalid collated file path list key error. " .
234 "'$key' given, string expected."
245 $option = array_values( array_unique( (
array)$option ) );
248 $this->{$member} = $option;
253 case 'localBasePath':
254 case 'remoteBasePath':
255 $this->{$member} = (string)$option;
260 $this->{$member} = (bool)$option;
305 if ( count( $this->loaderScripts ) == 0 ) {
323 $this->localFileRefs = array_unique( $this->localFileRefs );
328 $dbw->replace(
'module_deps',
330 'md_module' => $this->
getName(),
331 'md_skin' => $context->
getSkin(),
336 }
catch ( Exception
$e ) {
337 wfDebugLog(
'resourceloader', __METHOD__ .
": failed to update DB: $e" );
347 if ( $this->hasGeneratedStyles ) {
350 return parent::getStyleURLsForDebug( $context );
356 $urls[$mediaType] =
array();
420 if ( isset( $this->modifiedTime[$context->
getHash()] ) ) {
421 return $this->modifiedTime[$context->
getHash()];
434 self::tryForKey( $this->skinStyles, $context->
getSkin(),
'default' ),
438 foreach ( $skinFiles
as $styleFiles ) {
448 self::tryForKey( $this->skinScripts, $context->
getSkin(),
'default' ),
457 if ( count(
$files ) === 0 ) {
458 $this->modifiedTime[$context->
getHash()] = 1;
460 return $this->modifiedTime[$context->
getHash()];
464 $filesMtime = max( array_map(
array( __CLASS__,
'safeFilemtime' ),
$files ) );
467 $this->modifiedTime[$context->
getHash()] = max(
474 return $this->modifiedTime[$context->
getHash()];
484 'class' => get_class( $this ),
504 $summary[$member] = $this->{$member};
516 return "{$this->localBasePath}/$path";
524 return "{$this->remoteBasePath}/$path";
535 return preg_match(
'/\.less$/i',
$path ) ?
'less' :
'css';
548 $collatedFiles =
array();
550 if ( is_int( $key ) ) {
552 if ( !isset( $collatedFiles[$default] ) ) {
553 $collatedFiles[$default] =
array();
555 $collatedFiles[$default][] =
$value;
556 } elseif ( is_array(
$value ) ) {
558 $optionValue = isset(
$value[$option] ) ?
$value[$option] : $default;
559 if ( !isset( $collatedFiles[$optionValue] ) ) {
560 $collatedFiles[$optionValue] =
array();
562 $collatedFiles[$optionValue][] = $key;
565 return $collatedFiles;
578 if ( isset( $list[$key] ) && is_array( $list[$key] ) ) {
598 self::tryForKey( $this->languageScripts, $context->
getLanguage() ),
599 self::tryForKey( $this->skinScripts, $context->
getSkin(),
'default' )
605 return array_unique(
$files );
615 return array_merge_recursive(
616 self::collateFilePathListByOption( $this->styles,
'media',
'all' ),
617 self::collateFilePathListByOption(
618 self::tryForKey( $this->skinStyles, $context->
getSkin(),
'default' ),
632 if ( is_array(
$value ) ) {
650 global $wgResourceLoaderValidateStaticJS;
655 foreach ( array_unique(
$scripts )
as $fileName ) {
657 if ( !file_exists( $localPath ) ) {
658 throw new MWException( __METHOD__ .
": script file not found: \"$localPath\"" );
660 $contents = file_get_contents( $localPath );
661 if ( $wgResourceLoaderValidateStaticJS ) {
667 $js .= $contents .
"\n";
689 $uniqueFiles = array_unique(
$files );
690 $styleFiles =
array();
691 foreach ( $uniqueFiles
as $file ) {
694 $styles[$media] = implode(
"\n", $styleFiles );
712 if ( !file_exists( $localPath ) ) {
713 $msg = __METHOD__ .
": style file not found: \"$localPath\"";
720 $this->hasGeneratedStyles =
true;
722 $style = file_get_contents( $localPath );
728 $dirname = dirname(
$path );
729 if ( $dirname ==
'.' ) {
736 $this->localFileRefs = array_merge(
737 $this->localFileRefs,
741 $style,
$dir, $remoteDir,
true
751 return $context->getDirection() ===
'rtl';
812 throw new MWException(
'LESS compiler result has type ' . gettype(
$result ) .
'; array expected.' );
815 $this->localFileRefs += array_keys(
$result[
'files'] );
Object passed around to modules which contains information about the state of a specific loader reque...
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getModifiedTime(ResourceLoaderContext $context)
Get the last modified timestamp of this module.
$localBasePath
String: Local base path, see __construct()
__construct( $options=array(), $localBasePath=null, $remoteBasePath=null)
Constructs a new module from an options array.
$styles
Array: List of paths to CSS files to always include.
static remap( $source, $local, $remote, $embedData=true)
Remaps CSS URL paths and automatically embeds data URIs for CSS rules or url() values preceded by an ...
$raw
Boolean: Whether mw.loader.state() call should be omitted.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
getStyles(ResourceLoaderContext $context)
Gets all styles for a given context concatenated together.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
getDependencies()
Gets list of names of modules this module depends on.
getScriptURLsForDebug(ResourceLoaderContext $context)
wfProfileIn( $functionname)
Begin profiling of a function.
getFlip( $context)
Get whether CSS for this module should be flipped.
$dependencies
Array: List of modules this module depends on.
wfGetCache( $inputType)
Get a cache object.
getLoaderScript()
Gets loader script.
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
$scripts
Array: List of paths to JavaScript files to always include.
ResourceLoader module based on local JavaScript/CSS files.
$debugRaw
Boolean: Link to raw files in debug mode.
static getLocalFileReferences( $source, $path=null)
Gets a list of local file paths which are referenced in a CSS style sheet.
$position
String: Position on the page to load this module at.
wfMemcKey()
Get a cache key.
getGroup()
Gets the name of the group this module should be loaded in.
$localFileRefs
Array: Place where readStyleFile() tracks file dependencies.
getDefinitionMtime(ResourceLoaderContext $context)
Helper method for calculating when this module's definition summary was last changed.
getAllStyleFiles()
Returns all style files used by this module.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
readStyleFiles(array $styles, $flip)
Gets the contents of a list of CSS files.
getStyleURLsForDebug(ResourceLoaderContext $context)
$languageScripts
Array: List of JavaScript files to include when using a specific language.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
readStyleFile( $path, $flip)
Reads a style file.
$messages
Array: List of message keys used by this module.
when a variable name is used in a it is silently declared as a new masking the global
$loaderScripts
Array: List of paths to JavaScript files to include in the startup module.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
getTargets()
Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
static getLESSVars()
Get global LESS variables.
$hasGeneratedStyles
Boolean: Whether getStyleURLsForDebug should return raw file paths, or return load....
readScriptFiles(array $scripts)
Gets the contents of a list of JavaScript files.
$skinScripts
Array: List of JavaScript files to include when using a specific skin.
static collateFilePathListByOption(array $list, $option, $default)
Collates file paths by option (where provided).
validateScriptFile( $fileName, $contents)
Validate a given script file; if valid returns the original source.
static getLESSCacheKey( $fileName)
Generate a cache key for a LESS file.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
getMsgBlobMtime( $lang)
Get the last modification timestamp of the message blob for this module in a given language.
if(PHP_SAPI !='cli') $file
getScriptFiles(ResourceLoaderContext $context)
Gets a list of file paths for all scripts in this module, in order of propper execution.
static getLessCompiler()
Returns LESS compiler set up for use with MediaWiki.
getStyleSheetLang( $path)
Infer the stylesheet language from a stylesheet file path.
$modifiedTime
Array: Cache for mtime.
Abstraction for resource loader modules, with name registration and maxage functionality.
$remoteBasePath
String: Remote base path, see __construct()
if(count( $args)==0) $dir
compileLESSFile( $fileName)
Compile a LESS file into CSS.
static tryForKey(array $list, $key, $fallback=null)
Gets a list of element that match a key, optionally using a fallback key.
$skinStyles
Array: List of paths to CSS files to include when using specific skins.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
if(PHP_SAPI !='cli') $source
static transform( $css, $swapLtrRtlInURL=false, $swapLeftRightInURL=false)
Transform an LTR stylesheet to RTL.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
getMessages()
Gets list of message keys used by this module.
getStyleFiles(ResourceLoaderContext $context)
Gets a list of file paths for all styles in this module, in order of propper inclusion.
getFileDependencies( $skin)
Get the files this module depends on indirectly for a given skin.
getScript(ResourceLoaderContext $context)
Gets all scripts for a given context concatenated together.
$debugScripts
Array: List of paths to JavaScript files to include in debug mode.
getName()
Get this module's name.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
$group
String: Name of group to load this module in.