MediaWiki  1.30.0
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() {
75  $themeMap = self::$builtinSkinThemeMap;
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 }
$knownStylesModules
static $knownStylesModules
Definition: ResourceLoaderOOUIModule.php:28
getThemePaths
static getThemePaths()
Return a map of theme names to lists of paths from which a given theme should be loaded.
Definition: ResourceLoaderOOUIModule.php:90
getThemeScriptsPath
getThemeScriptsPath( $theme, $module)
Definition: ResourceLoaderOOUIModule.php:116
$builtinSkinThemeMap
static $builtinSkinThemeMap
Definition: ResourceLoaderOOUIModule.php:50
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
getThemePath
getThemePath( $theme, $kind, $module)
Return a path to load given module of given theme from.
Definition: ResourceLoaderOOUIModule.php:104
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:80
getThemeStylesPath
getThemeStylesPath( $theme, $module)
Definition: ResourceLoaderOOUIModule.php:128
$knownImagesModules
static $knownImagesModules
Definition: ResourceLoaderOOUIModule.php:29
getSkinThemeMap
static getSkinThemeMap()
Return a map of skin names (in lowercase) to OOUI theme names, defining which theme a given skin shou...
Definition: ResourceLoaderOOUIModule.php:74
$builtinThemePaths
static $builtinThemePaths
Definition: ResourceLoaderOOUIModule.php:55
$path
$path
Definition: NoLocalSettings.php:26
ResourceLoaderOOUIModule
trait ResourceLoaderOOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.
Definition: ResourceLoaderOOUIModule.php:26
getThemeImagesPath
getThemeImagesPath( $theme, $module)
Definition: ResourceLoaderOOUIModule.php:140