X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderOOUIImageModule.php;h=ee87d8d8e892f217112cfc047e40a495780473b0;hp=14e5c2691e91fb5e4db98f2f3cfd1534d1499a73;hb=6c9a2923fe1ee3a65cb027be5e781772f2b12fbd;hpb=cac0d75f3624529222b9dcd1a1283b9f2b93eceb diff --git a/includes/resourceloader/ResourceLoaderOOUIImageModule.php b/includes/resourceloader/ResourceLoaderOOUIImageModule.php index 14e5c2691e..ee87d8d8e8 100644 --- a/includes/resourceloader/ResourceLoaderOOUIImageModule.php +++ b/includes/resourceloader/ResourceLoaderOOUIImageModule.php @@ -24,24 +24,31 @@ * @since 1.26 */ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { + use ResourceLoaderOOUIModule; + protected function loadFromDefinition() { if ( $this->definition === null ) { // Do nothing if definition was already processed return; } - // Core default themes - $themes = [ 'default' => 'mediawiki' ]; - $themes += ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' ); + $themes = self::getSkinThemeMap(); - $name = $this->definition['name']; - $rootPath = $this->definition['rootPath']; + // For backwards-compatibility, allow missing 'themeImages' + $module = isset( $this->definition['themeImages'] ) ? $this->definition['themeImages'] : ''; $definition = []; foreach ( $themes as $skin => $theme ) { // Find the path to the JSON file which contains the actual image definitions for this theme - // TODO Allow extensions to specify this path somehow - $dataPath = $rootPath . '/' . strtolower( $theme ) . '/' . $name . '.json'; + if ( $module ) { + $dataPath = $this->getThemeImagesPath( $theme, $module ); + } else { + // Backwards-compatibility for things that probably shouldn't have used this class... + $dataPath = + $this->definition['rootPath'] . '/' . + strtolower( $theme ) . '/' . + $this->definition['name'] . '.json'; + } $localDataPath = $this->localBasePath . '/' . $dataPath; // If there's no file for this module of this theme, that's okay, it will just use the defaults @@ -79,7 +86,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { } elseif ( $definition[$key] !== $data[$key] ) { throw new Exception( "Mismatched OOUI theme images definition: " . - "key '$key' of theme '$theme' " . + "key '$key' of theme '$theme' for module '$module' " . "does not match other themes" ); } @@ -88,6 +95,16 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule { } } + // Extra selectors to allow using the same icons for old-style MediaWiki UI code + if ( substr( $module, 0, 5 ) === 'icons' ) { + $definition['selectorWithoutVariant'] = '.oo-ui-icon-{name}, .mw-ui-icon-{name}:before'; + $definition['selectorWithVariant'] = ' + .oo-ui-image-{variant}.oo-ui-icon-{name}, .mw-ui-icon-{name}-{variant}:before, + /* Hack for Flow, see T110051 */ + .mw-ui-hovericon:hover .mw-ui-icon-{name}-{variant}-hover:before, + .mw-ui-hovericon.mw-ui-icon-{name}-{variant}-hover:hover:before'; + } + // Fields from module definition silently override keys from JSON files $this->definition += $definition;