35 if ( $this->definition ===
null ) {
43 $module = $this->definition[
'themeImages'] ??
'';
46 foreach ( $themes as $skin => $theme ) {
55 foreach ( $data as $key => $value ) {
69 "Mismatched OOUI theme images definition: " .
70 "key '$key' of theme '$theme' for module '$module' " .
71 "does not match other themes"
80 if ( substr( $module, 0, 5 ) ===
'icons' ) {
81 $definition[
'selectorWithoutVariant'] =
'.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
82 $definition[
'selectorWithVariant'] =
'.oo-ui-image-{variant}.oo-ui-icon-{name}, ' .
83 '.mw-ui-icon-{name}-{variant}:before';
89 parent::loadFromDefinition();
111 $this->definition[
'rootPath'] .
'/' .
112 strtolower( $theme ) .
'/' .
113 $this->definition[
'name'] .
'.json';
129 if ( !file_exists( $localDataPath ) ) {
133 $data = json_decode( file_get_contents( $localDataPath ),
true );
137 $fixPath =
static function ( &
$path ) use ( $dataPath ) {
138 if ( $dataPath instanceof
FilePath ) {
140 dirname( $dataPath->getPath() ) .
'/' .
$path,
141 $dataPath->getLocalBasePath(),
142 $dataPath->getRemoteBasePath()
149 array_walk( $data[
'images'],
static function ( &$value ) use ( $fixPath ) {
150 if ( is_string( $value[
'file'] ) ) {
151 $fixPath( $value[
'file'] );
152 } elseif ( is_array( $value[
'file'] ) ) {
153 array_walk_recursive( $value[
'file'], $fixPath );
162class_alias( OOUIImageModule::class,
'ResourceLoaderOOUIImageModule' );
trait OOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.