MediaWiki REL1_33
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.
 
 getDeprecationInformation ()
 Get JS representing deprecation information for the current module if available.
 
 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.
 
 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 source 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).
 
 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.
 
 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

string null $defaultColor = null
 
array null $definition = null
 
array null $globalVariants = null
 
ResourceLoaderImage[] null $imageObjects = null
 
array $images = []
 
string $localBasePath = ''
 Local base path, see __construct()
 
 $origin = self::ORIGIN_CORE_SITEWIDE
 
string null $prefix = null
 
 $selectorWithoutVariant = '.{prefix}-{name}'
 
 $selectorWithVariant = '.{prefix}-{name}-{variant}'
 
 $targets = [ 'desktop', 'mobile' ]
 
 $useDataURI = true
 
array $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.
 
 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 | 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
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],
],
...
],
...
],
]
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
in the sidebar</td >< td > font color
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
For a write use something like
Definition database.txt:28
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
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
database rows
Definition globals.txt:10
in this case you re responsible for computing and outputting the entire conflict i e
Definition hooks.txt:1423
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
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 local administrators to define code that will be run at certain points in the mainline code
Definition hooks.txt:28
and how to run hooks for an and one after Each event has a name
Definition hooks.txt:12
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:106
controlled by the following variables
Definition memcached.txt:78
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))
This document provides an overview of the usage of PageUpdater and that is
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 115 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 463 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 395 of file ResourceLoaderImageModule.php.

References $fallback, and CSSMin\buildUrlValue().

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 417 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 445 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 298 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 239 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 250 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 216 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 225 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 368 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 480 of file ResourceLoaderImageModule.php.

References ResourceLoaderModule\LOAD_STYLES.

◆ loadFromDefinition()

ResourceLoaderImageModule::loadFromDefinition ( )
protected

◆ supportsURLLoading()

ResourceLoaderImageModule::supportsURLLoading ( )
Returns
bool

Reimplemented from ResourceLoaderModule.

Definition at line 407 of file ResourceLoaderImageModule.php.

Member Data Documentation

◆ $defaultColor

string null ResourceLoaderImageModule::$defaultColor = null
protected

Definition at line 47 of file ResourceLoaderImageModule.php.

◆ $definition

array null ResourceLoaderImageModule::$definition = null
protected

◆ $globalVariants

array null ResourceLoaderImageModule::$globalVariants = null
protected

Definition at line 50 of file ResourceLoaderImageModule.php.

◆ $imageObjects

ResourceLoaderImage [] null ResourceLoaderImageModule::$imageObjects = null
protected

Definition at line 43 of file ResourceLoaderImageModule.php.

◆ $images

array ResourceLoaderImageModule::$images = []
protected

Definition at line 45 of file ResourceLoaderImageModule.php.

Referenced by getImage().

◆ $localBasePath

string ResourceLoaderImageModule::$localBasePath = ''
protected

Local base path, see __construct()

Definition at line 38 of file ResourceLoaderImageModule.php.

Referenced by __construct(), and extractLocalBasePath().

◆ $origin

ResourceLoaderImageModule::$origin = self::ORIGIN_CORE_SITEWIDE
protected

Definition at line 40 of file ResourceLoaderImageModule.php.

◆ $prefix

string null ResourceLoaderImageModule::$prefix = null
protected

Definition at line 54 of file ResourceLoaderImageModule.php.

Referenced by getPrefix(), and loadFromDefinition().

◆ $selectorWithoutVariant

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

Definition at line 55 of file ResourceLoaderImageModule.php.

Referenced by getSelectors(), and loadFromDefinition().

◆ $selectorWithVariant

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

Definition at line 56 of file ResourceLoaderImageModule.php.

Referenced by getSelectors(), and loadFromDefinition().

◆ $targets

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

Definition at line 57 of file ResourceLoaderImageModule.php.

◆ $useDataURI

ResourceLoaderImageModule::$useDataURI = true
protected

Definition at line 48 of file ResourceLoaderImageModule.php.

◆ $variants

array ResourceLoaderImageModule::$variants = []
protected

Definition at line 52 of file ResourceLoaderImageModule.php.


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