MediaWiki REL1_32
ResourceLoaderOOUIModule.php
Go to the documentation of this file.
1<?php
27 protected static $knownScriptsModules = [ 'core' ];
28 protected static $knownStylesModules = [ 'core', 'widgets', 'toolbars', 'windows' ];
29 protected static $knownImagesModules = [
30 'indicators', 'textures',
31 // Extra icons
32 'icons-accessibility',
33 'icons-alerts',
34 'icons-content',
35 'icons-editing-advanced',
36 'icons-editing-citation',
37 'icons-editing-core',
38 'icons-editing-list',
39 'icons-editing-styling',
40 'icons-interactions',
41 'icons-layout',
42 'icons-location',
43 'icons-media',
44 'icons-moderation',
45 'icons-movement',
46 'icons-user',
47 'icons-wikimedia',
48 ];
49
50 // Note that keys must be lowercase, values TitleCase.
51 protected static $builtinSkinThemeMap = [
52 'default' => 'WikimediaUI',
53 ];
54
55 // Note that keys must be TitleCase.
56 protected static $builtinThemePaths = [
57 'WikimediaUI' => [
58 'scripts' => 'resources/lib/ooui/oojs-ui-wikimediaui.js',
59 'styles' => 'resources/lib/ooui/oojs-ui-{module}-wikimediaui.css',
60 'images' => 'resources/lib/ooui/themes/wikimediaui/{module}.json',
61 ],
62 'Apex' => [
63 'scripts' => 'resources/lib/ooui/oojs-ui-apex.js',
64 'styles' => 'resources/lib/ooui/oojs-ui-{module}-apex.css',
65 'images' => 'resources/lib/ooui/themes/apex/{module}.json',
66 ],
67 ];
68
75 public static function getSkinThemeMap() {
77 $themeMap += ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
78 return $themeMap;
79 }
80
91 protected static function getThemePaths() {
92 $themePaths = self::$builtinThemePaths;
93 return $themePaths;
94 }
95
105 protected function getThemePath( $theme, $kind, $module ) {
106 $paths = self::getThemePaths();
107 $path = $paths[ $theme ][ $kind ];
108 $path = str_replace( '{module}', $module, $path );
109 return $path;
110 }
111
117 protected function getThemeScriptsPath( $theme, $module ) {
118 if ( !in_array( $module, self::$knownScriptsModules ) ) {
119 throw new InvalidArgumentException( "Invalid OOUI scripts module '$module'" );
120 }
121 return $this->getThemePath( $theme, 'scripts', $module );
122 }
123
129 protected function getThemeStylesPath( $theme, $module ) {
130 if ( !in_array( $module, self::$knownStylesModules ) ) {
131 throw new InvalidArgumentException( "Invalid OOUI styles module '$module'" );
132 }
133 return $this->getThemePath( $theme, 'styles', $module );
134 }
135
141 protected function getThemeImagesPath( $theme, $module ) {
142 if ( !in_array( $module, self::$knownImagesModules ) ) {
143 throw new InvalidArgumentException( "Invalid OOUI images module '$module'" );
144 }
145 return $this->getThemePath( $theme, 'images', $module );
146 }
147}
static $knownImagesModules
static getThemePaths()
Return a map of theme names to lists of paths from which a given theme should be loaded.
static $knownStylesModules
static $builtinSkinThemeMap
static $builtinThemePaths
getThemePath( $theme, $kind, $module)
Return a path to load given module of given theme from.
static getSkinThemeMap()
Return a map of skin names (in lowercase) to OOUI theme names, defining which theme a given skin shou...
trait ResourceLoaderOOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.
getThemeScriptsPath( $theme, $module)
getThemeStylesPath( $theme, $module)
getThemeImagesPath( $theme, $module)