MediaWiki  1.27.2
ResourcesOOUI.php
Go to the documentation of this file.
1 <?php
23 if ( !defined( 'MEDIAWIKI' ) ) {
24  die( 'Not an entry point.' );
25 }
26 
27 // WARNING: OOjs-UI is NOT TESTED with older browsers and is likely to break
28 // if loaded in browsers that don't support ES5
29 return call_user_func( function () {
30  $themes = ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
31  // We only use the theme names for file names, and they are lowercase
32  $themes = array_map( 'strtolower', $themes );
33  $themes['default'] = 'mediawiki';
34 
35  // Helper function to generate paths to files used in 'skinStyles' and 'skinScripts'.
36  $getSkinSpecific = function ( $module, $ext = 'css' ) use ( $themes ) {
37  return array_combine(
38  array_keys( $themes ),
39  array_map( function ( $theme ) use ( $module, $ext ) {
40  $module = $module ? "$module-" : '';
41  // TODO Allow extensions to specify this path somehow
42  return "resources/lib/oojs-ui/oojs-ui-$module$theme.$ext";
43  }, array_values( $themes ) )
44  );
45  };
46 
47  $modules = [];
48 
49  // Omnibus module.
50  $modules['oojs-ui'] = [
51  'dependencies' => [
52  'oojs-ui-core',
53  'oojs-ui-widgets',
54  'oojs-ui-toolbars',
55  'oojs-ui-windows',
56  ],
57  'targets' => [ 'desktop', 'mobile' ],
58  ];
59 
60  // The core JavaScript library.
61  $modules['oojs-ui-core'] = [
62  'scripts' => [
63  'resources/lib/oojs-ui/oojs-ui-core.js',
64  'resources/src/oojs-ui-local.js',
65  ],
66  'skinScripts' => $getSkinSpecific( null, 'js' ),
67  'dependencies' => [
68  'es5-shim',
69  'oojs',
70  'oojs-ui-core.styles',
71  'mediawiki.language',
72  ],
73  'targets' => [ 'desktop', 'mobile' ],
74  ];
75  // This contains only the styles required by core widgets.
76  $modules['oojs-ui-core.styles'] = [
77  'position' => 'top',
78  'styles' => 'resources/src/oojs-ui-local.css', // HACK, see inside the file
79  'skinStyles' => $getSkinSpecific( 'core' ),
80  'targets' => [ 'desktop', 'mobile' ],
81  // ResourceLoaderImageModule doesn't support 'skipFunction', so instead we set this up so that
82  // this module is skipped together with its dependencies. Nothing else depends on these modules.
83  'dependencies' => [
84  'oojs-ui.styles.icons',
85  'oojs-ui.styles.indicators',
86  'oojs-ui.styles.textures',
87  ],
88  'skipFunction' => 'resources/src/oojs-ui-styles-skip.js',
89  ];
90 
91  // Deprecated old name for the module 'oojs-ui-core.styles'.
92  $modules['oojs-ui.styles'] = $modules['oojs-ui-core.styles'];
93 
94  // Additional widgets and layouts module.
95  $modules['oojs-ui-widgets'] = [
96  'scripts' => 'resources/lib/oojs-ui/oojs-ui-widgets.js',
97  'skinStyles' => $getSkinSpecific( 'widgets' ),
98  'dependencies' => 'oojs-ui-core',
99  'messages' => [
100  'ooui-outline-control-move-down',
101  'ooui-outline-control-move-up',
102  'ooui-outline-control-remove',
103  'ooui-selectfile-button-select',
104  'ooui-selectfile-dragdrop-placeholder',
105  'ooui-selectfile-not-supported',
106  'ooui-selectfile-placeholder',
107  ],
108  'targets' => [ 'desktop', 'mobile' ],
109  ];
110  // Toolbar and tools module.
111  $modules['oojs-ui-toolbars'] = [
112  'scripts' => 'resources/lib/oojs-ui/oojs-ui-toolbars.js',
113  'skinStyles' => $getSkinSpecific( 'toolbars' ),
114  'dependencies' => 'oojs-ui-core',
115  'messages' => [
116  'ooui-toolbar-more',
117  'ooui-toolgroup-collapse',
118  'ooui-toolgroup-expand',
119  ],
120  'targets' => [ 'desktop', 'mobile' ],
121  ];
122  // Windows and dialogs module.
123  $modules['oojs-ui-windows'] = [
124  'scripts' => 'resources/lib/oojs-ui/oojs-ui-windows.js',
125  'skinStyles' => $getSkinSpecific( 'windows' ),
126  'dependencies' => 'oojs-ui-core',
127  'messages' => [
128  'ooui-dialog-message-accept',
129  'ooui-dialog-message-reject',
130  'ooui-dialog-process-continue',
131  'ooui-dialog-process-dismiss',
132  'ooui-dialog-process-error',
133  'ooui-dialog-process-retry',
134  ],
135  'targets' => [ 'desktop', 'mobile' ],
136  ];
137 
138  $imageSets = [
139  // Comments for greppability
140  'icons', // oojs-ui.styles.icons
141  'indicators', // oojs-ui.styles.indicators
142  'textures', // oojs-ui.styles.textures
143  'icons-accessibility', // oojs-ui.styles.icons-accessibility
144  'icons-alerts', // oojs-ui.styles.icons-alerts
145  'icons-content', // oojs-ui.styles.icons-content
146  'icons-editing-advanced', // oojs-ui.styles.icons-editing-advanced
147  'icons-editing-core', // oojs-ui.styles.icons-editing-core
148  'icons-editing-list', // oojs-ui.styles.icons-editing-list
149  'icons-editing-styling', // oojs-ui.styles.icons-editing-styling
150  'icons-interactions', // oojs-ui.styles.icons-interactions
151  'icons-layout', // oojs-ui.styles.icons-layout
152  'icons-location', // oojs-ui.styles.icons-location
153  'icons-media', // oojs-ui.styles.icons-media
154  'icons-moderation', // oojs-ui.styles.icons-moderation
155  'icons-movement', // oojs-ui.styles.icons-movement
156  'icons-user', // oojs-ui.styles.icons-user
157  'icons-wikimedia', // oojs-ui.styles.icons-wikimedia
158  ];
159  $rootPath = 'resources/lib/oojs-ui/themes';
160 
161  foreach ( $imageSets as $name ) {
162  $module = [
163  'position' => 'top',
164  'class' => 'ResourceLoaderOOUIImageModule',
165  'name' => $name,
166  'rootPath' => $rootPath,
167  ];
168 
169  if ( substr( $name, 0, 5 ) === 'icons' ) {
170  $module['selectorWithoutVariant'] = '.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
171  $module['selectorWithVariant'] = '
172  .oo-ui-image-{variant}.oo-ui-icon-{name}, .mw-ui-icon-{name}-{variant}:before,
173  /* Hack for Flow, see T110051 */
174  .mw-ui-hovericon:hover .mw-ui-icon-{name}-{variant}-hover:before,
175  .mw-ui-hovericon.mw-ui-icon-{name}-{variant}-hover:hover:before';
176  }
177 
178  $modules["oojs-ui.styles.$name"] = $module;
179  }
180 
181  return $modules;
182 } );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
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
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310