X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderImage.php;h=2338c902bad92fe8bfba70fbeb6952e283b92495;hp=bf68fdda94c85328cdfdbd56d5ab26812f19363c;hb=59ebff658ce912c1b0e7ef8d8f9bfec5a4e17b39;hpb=f838e8c432704031cf4c56b848ac11ef83fbc676 diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index bf68fdda94..2338c902ba 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -54,15 +54,16 @@ class ResourceLoaderImage { $this->variants = $variants; // Expand shorthands: - // array( "en,de,fr" => "foo.svg" ) → array( "en" => "foo.svg", "de" => "foo.svg", "fr" => "foo.svg" ) + // 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 ] + $this->descriptor['lang'][$langList] ); - unset( $this->descriptor['lang'][ $langList ] ); + unset( $this->descriptor['lang'][$langList] ); } } } @@ -75,11 +76,15 @@ class ResourceLoaderImage { } ); $extensions = array_unique( $extensions ); if ( count( $extensions ) !== 1 ) { - throw new InvalidArgumentException( "File type for different image files of '$name' not the same" ); + throw new InvalidArgumentException( + "File type for different image files of '$name' not the same" + ); } $ext = $extensions[0]; if ( !isset( self::$fileTypes[$ext] ) ) { - throw new InvalidArgumentException( "Invalid file type for image files of '$name' (valid: svg, png, gif, jpg)" ); + throw new InvalidArgumentException( + "Invalid file type for image files of '$name' (valid: svg, png, gif, jpg)" + ); } $this->extension = $ext; } @@ -121,10 +126,10 @@ class ResourceLoaderImage { $desc = $this->descriptor; if ( is_string( $desc ) ) { return $this->basePath . '/' . $desc; - } elseif ( isset( $desc['lang'][ $context->getLanguage() ] ) ) { - return $this->basePath . '/' . $desc['lang'][ $context->getLanguage() ]; - } elseif ( isset( $desc[ $context->getDirection() ] ) ) { - return $this->basePath . '/' . $desc[ $context->getDirection() ]; + } elseif ( isset( $desc['lang'][$context->getLanguage()] ) ) { + return $this->basePath . '/' . $desc['lang'][$context->getLanguage()]; + } elseif ( isset( $desc[$context->getDirection()] ) ) { + return $this->basePath . '/' . $desc[$context->getDirection()]; } else { return $this->basePath . '/' . $desc['default']; }