X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderOOUIImageModule.php;h=52aa39250d1c209b30ed8314f2bd436dead792ce;hb=515839fdad497581269311b74a01316601ff21a5;hp=6d76493a5fe3191303bb4f8983bf7456fc556a3b;hpb=e3e20c5bf7501b340e3ae002b3a23e4ecda861ed;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderOOUIImageModule.php b/includes/resourceloader/ResourceLoaderOOUIImageModule.php index 6d76493a5f..52aa39250d 100644 --- a/includes/resourceloader/ResourceLoaderOOUIImageModule.php +++ b/includes/resourceloader/ResourceLoaderOOUIImageModule.php @@ -30,25 +30,32 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { } // Core default themes - $themes = array( 'default' => 'mediawiki' ); + $themes = [ 'default' => 'mediawiki' ]; $themes += ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' ); $name = $this->definition['name']; $rootPath = $this->definition['rootPath']; - $definition = array(); + $definition = []; foreach ( $themes as $skin => $theme ) { // TODO Allow extensions to specify this path somehow $dataPath = $this->localBasePath . '/' . $rootPath . '/' . $theme . '/' . $name . '.json'; if ( file_exists( $dataPath ) ) { $data = json_decode( file_get_contents( $dataPath ), true ); - array_walk_recursive( $data['images'], function ( &$path ) use ( $rootPath, $theme ) { + $fixPath = function ( &$path ) use ( $rootPath, $theme ) { // TODO Allow extensions to specify this path somehow $path = $rootPath . '/' . $theme . '/' . $path; + }; + array_walk( $data['images'], function ( &$value ) use ( $fixPath ) { + if ( is_string( $value['file'] ) ) { + $fixPath( $value['file'] ); + } elseif ( is_array( $value['file'] ) ) { + array_walk_recursive( $value['file'], $fixPath ); + } } ); } else { - $data = array(); + $data = []; } foreach ( $data as $key => $value ) { @@ -62,7 +69,9 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { if ( !isset( $definition[$key] ) ) { $definition[$key] = $data[$key]; } elseif ( $definition[$key] !== $data[$key] ) { - throw new Exception( "Mismatched OOUI theme definitions are not supported: trying to load $key of $theme theme" ); + throw new Exception( + "Mismatched OOUI theme definitions are not supported: trying to load $key of $theme theme" + ); } break; }