MediaWiki  1.23.6
ResourceLoaderWikiModule Class Reference

Abstraction for resource loader modules which pull from wiki pages. More...

Inheritance diagram for ResourceLoaderWikiModule:
Collaboration diagram for ResourceLoaderWikiModule:

Public Member Functions

 getDefinitionSummary (ResourceLoaderContext $context)
 Get the definition summary for this module. More...
 
 getModifiedTime (ResourceLoaderContext $context)
 
 getScript (ResourceLoaderContext $context)
 
 getStyles (ResourceLoaderContext $context)
 
 isKnownEmpty (ResourceLoaderContext $context)
 
- Public Member Functions inherited from ResourceLoaderModule
 getDefinitionMtime (ResourceLoaderContext $context)
 Helper method for calculating when this module's definition summary was last changed. More...
 
 getDependencies ()
 Get a list of modules this module depends on. More...
 
 getFileDependencies ( $skin)
 Get the files this module depends on indirectly for a given skin. More...
 
 getFlip ( $context)
 
 getGroup ()
 Get the group this module is in. More...
 
 getHashMtime (ResourceLoaderContext $context)
 Helper method for calculating when the module's hash (if it has one) changed. More...
 
 getLoaderScript ()
 Get the loader JS for this module, if set. More...
 
 getMessages ()
 Get the messages needed for this module. 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...
 
 getPosition ()
 Where on the HTML page should this module's JS be loaded? More...
 
 getScriptURLsForDebug (ResourceLoaderContext $context)
 Get the URL or URLs to load for this module's JS in debug mode. More...
 
 getSource ()
 Get the origin of this module. More...
 
 getStyleURLsForDebug (ResourceLoaderContext $context)
 Get the URL or URLs to load for this module's CSS in debug mode. More...
 
 getTargets ()
 Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile']. More...
 
 isRaw ()
 Whether this module's JS expects to work without the client-side ResourceLoader module. 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...
 
 supportsURLLoading ()
 Whether this module supports URL loading. More...
 

Protected Member Functions

 getContent ( $title)
 
 getDB ()
 Get the Database object used in getTitleMTimes(). More...
 
 getPages (ResourceLoaderContext $context)
 Subclasses should return an associative array of resources in the module. More...
 
 getTitleMtimes (ResourceLoaderContext $context)
 Get the modification times of all titles that would be loaded for a given context. More...
 
- Protected Member Functions inherited from ResourceLoaderModule
 validateScriptFile ( $fileName, $contents)
 Validate a given script file; if valid returns the original source. More...
 

Protected Attributes

 $origin = self::ORIGIN_USER_SITEWIDE
 
 $titleMtimes = array()
 
- 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'
 
- 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...
 

Detailed Description

Abstraction for resource loader modules which pull from wiki pages.

This can only be used for wiki pages in the MediaWiki and User namespaces, because of its dependence on the functionality of Title::isCssJsSubpage.

Definition at line 32 of file ResourceLoaderWikiModule.php.

Member Function Documentation

◆ getContent()

ResourceLoaderWikiModule::getContent (   $title)
protected
Parameters
$titleTitle
Returns
null|string

Definition at line 83 of file ResourceLoaderWikiModule.php.

References $title, CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT, Revision\newFromTitle(), Revision\RAW, IDBAccessObject\READ_NORMAL, and wfDebugLog().

Referenced by getScript(), and getStyles().

◆ getDB()

ResourceLoaderWikiModule::getDB ( )
protected

Get the Database object used in getTitleMTimes().

Defaults to the local slave DB but subclasses may want to override this to return a remote DB object, or to return null if getTitleMTimes() shouldn't access the DB at all.

NOTE: This ONLY works for getTitleMTimes() and getModifiedTime(), NOT FOR ANYTHING ELSE. In particular, it doesn't work for getting the content of JS and CSS pages. That functionality will use the local DB irrespective of the return value of this method.

Returns
DatabaseBase|null

Definition at line 75 of file ResourceLoaderWikiModule.php.

References DB_SLAVE, and wfGetDB().

Referenced by getTitleMtimes().

◆ getDefinitionSummary()

ResourceLoaderWikiModule::getDefinitionSummary ( ResourceLoaderContext  $context)

Get the definition summary for this module.

Returns
Array

Reimplemented from ResourceLoaderModule.

Definition at line 196 of file ResourceLoaderWikiModule.php.

References array(), and getPages().

◆ getModifiedTime()

ResourceLoaderWikiModule::getModifiedTime ( ResourceLoaderContext  $context)

◆ getPages()

ResourceLoaderWikiModule::getPages ( ResourceLoaderContext  $context)
abstractprotected

Subclasses should return an associative array of resources in the module.

Keys should be the title of a page in the MediaWiki or User namespace.

Values should be a nested array of options. The supported keys are 'type' and (CSS only) 'media'.

For scripts, 'type' should be 'script'.

For stylesheets, 'type' should be 'style'. There is an optional media key, the value of which can be the medium ('screen', 'print', etc.) of the stylesheet.

Parameters
$contextResourceLoaderContext
Returns
array

Reimplemented in ResourceLoaderNoscriptModule, ResourceLoaderUserModule, ResourceLoaderSiteModule, ResourceLoaderUserGroupsModule, and ResourceLoaderFilePageModule.

Referenced by getDefinitionSummary(), getScript(), getStyles(), and getTitleMtimes().

◆ getScript()

ResourceLoaderWikiModule::getScript ( ResourceLoaderContext  $context)
Parameters
$contextResourceLoaderContext
Returns
string

Reimplemented from ResourceLoaderModule.

Definition at line 115 of file ResourceLoaderWikiModule.php.

References $options, $title, as, getContent(), getPages(), Title\newFromText(), and ResourceLoaderModule\validateScriptFile().

◆ getStyles()

ResourceLoaderWikiModule::getStyles ( ResourceLoaderContext  $context)

◆ getTitleMtimes()

ResourceLoaderWikiModule::getTitleMtimes ( ResourceLoaderContext  $context)
protected

Get the modification times of all titles that would be loaded for a given context.

Parameters
$contextResourceLoaderContext: Context object
Returns
array( prefixed DB key => UNIX timestamp ), nonexistent titles are dropped

Definition at line 217 of file ResourceLoaderWikiModule.php.

References $batch, $dbr, $hash, $options, $res, $title, array(), as, getDB(), ResourceLoaderContext\getHash(), getPages(), Title\makeTitle(), Title\newFromText(), TS_UNIX, and wfTimestamp().

Referenced by getModifiedTime(), and isKnownEmpty().

◆ isKnownEmpty()

ResourceLoaderWikiModule::isKnownEmpty ( ResourceLoaderContext  $context)
Parameters
$contextResourceLoaderContext
Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 207 of file ResourceLoaderWikiModule.php.

References getTitleMtimes().

Member Data Documentation

◆ $origin

ResourceLoaderWikiModule::$origin = self::ORIGIN_USER_SITEWIDE
protected

Definition at line 37 of file ResourceLoaderWikiModule.php.

◆ $titleMtimes

ResourceLoaderWikiModule::$titleMtimes = array()
protected

Definition at line 40 of file ResourceLoaderWikiModule.php.


The documentation for this class was generated from the following file: