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

Static Public Member Functions

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

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). More...
 
 loadFromDefinition ()
 Parse definition and external JSON data, if referenced. More...
 
- Protected Member Functions inherited from ResourceLoaderModule
 buildContent (ResourceLoaderContext $context)
 Bundle all resources attached to this module into an array. More...
 
 getFileDependencies (ResourceLoaderContext $context)
 Get the files this module depends on indirectly for a given skin. More...
 
 getLessVars (ResourceLoaderContext $context)
 Get module-specific LESS variables, if any. More...
 
 getLogger ()
 
 getMessageBlob (ResourceLoaderContext $context)
 Get the hash of the message blob. More...
 
 getPreloadLinks (ResourceLoaderContext $context)
 Get a list of resources that web browsers may preload. More...
 
 saveFileDependencies (ResourceLoaderContext $context, $localFileRefs)
 Set the files this module depends on indirectly for a given skin. More...
 
 validateScriptFile ( $fileName, $contents)
 Validate a given script file; if valid returns the original source. More...
 

Protected Attributes

 $defaultColor = null
 
 $definition = null
 
 $images = []
 
string $localBasePath = ''
 Local base path, see __construct() More...
 
 $origin = self::ORIGIN_CORE_SITEWIDE
 
 $prefix = null
 
 $selectorWithoutVariant = '.{prefix}-{name}'
 
 $selectorWithVariant = '.{prefix}-{name}-{variant}'
 
 $targets = [ 'desktop', 'mobile' ]
 
 $useDataURI = true
 
 $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

 getFileHashes (ResourceLoaderContext $context)
 Helper method for getDefinitionSummary. More...
 
 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. More...
 
static safeFilemtime ( $filePath)
 Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist. More...
 

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 | null$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
'en,de,ar'],
'variants' => [array of variant name strings, variants
available for this image],
],
...
],
...
],
]
Exceptions
InvalidArgumentException

Definition at line 106 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 | null$localBasePathPath to use if not provided in module definition. Defaults to $IP
Returns
string Local base path

Definition at line 454 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 386 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 408 of file ResourceLoaderImageModule.php.

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

◆ getFileHashes()

ResourceLoaderImageModule::getFileHashes ( ResourceLoaderContext  $context)
private

Helper method for getDefinitionSummary.

Parameters
ResourceLoaderContext$context
Returns
array

Definition at line 436 of file ResourceLoaderImageModule.php.

References $context, $image, ResourceLoaderModule\$name, as, 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 289 of file ResourceLoaderImageModule.php.

References ResourceLoaderModule\$config, $context, ResourceLoaderModule\$name, $skin, as, 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 230 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 241 of file ResourceLoaderImageModule.php.

References $context, $image, ResourceLoaderModule\$name, $options, $skin, as, 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 207 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 216 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 359 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 471 of file ResourceLoaderImageModule.php.

References ResourceLoaderModule\LOAD_STYLES.

◆ loadFromDefinition()

ResourceLoaderImageModule::loadFromDefinition ( )
protected

◆ supportsURLLoading()

ResourceLoaderImageModule::supportsURLLoading ( )
Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 398 of file ResourceLoaderImageModule.php.

Member Data Documentation

◆ $defaultColor

ResourceLoaderImageModule::$defaultColor = null
protected

Definition at line 42 of file ResourceLoaderImageModule.php.

◆ $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 45 of file ResourceLoaderImageModule.php.

Referenced by getPrefix(), and loadFromDefinition().

◆ $selectorWithoutVariant

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

Definition at line 46 of file ResourceLoaderImageModule.php.

Referenced by getSelectors(), and loadFromDefinition().

◆ $selectorWithVariant

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

Definition at line 47 of file ResourceLoaderImageModule.php.

Referenced by getSelectors(), and loadFromDefinition().

◆ $targets

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

Definition at line 48 of file ResourceLoaderImageModule.php.

◆ $useDataURI

ResourceLoaderImageModule::$useDataURI = true
protected

Definition at line 43 of file ResourceLoaderImageModule.php.

◆ $variants

ResourceLoaderImageModule::$variants = []
protected

Definition at line 44 of file ResourceLoaderImageModule.php.


The documentation for this class was generated from the following file:
file
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:91
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
is
This document provides an overview of the usage of PageUpdater and that is
Definition: pageupdater.txt:3
name
and how to run hooks for an and one after Each event has a name
Definition: hooks.txt:6
boolean
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 as and are nearing end of 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
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
string
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:175
list
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
or
or
Definition: COPYING.txt:140
code
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
Definition: hooks.txt:23
e
in this case you re responsible for computing and outputting the entire conflict i e
Definition: hooks.txt:1462
language
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
variables
controlled by the following variables
Definition: memcached.txt:78
and
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 and(2) offer you this license which gives you legal permission to copy
like
For a write use something like
Definition: database.txt:26
are
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are
Definition: contenthandler.txt:5
values
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:175
color
in the sidebar</td >< td > font color
Definition: All_system_messages.txt:425
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
type
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 as and are nearing end of 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:22