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();
106 $this->definition[
'rootPath'] .
'/' .
107 strtolower( $theme ) .
'/' .
108 $this->definition[
'name'] .
'.json';
124 if ( !file_exists( $localDataPath ) ) {
128 $data = json_decode( file_get_contents( $localDataPath ),
true );
132 $fixPath =
function ( &
$path ) use ( $dataPath ) {
135 dirname( $dataPath->getPath() ) .
'/' .
$path,
136 $dataPath->getLocalBasePath(),
137 $dataPath->getRemoteBasePath()
143 array_walk( $data[
'images'],
function ( &$value ) use ( $fixPath ) {
144 if ( is_string( $value[
'file'] ) ) {
145 $fixPath( $value[
'file'] );
146 } elseif ( is_array( $value[
'file'] ) ) {
147 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.