Merge "Apply $wgShellLocale in Setup.php"
[lhc/web/wiklou.git] / resources / ResourcesOOUI.php
1 <?php
2 /**
3 * Definition of OOjs UI ResourceLoader modules.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
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'] = 'wikimediaui';
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 'oojs',
69 'oojs-ui-core.styles',
70 'oojs-ui.styles.indicators',
71 'oojs-ui.styles.textures',
72 'mediawiki.language',
73 ],
74 'targets' => [ 'desktop', 'mobile' ],
75 ];
76 // This contains only the styles required by core widgets.
77 $modules['oojs-ui-core.styles'] = [
78 'position' => 'top',
79 'styles' => 'resources/src/oojs-ui-local.css', // HACK, see inside the file
80 'skinStyles' => $getSkinSpecific( 'core' ),
81 'targets' => [ 'desktop', 'mobile' ],
82 ];
83
84 // Additional widgets and layouts module.
85 $modules['oojs-ui-widgets'] = [
86 'scripts' => 'resources/lib/oojs-ui/oojs-ui-widgets.js',
87 'skinStyles' => $getSkinSpecific( 'widgets' ),
88 'dependencies' => 'oojs-ui-core',
89 'messages' => [
90 'ooui-outline-control-move-down',
91 'ooui-outline-control-move-up',
92 'ooui-outline-control-remove',
93 'ooui-selectfile-button-select',
94 'ooui-selectfile-dragdrop-placeholder',
95 'ooui-selectfile-not-supported',
96 'ooui-selectfile-placeholder',
97 ],
98 'targets' => [ 'desktop', 'mobile' ],
99 ];
100 // Toolbar and tools module.
101 $modules['oojs-ui-toolbars'] = [
102 'scripts' => 'resources/lib/oojs-ui/oojs-ui-toolbars.js',
103 'skinStyles' => $getSkinSpecific( 'toolbars' ),
104 'dependencies' => 'oojs-ui-core',
105 'messages' => [
106 'ooui-toolbar-more',
107 'ooui-toolgroup-collapse',
108 'ooui-toolgroup-expand',
109 ],
110 'targets' => [ 'desktop', 'mobile' ],
111 ];
112 // Windows and dialogs module.
113 $modules['oojs-ui-windows'] = [
114 'scripts' => 'resources/lib/oojs-ui/oojs-ui-windows.js',
115 'skinStyles' => $getSkinSpecific( 'windows' ),
116 'dependencies' => 'oojs-ui-core',
117 'messages' => [
118 'ooui-dialog-message-accept',
119 'ooui-dialog-message-reject',
120 'ooui-dialog-process-continue',
121 'ooui-dialog-process-dismiss',
122 'ooui-dialog-process-error',
123 'ooui-dialog-process-retry',
124 ],
125 'targets' => [ 'desktop', 'mobile' ],
126 ];
127
128 $imageSets = [
129 // Comments for greppability
130 'icons', // oojs-ui.styles.icons
131 'indicators', // oojs-ui.styles.indicators
132 'textures', // oojs-ui.styles.textures
133 'icons-accessibility', // oojs-ui.styles.icons-accessibility
134 'icons-alerts', // oojs-ui.styles.icons-alerts
135 'icons-content', // oojs-ui.styles.icons-content
136 'icons-editing-advanced', // oojs-ui.styles.icons-editing-advanced
137 'icons-editing-core', // oojs-ui.styles.icons-editing-core
138 'icons-editing-list', // oojs-ui.styles.icons-editing-list
139 'icons-editing-styling', // oojs-ui.styles.icons-editing-styling
140 'icons-interactions', // oojs-ui.styles.icons-interactions
141 'icons-layout', // oojs-ui.styles.icons-layout
142 'icons-location', // oojs-ui.styles.icons-location
143 'icons-media', // oojs-ui.styles.icons-media
144 'icons-moderation', // oojs-ui.styles.icons-moderation
145 'icons-movement', // oojs-ui.styles.icons-movement
146 'icons-user', // oojs-ui.styles.icons-user
147 'icons-wikimedia', // oojs-ui.styles.icons-wikimedia
148 ];
149 $rootPath = 'resources/lib/oojs-ui/themes';
150
151 foreach ( $imageSets as $name ) {
152 $module = [
153 'position' => 'top',
154 'class' => 'ResourceLoaderOOUIImageModule',
155 'name' => $name,
156 'rootPath' => $rootPath,
157 ];
158
159 if ( substr( $name, 0, 5 ) === 'icons' ) {
160 $module['selectorWithoutVariant'] = '.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
161 $module['selectorWithVariant'] = '
162 .oo-ui-image-{variant}.oo-ui-icon-{name}, .mw-ui-icon-{name}-{variant}:before,
163 /* Hack for Flow, see T110051 */
164 .mw-ui-hovericon:hover .mw-ui-icon-{name}-{variant}-hover:before,
165 .mw-ui-hovericon.mw-ui-icon-{name}-{variant}-hover:hover:before';
166 }
167
168 $modules["oojs-ui.styles.$name"] = $module;
169 }
170
171 return $modules;
172 } );