31 if ( $this->definition ===
null ) {
39 $module = $this->definition[
'themeImages'] ??
'';
42 foreach ( $themes as $skin => $theme ) {
51 foreach ( $data as $key => $value ) {
65 "Mismatched OOUI theme images definition: " .
66 "key '$key' of theme '$theme' for module '$module' " .
67 "does not match other themes"
76 if ( substr( $module, 0, 5 ) ===
'icons' ) {
77 $definition[
'selectorWithoutVariant'] =
'.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
78 $definition[
'selectorWithVariant'] =
'.oo-ui-image-{variant}.oo-ui-icon-{name}, ' .
79 '.mw-ui-icon-{name}-{variant}:before';
85 parent::loadFromDefinition();
107 $this->definition[
'rootPath'] .
'/' .
108 strtolower( $theme ) .
'/' .
109 $this->definition[
'name'] .
'.json';
125 if ( !file_exists( $localDataPath ) ) {
129 $data = json_decode( file_get_contents( $localDataPath ),
true );
133 $fixPath =
function ( &
$path ) use ( $dataPath ) {
136 dirname( $dataPath->getPath() ) .
'/' .
$path,
137 $dataPath->getLocalBasePath(),
138 $dataPath->getRemoteBasePath()
145 array_walk( $data[
'images'],
function ( &$value ) use ( $fixPath ) {
146 if ( is_string( $value[
'file'] ) ) {
147 $fixPath( $value[
'file'] );
148 } elseif ( is_array( $value[
'file'] ) ) {
149 array_walk_recursive( $value[
'file'], $fixPath );
static getSkinThemeMap()
Return a map of skin names (in lowercase) to OOUI theme names, defining which theme a given skin shou...
getThemeImagesPath( $theme, $module)
An object to represent a path to a JavaScript/CSS file, along with a remote and local base path,...
Module for generated and embedded images.
Loads the module definition from JSON files in the format that OOUI uses, converting it to the format...
loadOOUIDefinition( $theme, $module)
Load the module definition from the JSON file(s) for the given theme and module.
loadFromDefinition()
Parse definition and external JSON data, if referenced.
readJSONFile( $dataPath)
Read JSON from a file, and transform all paths in it to be relative to the module's base path.
trait ResourceLoaderOOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.