MediaWiki REL1_31
ResourceLoaderImageModule Class Reference

ResourceLoader module for generated and embedded images. More...

Inheritance diagram for ResourceLoaderImageModule:
Collaboration diagram for ResourceLoaderImageModule:

Public Member Functions

 __construct ( $options=[], $localBasePath=null)
 Constructs a new module from an options array.
 
 getDefinitionSummary (ResourceLoaderContext $context)
 Get the definition summary for this module.
 
 getGlobalVariants (ResourceLoaderContext $context)
 Get list of variants in this module that are 'global', i.e., available for every image regardless of image options.
 
 getImage ( $name, ResourceLoaderContext $context)
 Get a ResourceLoaderImage object for given image.
 
 getImages (ResourceLoaderContext $context)
 Get ResourceLoaderImage objects for all images.
 
 getPrefix ()
 Get CSS class prefix used by this module.
 
 getSelectors ()
 Get CSS selector templates used by this module.
 
 getStyles (ResourceLoaderContext $context)
 
 getType ()
 
 supportsURLLoading ()
 
- Public Member Functions inherited from ResourceLoaderModule
 enableModuleContentVersion ()
 Whether to generate version hash based on module content.
 
 getConfig ()
 
 getDependencies (ResourceLoaderContext $context=null)
 Get a list of modules this module depends on.
 
 getFlip ( $context)
 
 getGroup ()
 Get the group this module is in.
 
 getHeaders (ResourceLoaderContext $context)
 Get headers to send as part of a module web response.
 
 getMessages ()
 Get the messages needed for this module.
 
 getModifiedHash (ResourceLoaderContext $context)
 Helper method for providing a version hash to getVersionHash().
 
 getModifiedTime (ResourceLoaderContext $context)
 Get this module's last modification timestamp for a given context.
 
 getModuleContent (ResourceLoaderContext $context)
 Get an array of this module's resources.
 
 getName ()
 Get this module's name.
 
 getOrigin ()
 Get this module's origin.
 
 getScript (ResourceLoaderContext $context)
 Get all JS for this module for a given language and skin.
 
 getScriptURLsForDebug (ResourceLoaderContext $context)
 Get the URL or URLs to load for this module's JS in debug mode.
 
 getSkipFunction ()
 Get the skip function.
 
 getSource ()
 Get the origin of this module.
 
 getStyleURLsForDebug (ResourceLoaderContext $context)
 Get the URL or URLs to load for this module's CSS in debug mode.
 
 getTargets ()
 Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'].
 
 getTemplates ()
 Takes named templates by the module and returns an array mapping.
 
 getVersionHash (ResourceLoaderContext $context)
 Get a string identifying the current version of this module in a given context.
 
 isKnownEmpty (ResourceLoaderContext $context)
 Check whether this module is known to be empty.
 
 isRaw ()
 Whether this module's JS expects to work without the client-side ResourceLoader module.
 
 setConfig (Config $config)
 
 setFileDependencies (ResourceLoaderContext $context, $files)
 Set in-object cache for file dependencies.
 
 setLogger (LoggerInterface $logger)
 
 setMessageBlob ( $blob, $lang)
 Set in-object cache for message blobs.
 
 setName ( $name)
 Set this module's name.
 
 shouldEmbedModule (ResourceLoaderContext $context)
 Check whether this module should be embeded rather than linked.
 

Static Public Member Functions

static extractLocalBasePath ( $options, $localBasePath=null)
 Extract a local base path from module definition information.
 
- Static Public Member Functions inherited from ResourceLoaderModule
static expandRelativePaths (array $filePaths)
 Expand directories relative to $IP.
 
static getRelativePaths (array $filePaths)
 Make file paths relative to MediaWiki directory.
 

Protected Member Functions

 getCssDeclarations ( $primary, $fallback)
 SVG support using a transparent gradient to guarantee cross-browser compatibility (browsers able to understand gradient syntax support also SVG).
 
 getFileHashes (ResourceLoaderContext $context)
 Helper method for getDefinitionSummary.
 
 loadFromDefinition ()
 Parse definition and external JSON data, if referenced.
 
- Protected Member Functions inherited from ResourceLoaderModule
 buildContent (ResourceLoaderContext $context)
 Bundle all resources attached to this module into an array.
 
 getDeprecationInformation ()
 Get JS representing deprecation information for the current module if available.
 
 getFileDependencies (ResourceLoaderContext $context)
 Get the files this module depends on indirectly for a given skin.
 
 getLessVars (ResourceLoaderContext $context)
 Get module-specific LESS variables, if any.
 
 getLogger ()
 
 getMessageBlob (ResourceLoaderContext $context)
 Get the hash of the message blob.
 
 getPreloadLinks (ResourceLoaderContext $context)
 Get a list of resources that web browsers may preload.
 
 saveFileDependencies (ResourceLoaderContext $context, $localFileRefs)
 Set the files this module depends on indirectly for a given skin.
 
 validateScriptFile ( $fileName, $contents)
 Validate a given script file; if valid returns the original source.
 

Protected Attributes

 $definition = null
 
 $images = []
 
string $localBasePath = ''
 Local base path, see __construct()
 
 $origin = self::ORIGIN_CORE_SITEWIDE
 
 $prefix = null
 
 $selectorWithoutVariant = '.{prefix}-{name}'
 
 $selectorWithVariant = '.{prefix}-{name}-{variant}'
 
 $targets = [ 'desktop', 'mobile' ]
 
 $variants = []
 
- Protected Attributes inherited from ResourceLoaderModule
Config $config
 
 $contents = []
 
array bool $deprecated = false
 
 $fileDeps = []
 
LoggerInterface $logger
 
 $msgBlobs = []
 
 $name = null
 
 $origin = self::ORIGIN_CORE_SITEWIDE
 
 $targets = [ 'desktop' ]
 
 $versionHash = []
 

Private Member Functions

 getStyleDeclarations (ResourceLoaderContext $context, ResourceLoaderImage $image, $script, $variant=null)
 

Additional Inherited Members

- Public Attributes inherited from ResourceLoaderModule
const LOAD_GENERAL = 'general'
 
const LOAD_STYLES = 'styles'
 
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_SCRIPTS = 'scripts'
 
const TYPE_STYLES = 'styles'
 
- Static Protected Member Functions inherited from ResourceLoaderModule
static javaScriptParser ()
 
static safeFileHash ( $filePath)
 Compute a non-cryptographic string hash of a file's contents.
 
static safeFilemtime ( $filePath)
 Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist.
 

Detailed Description

ResourceLoader module for generated and embedded images.

Since
1.25

Definition at line 29 of file ResourceLoaderImageModule.php.

Constructor & Destructor Documentation

◆ __construct()

ResourceLoaderImageModule::__construct ( $options = [],
$localBasePath = null )

Constructs a new module from an options array.

Parameters
array$optionsList of options; if not given or empty, an empty module will be constructed
string$localBasePathBase path to prepend to all local paths in $options. Defaults to $IP

Below is a description for the $options array:

Construction options:
[
// Base path to prepend to all local paths in $options. Defaults to $IP
'localBasePath' => [base path],
// Path to JSON file that contains any of the settings below
'data' => [file path string]
// CSS class prefix to use in all style rules
'prefix' => [CSS class prefix],
// Alternatively: Format of CSS selector to use in all style rules
'selector' => [CSS selector template, variables: {prefix} {name} {variant}],
// Alternatively: When using variants
'selectorWithoutVariant' => [CSS selector template, variables: {prefix} {name}],
'selectorWithVariant' => [CSS selector template, variables: {prefix} {name} {variant}],
// List of variants that may be used for the image files
'variants' => [
// This level of nesting can be omitted if you use the same images for every skin
[skin name (or 'default')] => [
[variant name] => [
'color' => [color string, e.g. '#ffff00'],
'global' => [boolean, if true, this variant is available
for all images of this type],
],
...
],
...
],
// List of image files and their options
'images' => [
// This level of nesting can be omitted if you use the same images for every skin
[skin name (or 'default')] => [
[icon name] => [
'file' => [file path string or array whose values are file path strings
and whose keys are 'default', 'ltr', 'rtl', a single
language code like 'en', or a list of language codes like
'en,de,ar'],
'variants' => [array of variant name strings, variants
available for this image],
],
...
],
...
],
]
in the sidebar</td >< td > font color
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a skin(according to that user 's preference)
it sets a lot of them automatically from query strings
Definition design.txt:93
in this case you re responsible for computing and outputting the entire conflict i e
Definition hooks.txt:1421
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
Definition hooks.txt:179
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition hooks.txt:181
> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. '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 '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 '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 '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. '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 IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() '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 Sanitizer::validateEmail(), 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. '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) '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 '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:Array with elements of the form "language:title" in the order that they will be output. & $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. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. 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) name
Definition hooks.txt:1840
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a boolean(which is limited to accepting true, false, 0, 1, t, or f) *The default data type for all VARCHAR
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition postgres.txt:30
Exceptions
InvalidArgumentException

Definition at line 104 of file ResourceLoaderImageModule.php.

References $localBasePath, $options, definition, and extractLocalBasePath().

Member Function Documentation

◆ extractLocalBasePath()

static ResourceLoaderImageModule::extractLocalBasePath ( $options,
$localBasePath = null )
static

Extract a local base path from module definition information.

Parameters
array$optionsModule definition
string$localBasePathPath to use if not provided in module definition. Defaults to $IP
Returns
string Local base path

Definition at line 451 of file ResourceLoaderImageModule.php.

References $IP, $localBasePath, $options, and string.

Referenced by __construct().

◆ getCssDeclarations()

ResourceLoaderImageModule::getCssDeclarations ( $primary,
$fallback )
protected

SVG support using a transparent gradient to guarantee cross-browser compatibility (browsers able to understand gradient syntax support also SVG).

http://pauginer.tumblr.com/post/36614680636/invisible-gradient-technique

Keep synchronized with the .background-image-svg LESS mixin in /resources/src/mediawiki.less/mediawiki.mixins.less.

Parameters
string$primaryPrimary URI
string$fallbackFallback URI
Returns
string[] CSS declarations to use given URIs as background-image

Reimplemented in ResourceLoaderImageModuleTestable.

Definition at line 383 of file ResourceLoaderImageModule.php.

References $fallback.

Referenced by getStyleDeclarations().

◆ getDefinitionSummary()

ResourceLoaderImageModule::getDefinitionSummary ( ResourceLoaderContext $context)

Get the definition summary for this module.

Parameters
ResourceLoaderContext$context
Returns
array

Reimplemented from ResourceLoaderModule.

Definition at line 405 of file ResourceLoaderImageModule.php.

References $context, $options, getFileHashes(), and loadFromDefinition().

◆ getFileHashes()

ResourceLoaderImageModule::getFileHashes ( ResourceLoaderContext $context)
protected

Helper method for getDefinitionSummary.

Parameters
ResourceLoaderContext$context
Returns
array

Definition at line 433 of file ResourceLoaderImageModule.php.

References $context, $image, getImages(), and loadFromDefinition().

Referenced by getDefinitionSummary().

◆ getGlobalVariants()

ResourceLoaderImageModule::getGlobalVariants ( ResourceLoaderContext $context)

Get list of variants in this module that are 'global', i.e., available for every image regardless of image options.

Parameters
ResourceLoaderContext$context
Returns
string[]

Definition at line 284 of file ResourceLoaderImageModule.php.

References ResourceLoaderModule\$config, $context, ResourceLoaderModule\$name, $skin, and loadFromDefinition().

Referenced by getImages().

◆ getImage()

ResourceLoaderImageModule::getImage ( $name,
ResourceLoaderContext $context )

Get a ResourceLoaderImage object for given image.

Parameters
string$nameImage name
ResourceLoaderContext$context
Returns
ResourceLoaderImage|null

Definition at line 224 of file ResourceLoaderImageModule.php.

References $images, ResourceLoaderModule\$name, getImages(), and loadFromDefinition().

◆ getImages()

ResourceLoaderImageModule::getImages ( ResourceLoaderContext $context)

Get ResourceLoaderImage objects for all images.

Parameters
ResourceLoaderContext$context
Returns
ResourceLoaderImage[] Array keyed by image name

Definition at line 235 of file ResourceLoaderImageModule.php.

References $context, $image, $options, $skin, getGlobalVariants(), ResourceLoaderModule\getName(), and loadFromDefinition().

Referenced by getFileHashes(), getImage(), and getStyles().

◆ getPrefix()

ResourceLoaderImageModule::getPrefix ( )

Get CSS class prefix used by this module.

Returns
string

Definition at line 201 of file ResourceLoaderImageModule.php.

References $prefix, and loadFromDefinition().

Referenced by getStyles().

◆ getSelectors()

ResourceLoaderImageModule::getSelectors ( )

Get CSS selector templates used by this module.

Returns
string

Definition at line 210 of file ResourceLoaderImageModule.php.

References $selectorWithoutVariant, $selectorWithVariant, and loadFromDefinition().

Referenced by getStyles().

◆ getStyleDeclarations()

ResourceLoaderImageModule::getStyleDeclarations ( ResourceLoaderContext $context,
ResourceLoaderImage $image,
$script,
$variant = null )
private
Parameters
ResourceLoaderContext$context
ResourceLoaderImage$imageImage to get the style for
string$scriptURL to load.php
string | null$variantVariant to get the style for
Returns
string

Definition at line 356 of file ResourceLoaderImageModule.php.

References $context, $image, and getCssDeclarations().

Referenced by getStyles().

◆ getStyles()

ResourceLoaderImageModule::getStyles ( ResourceLoaderContext $context)

◆ getType()

ResourceLoaderImageModule::getType ( )
Returns
string

Reimplemented from ResourceLoaderModule.

Definition at line 468 of file ResourceLoaderImageModule.php.

References ResourceLoaderModule\LOAD_STYLES.

◆ loadFromDefinition()

ResourceLoaderImageModule::loadFromDefinition ( )
protected

◆ supportsURLLoading()

ResourceLoaderImageModule::supportsURLLoading ( )
Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 395 of file ResourceLoaderImageModule.php.

Member Data Documentation

◆ $definition

ResourceLoaderImageModule::$definition = null
protected

◆ $images

ResourceLoaderImageModule::$images = []
protected

Definition at line 41 of file ResourceLoaderImageModule.php.

Referenced by getImage().

◆ $localBasePath

string ResourceLoaderImageModule::$localBasePath = ''
protected

Local base path, see __construct()

Definition at line 37 of file ResourceLoaderImageModule.php.

Referenced by __construct(), and extractLocalBasePath().

◆ $origin

ResourceLoaderImageModule::$origin = self::ORIGIN_CORE_SITEWIDE
protected

Definition at line 39 of file ResourceLoaderImageModule.php.

◆ $prefix

ResourceLoaderImageModule::$prefix = null
protected

Definition at line 43 of file ResourceLoaderImageModule.php.

Referenced by getPrefix(), and loadFromDefinition().

◆ $selectorWithoutVariant

ResourceLoaderImageModule::$selectorWithoutVariant = '.{prefix}-{name}'
protected

Definition at line 44 of file ResourceLoaderImageModule.php.

Referenced by getSelectors(), and loadFromDefinition().

◆ $selectorWithVariant

ResourceLoaderImageModule::$selectorWithVariant = '.{prefix}-{name}-{variant}'
protected

Definition at line 45 of file ResourceLoaderImageModule.php.

Referenced by getSelectors(), and loadFromDefinition().

◆ $targets

ResourceLoaderImageModule::$targets = [ 'desktop', 'mobile' ]
protected

Definition at line 46 of file ResourceLoaderImageModule.php.

◆ $variants

ResourceLoaderImageModule::$variants = []
protected

Definition at line 42 of file ResourceLoaderImageModule.php.


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