124 $dataPath = $this->localBasePath .
'/' .
$options[
'data'];
125 $data = json_decode( file_get_contents( $dataPath ),
true );
139 &&
$options[
'selectorWithoutVariant'];
144 throw new InvalidArgumentException(
145 "Given 'selectorWithoutVariant' but no 'selectorWithVariant'."
149 throw new InvalidArgumentException(
150 "Given 'selectorWithVariant' but no 'selectorWithoutVariant'."
154 throw new InvalidArgumentException(
155 "Incompatible 'selector' and 'selectorWithVariant'+'selectorWithoutVariant' given."
159 throw new InvalidArgumentException(
160 "None of 'prefix', 'selector' or 'selectorWithVariant'+'selectorWithoutVariant' given."
164 foreach (
$options as $member => $option ) {
168 if ( !is_array( $option ) ) {
169 throw new InvalidArgumentException(
170 "Invalid list error. '$option' given, array expected."
173 if ( !isset( $option[
'default'] ) ) {
175 $option = [
'default' => $option ];
177 foreach ( $option as $skin => $data ) {
178 if ( !is_array( $option ) ) {
179 throw new InvalidArgumentException(
180 "Invalid list error. '$option' given, array expected."
184 $this->{$member} = $option;
188 $this->{$member} = (bool)$option;
192 case 'selectorWithoutVariant':
193 case 'selectorWithVariant':
194 $this->{$member} = (
string)$option;
198 $this->selectorWithoutVariant = $this->selectorWithVariant = (
string)$option;
243 if ( !isset( $this->imageObjects ) ) {
245 $this->imageObjects = [];
247 if ( !isset( $this->imageObjects[$skin] ) ) {
248 $this->imageObjects[
$skin] = [];
249 if ( !isset( $this->images[$skin] ) ) {
250 $this->images[
$skin] = $this->images[
'default'] ?? [];
252 foreach ( $this->images[$skin] as $name =>
$options ) {
255 $allowedVariants = array_merge(
259 if ( isset( $this->variants[$skin] ) ) {
260 $variantConfig = array_intersect_key(
261 $this->variants[$skin],
262 array_fill_keys( $allowedVariants,
true )
272 $this->localBasePath,
280 return $this->imageObjects[
$skin];
291 if ( !isset( $this->globalVariants ) ) {
293 $this->globalVariants = [];
295 if ( !isset( $this->globalVariants[$skin] ) ) {
296 $this->globalVariants[
$skin] = [];
297 if ( !isset( $this->variants[$skin] ) ) {
298 $this->variants[
$skin] = $this->variants[
'default'] ?? [];
300 foreach ( $this->variants[$skin] as $name =>
$config ) {
307 return $this->globalVariants[
$skin];
325 $selectors[
'selectorWithoutVariant'],
332 $rules[] =
"$selector {\n\t$declarations\n}";
334 foreach (
$image->getVariants() as $variant ) {
337 $selectors[
'selectorWithVariant'],
341 '{variant}' => $variant,
344 $rules[] =
"$selector {\n\t$declarations\n}";
348 $style = implode(
"\n", $rules );
349 return [
'all' => $style ];
365 $imageDataUri = $this->useDataURI ?
$image->getDataUri(
$context, $variant,
'original' ) :
false;
366 $primaryUrl = $imageDataUri ?:
$image->getUrl(
$context, $script, $variant,
'original' );
371 return implode(
"\n\t", $declarations );
387 $primaryUrl = CSSMin::buildUrlValue( $primary );
388 $fallbackUrl = CSSMin::buildUrlValue(
$fallback );
390 "background-image: $fallbackUrl;",
391 "background-image: linear-gradient(transparent, transparent), $primaryUrl;",
410 $summary = parent::getDefinitionSummary(
$context );
418 'selectorWithoutVariant',
419 'selectorWithVariant',
421 $options[$member] = $this->{$member};
442 $files = array_values( array_unique( $files ) );
443 return array_map( [ __CLASS__,
'safeFileHash' ], $files );
461 if ( array_key_exists(
'localBasePath',
$options ) ) {
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this definition
Object passed around to modules which contains information about the state of a specific loader reque...
ResourceLoader module for generated and embedded images.
getImage( $name, ResourceLoaderContext $context)
Get a ResourceLoaderImage object for given image.
loadFromDefinition()
Parse definition and external JSON data, if referenced.
getStyles(ResourceLoaderContext $context)
string $localBasePath
Local base path, see __construct()
__construct( $options=[], $localBasePath=null)
Constructs a new module from an options array.
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
static extractLocalBasePath( $options, $localBasePath=null)
Extract a local base path from module definition information.
getSelectors()
Get CSS selector templates used by this module.
getCssDeclarations( $primary, $fallback)
SVG support using a transparent gradient to guarantee cross-browser compatibility (browsers able to u...
getFileHashes(ResourceLoaderContext $context)
Helper method for getDefinitionSummary.
getPrefix()
Get CSS class prefix used by this module.
getStyleDeclarations(ResourceLoaderContext $context, ResourceLoaderImage $image, $script, $variant=null)
getGlobalVariants(ResourceLoaderContext $context)
Get list of variants in this module that are 'global', i.e., available for every image regardless of ...
getImages(ResourceLoaderContext $context)
Get ResourceLoaderImage objects for all images.
Class encapsulating an image used in a ResourceLoaderImageModule.
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
const ORIGIN_CORE_SITEWIDE
getSource()
Get the source of this module.
getName()
Get this module's name.
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin