Switch some HTMLForms in special pages to OOUI
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImageModule.php
index eb06a69..8de87f2 100644 (file)
@@ -86,9 +86,11 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         *         // List of image files and their options
         *         'images' => array(
         *             [theme name] => array(
-        *                 [file path string],
-        *                 [file path string] => array(
-        *                     'name' => [image name string, defaults to file name],
+        *                 [icon name] => array(
+        *                     '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],
         *                 ),
@@ -132,20 +134,30 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
 
                $prefix = isset( $options['prefix'] ) && $options['prefix'];
                $selector = isset( $options['selector'] ) && $options['selector'];
-               $selectorWithoutVariant = isset( $options['selectorWithoutVariant'] ) && $options['selectorWithoutVariant'];
-               $selectorWithVariant = isset( $options['selectorWithVariant'] ) && $options['selectorWithVariant'];
+               $selectorWithoutVariant = isset( $options['selectorWithoutVariant'] )
+                       && $options['selectorWithoutVariant'];
+               $selectorWithVariant = isset( $options['selectorWithVariant'] )
+                       && $options['selectorWithVariant'];
 
                if ( $selectorWithoutVariant && !$selectorWithVariant ) {
-                       throw new InvalidArgumentException( "Given 'selectorWithoutVariant' but no 'selectorWithVariant'." );
+                       throw new InvalidArgumentException(
+                               "Given 'selectorWithoutVariant' but no 'selectorWithVariant'."
+                       );
                }
                if ( $selectorWithVariant && !$selectorWithoutVariant ) {
-                       throw new InvalidArgumentException( "Given 'selectorWithVariant' but no 'selectorWithoutVariant'." );
+                       throw new InvalidArgumentException(
+                               "Given 'selectorWithVariant' but no 'selectorWithoutVariant'."
+                       );
                }
                if ( $selector && $selectorWithVariant ) {
-                       throw new InvalidArgumentException( "Incompatible 'selector' and 'selectorWithVariant'+'selectorWithoutVariant' given." );
+                       throw new InvalidArgumentException(
+                               "Incompatible 'selector' and 'selectorWithVariant'+'selectorWithoutVariant' given."
+                       );
                }
                if ( !$prefix && !$selector && !$selectorWithVariant ) {
-                       throw new InvalidArgumentException( "None of 'prefix', 'selector' or 'selectorWithVariant'+'selectorWithoutVariant' given." );
+                       throw new InvalidArgumentException(
+                               "None of 'prefix', 'selector' or 'selectorWithVariant'+'selectorWithoutVariant' given."
+                       );
                }
 
                foreach ( $options as $member => $option ) {
@@ -209,6 +221,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
        /**
         * Get a ResourceLoaderImage object for given image.
         * @param string $name Image name
+        * @param ResourceLoaderContext $context
         * @return ResourceLoaderImage|null
         */
        public function getImage( $name, ResourceLoaderContext $context ) {
@@ -219,6 +232,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
 
        /**
         * Get ResourceLoaderImage objects for all images.
+        * @param ResourceLoaderContext $context
         * @return ResourceLoaderImage[] Array keyed by image name
         */
        public function getImages( ResourceLoaderContext $context ) {
@@ -227,23 +241,23 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                        $this->loadFromDefinition();
                        $this->imageObjects = array();
                }
-               if ( !isset( $this->imageObjects[ $skin ] ) ) {
-                       $this->imageObjects[ $skin ] = array();
-                       if ( !isset( $this->images[ $skin ] ) ) {
-                               $this->images[ $skin ] = isset( $this->images[ 'default' ] ) ?
-                                       $this->images[ 'default' ] :
+               if ( !isset( $this->imageObjects[$skin] ) ) {
+                       $this->imageObjects[$skin] = array();
+                       if ( !isset( $this->images[$skin] ) ) {
+                               $this->images[$skin] = isset( $this->images['default'] ) ?
+                                       $this->images['default'] :
                                        array();
                        }
-                       foreach ( $this->images[ $skin ] as $name => $options ) {
+                       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(),
                                        $this->getGlobalVariants( $context )
                                );
-                               if ( isset( $this->variants[ $skin ] ) ) {
+                               if ( isset( $this->variants[$skin] ) ) {
                                        $variantConfig = array_intersect_key(
-                                               $this->variants[ $skin ],
+                                               $this->variants[$skin],
                                                array_fill_keys( $allowedVariants, true )
                                        );
                                } else {
@@ -257,16 +271,17 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                        $this->localBasePath,
                                        $variantConfig
                                );
-                               $this->imageObjects[ $skin ][ $image->getName() ] = $image;
+                               $this->imageObjects[$skin][$image->getName()] = $image;
                        }
                }
 
-               return $this->imageObjects[ $skin ];
+               return $this->imageObjects[$skin];
        }
 
        /**
         * Get list of variants in this module that are 'global', i.e., available
         * for every image regardless of image options.
+        * @param ResourceLoaderContext $context
         * @return string[]
         */
        public function getGlobalVariants( ResourceLoaderContext $context ) {
@@ -275,21 +290,21 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                        $this->loadFromDefinition();
                        $this->globalVariants = array();
                }
-               if ( !isset( $this->globalVariants[ $skin ] ) ) {
-                       $this->globalVariants[ $skin ] = array();
-                       if ( !isset( $this->variants[ $skin ] ) ) {
-                               $this->variants[ $skin ] = isset( $this->variants[ 'default' ] ) ?
-                                       $this->variants[ 'default' ] :
+               if ( !isset( $this->globalVariants[$skin] ) ) {
+                       $this->globalVariants[$skin] = array();
+                       if ( !isset( $this->variants[$skin] ) ) {
+                               $this->variants[$skin] = isset( $this->variants['default'] ) ?
+                                       $this->variants['default'] :
                                        array();
                        }
-                       foreach ( $this->variants[ $skin ] as $name => $config ) {
+                       foreach ( $this->variants[$skin] as $name => $config ) {
                                if ( isset( $config['global'] ) && $config['global'] ) {
-                                       $this->globalVariants[ $skin ][] = $name;
+                                       $this->globalVariants[$skin][] = $name;
                                }
                        }
                }
 
-               return $this->globalVariants[ $skin ];
+               return $this->globalVariants[$skin];
        }
 
        /**