Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImageModule.php
index 8fd94f7..3b3bdf7 100644 (file)
@@ -38,12 +38,12 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
 
        protected $origin = self::ORIGIN_CORE_SITEWIDE;
 
-       protected $images = array();
-       protected $variants = array();
+       protected $images = [];
+       protected $variants = [];
        protected $prefix = null;
        protected $selectorWithoutVariant = '.{prefix}-{name}';
        protected $selectorWithVariant = '.{prefix}-{name}-{variant}';
-       protected $targets = array( 'desktop', 'mobile' );
+       protected $targets = [ 'desktop', 'mobile' ];
 
        /** @var string Position on the page to load this module at */
        protected $position = 'bottom';
@@ -102,7 +102,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         * @endcode
         * @throws InvalidArgumentException
         */
-       public function __construct( $options = array(), $localBasePath = null ) {
+       public function __construct( $options = [], $localBasePath = null ) {
                $this->localBasePath = self::extractLocalBasePath( $options, $localBasePath );
 
                $this->definition = $options;
@@ -171,7 +171,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                        }
                                        if ( !isset( $option['default'] ) ) {
                                                // Backwards compatibility
-                                               $option = array( 'default' => $option );
+                                               $option = [ 'default' => $option ];
                                        }
                                        foreach ( $option as $skin => $data ) {
                                                if ( !is_array( $option ) ) {
@@ -211,10 +211,10 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         */
        public function getSelectors() {
                $this->loadFromDefinition();
-               return array(
+               return [
                        'selectorWithoutVariant' => $this->selectorWithoutVariant,
                        'selectorWithVariant' => $this->selectorWithVariant,
-               );
+               ];
        }
 
        /**
@@ -238,20 +238,20 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                $skin = $context->getSkin();
                if ( !isset( $this->imageObjects ) ) {
                        $this->loadFromDefinition();
-                       $this->imageObjects = array();
+                       $this->imageObjects = [];
                }
                if ( !isset( $this->imageObjects[$skin] ) ) {
-                       $this->imageObjects[$skin] = array();
+                       $this->imageObjects[$skin] = [];
                        if ( !isset( $this->images[$skin] ) ) {
                                $this->images[$skin] = isset( $this->images['default'] ) ?
                                        $this->images['default'] :
-                                       array();
+                                       [];
                        }
                        foreach ( $this->images[$skin] as $name => $options ) {
                                $fileDescriptor = is_string( $options ) ? $options : $options['file'];
 
                                $allowedVariants = array_merge(
-                                       is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : array(),
+                                       is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : [],
                                        $this->getGlobalVariants( $context )
                                );
                                if ( isset( $this->variants[$skin] ) ) {
@@ -260,7 +260,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                                array_fill_keys( $allowedVariants, true )
                                        );
                                } else {
-                                       $variantConfig = array();
+                                       $variantConfig = [];
                                }
 
                                $image = new ResourceLoaderImage(
@@ -287,14 +287,14 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                $skin = $context->getSkin();
                if ( !isset( $this->globalVariants ) ) {
                        $this->loadFromDefinition();
-                       $this->globalVariants = array();
+                       $this->globalVariants = [];
                }
                if ( !isset( $this->globalVariants[$skin] ) ) {
-                       $this->globalVariants[$skin] = array();
+                       $this->globalVariants[$skin] = [];
                        if ( !isset( $this->variants[$skin] ) ) {
                                $this->variants[$skin] = isset( $this->variants['default'] ) ?
                                        $this->variants['default'] :
-                                       array();
+                                       [];
                        }
                        foreach ( $this->variants[$skin] as $name => $config ) {
                                if ( isset( $config['global'] ) && $config['global'] ) {
@@ -314,7 +314,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                $this->loadFromDefinition();
 
                // Build CSS rules
-               $rules = array();
+               $rules = [];
                $script = $context->getResourceLoader()->getLoadScript( $this->getSource() );
                $selectors = $this->getSelectors();
 
@@ -326,11 +326,11 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                        $declarations = implode( "\n\t", $declarations );
                        $selector = strtr(
                                $selectors['selectorWithoutVariant'],
-                               array(
+                               [
                                        '{prefix}' => $this->getPrefix(),
                                        '{name}' => $name,
                                        '{variant}' => '',
-                               )
+                               ]
                        );
                        $rules[] = "$selector {\n\t$declarations\n}";
 
@@ -342,18 +342,18 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                $declarations = implode( "\n\t", $declarations );
                                $selector = strtr(
                                        $selectors['selectorWithVariant'],
-                                       array(
+                                       [
                                                '{prefix}' => $this->getPrefix(),
                                                '{name}' => $name,
                                                '{variant}' => $variant,
-                                       )
+                                       ]
                                );
                                $rules[] = "$selector {\n\t$declarations\n}";
                        }
                }
 
                $style = implode( "\n", $rules );
-               return array( 'all' => $style );
+               return [ 'all' => $style ];
        }
 
        /**
@@ -369,12 +369,12 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         * @return string[] CSS declarations to use given URIs as background-image
         */
        protected function getCssDeclarations( $primary, $fallback ) {
-               return array(
+               return [
                        "background-image: url($fallback);",
-                       "background-image: -webkit-linear-gradient(transparent, transparent), url($primary);",
                        "background-image: linear-gradient(transparent, transparent), url($primary);",
+                       // Do not serve SVG to Opera 12, bad rendering with border-radius or background-size (T87504)
                        "background-image: -o-linear-gradient(transparent, transparent), url($fallback);",
-               );
+               ];
        }
 
        /**
@@ -393,14 +393,14 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
        public function getDefinitionSummary( ResourceLoaderContext $context ) {
                $this->loadFromDefinition();
                $summary = parent::getDefinitionSummary( $context );
-               foreach ( array(
+               foreach ( [
                        'localBasePath',
                        'images',
                        'variants',
                        'prefix',
                        'selectorWithoutVariant',
                        'selectorWithVariant',
-               ) as $member ) {
+               ] as $member ) {
                        $summary[$member] = $this->{$member};
                };
                return $summary;
@@ -415,13 +415,13 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         */
        public function getModifiedTime( ResourceLoaderContext $context ) {
                $this->loadFromDefinition();
-               $files = array();
+               $files = [];
                foreach ( $this->getImages( $context ) as $name => $image ) {
                        $files[] = $image->getPath( $context );
                }
 
                $files = array_values( array_unique( $files ) );
-               $filesMtime = max( array_map( array( __CLASS__, 'safeFilemtime' ), $files ) );
+               $filesMtime = max( array_map( [ __CLASS__, 'safeFilemtime' ], $files ) );
 
                return $filesMtime;
        }