MediaWiki REL1_30
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-core',
37 'icons-editing-list',
38 'icons-editing-styling',
39 'icons-interactions',
40 'icons-layout',
41 'icons-location',
42 'icons-media',
43 'icons-moderation',
44 'icons-movement',
45 'icons-user',
46 'icons-wikimedia',
47 ];
48
49 // Note that keys must be lowercase, values TitleCase.
50 protected static $builtinSkinThemeMap = [
51 'default' => 'WikimediaUI',
52 ];
53
54 // Note that keys must be TitleCase.
55 protected static $builtinThemePaths = [
56 'WikimediaUI' => [
57 'scripts' => 'resources/lib/oojs-ui/oojs-ui-wikimediaui.js',
58 'styles' => 'resources/lib/oojs-ui/oojs-ui-{module}-wikimediaui.css',
59 'images' => 'resources/lib/oojs-ui/themes/wikimediaui/{module}.json',
60 ],
61 'Apex' => [
62 'scripts' => 'resources/lib/oojs-ui/oojs-ui-apex.js',
63 'styles' => 'resources/lib/oojs-ui/oojs-ui-{module}-apex.css',
64 'images' => 'resources/lib/oojs-ui/themes/apex/{module}.json',
65 ],
66 ];
67
74 public static function getSkinThemeMap() {
76 $themeMap += ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
77 return $themeMap;
78 }
79
90 protected static function getThemePaths() {
91 $themePaths = self::$builtinThemePaths;
92 return $themePaths;
93 }
94
104 protected function getThemePath( $theme, $kind, $module ) {
105 $paths = self::getThemePaths();
106 $path = $paths[ $theme ][ $kind ];
107 $path = str_replace( '{module}', $module, $path );
108 return $path;
109 }
110
116 protected function getThemeScriptsPath( $theme, $module ) {
117 if ( !in_array( $module, self::$knownScriptsModules ) ) {
118 throw new InvalidArgumentException( "Invalid OOUI scripts module '$module'" );
119 }
120 return $this->getThemePath( $theme, 'scripts', $module );
121 }
122
128 protected function getThemeStylesPath( $theme, $module ) {
129 if ( !in_array( $module, self::$knownStylesModules ) ) {
130 throw new InvalidArgumentException( "Invalid OOUI styles module '$module'" );
131 }
132 return $this->getThemePath( $theme, 'styles', $module );
133 }
134
140 protected function getThemeImagesPath( $theme, $module ) {
141 if ( !in_array( $module, self::$knownImagesModules ) ) {
142 throw new InvalidArgumentException( "Invalid OOUI images module '$module'" );
143 }
144 return $this->getThemePath( $theme, 'images', $module );
145 }
146}
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)