resourceloader: Using file cache, prepend warnings after creating response
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImage.php
index d14b7a8..bf68fdd 100644 (file)
@@ -53,6 +53,20 @@ class ResourceLoaderImage {
                $this->basePath = $basePath;
                $this->variants = $variants;
 
+               // Expand shorthands:
+               // array( "en,de,fr" => "foo.svg" ) → array( "en" => "foo.svg", "de" => "foo.svg", "fr" => "foo.svg" )
+               if ( is_array( $this->descriptor ) && isset( $this->descriptor['lang'] ) ) {
+                       foreach ( array_keys( $this->descriptor['lang'] ) as $langList ) {
+                               if ( strpos( $langList, ',' ) !== false ) {
+                                       $this->descriptor['lang'] += array_fill_keys(
+                                               explode( ',', $langList ),
+                                               $this->descriptor['lang'][ $langList ]
+                                       );
+                                       unset( $this->descriptor['lang'][ $langList ] );
+                               }
+                       }
+               }
+
                // Ensure that all files have common extension.
                $extensions = array();
                $descriptor = (array)$descriptor;
@@ -103,7 +117,7 @@ class ResourceLoaderImage {
         * @param ResourceLoaderContext $context Any context
         * @return string
         */
-       protected function getPath( ResourceLoaderContext $context ) {
+       public function getPath( ResourceLoaderContext $context ) {
                $desc = $this->descriptor;
                if ( is_string( $desc ) ) {
                        return $this->basePath . '/' . $desc;