MimeAnalyzer: Add testcases for mp3 detection
[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'] = '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 'oojs',
69 'oojs-ui-core.styles',
70 'oojs-ui.styles.icons',
71 'oojs-ui.styles.indicators',
72 'oojs-ui.styles.textures',
73 'mediawiki.language',
74 ],
75 'targets' => [ 'desktop', 'mobile' ],
76 ];
77 // This contains only the styles required by core widgets.
78 $modules['oojs-ui-core.styles'] = [
79 'position' => 'top',
80 'styles' => 'resources/src/oojs-ui-local.css', // HACK, see inside the file
81 'skinStyles' => $getSkinSpecific( 'core' ),
82 'targets' => [ 'desktop', 'mobile' ],
83 ];
84
85 // Additional widgets and layouts module.
86 $modules['oojs-ui-widgets'] = [
87 'scripts' => 'resources/lib/oojs-ui/oojs-ui-widgets.js',
88 'skinStyles' => $getSkinSpecific( 'widgets' ),
89 'dependencies' => 'oojs-ui-core',
90 'messages' => [
91 'ooui-outline-control-move-down',
92 'ooui-outline-control-move-up',
93 'ooui-outline-control-remove',
94 'ooui-selectfile-button-select',
95 'ooui-selectfile-dragdrop-placeholder',
96 'ooui-selectfile-not-supported',
97 'ooui-selectfile-placeholder',
98 ],
99 'targets' => [ 'desktop', 'mobile' ],
100 ];
101 // Toolbar and tools module.
102 $modules['oojs-ui-toolbars'] = [
103 'scripts' => 'resources/lib/oojs-ui/oojs-ui-toolbars.js',
104 'skinStyles' => $getSkinSpecific( 'toolbars' ),
105 'dependencies' => 'oojs-ui-core',
106 'messages' => [
107 'ooui-toolbar-more',
108 'ooui-toolgroup-collapse',
109 'ooui-toolgroup-expand',
110 ],
111 'targets' => [ 'desktop', 'mobile' ],
112 ];
113 // Windows and dialogs module.
114 $modules['oojs-ui-windows'] = [
115 'scripts' => 'resources/lib/oojs-ui/oojs-ui-windows.js',
116 'skinStyles' => $getSkinSpecific( 'windows' ),
117 'dependencies' => 'oojs-ui-core',
118 'messages' => [
119 'ooui-dialog-message-accept',
120 'ooui-dialog-message-reject',
121 'ooui-dialog-process-continue',
122 'ooui-dialog-process-dismiss',
123 'ooui-dialog-process-error',
124 'ooui-dialog-process-retry',
125 ],
126 'targets' => [ 'desktop', 'mobile' ],
127 ];
128
129 $imageSets = [
130 // Comments for greppability
131 'icons', // oojs-ui.styles.icons
132 'indicators', // oojs-ui.styles.indicators
133 'textures', // oojs-ui.styles.textures
134 'icons-accessibility', // oojs-ui.styles.icons-accessibility
135 'icons-alerts', // oojs-ui.styles.icons-alerts
136 'icons-content', // oojs-ui.styles.icons-content
137 'icons-editing-advanced', // oojs-ui.styles.icons-editing-advanced
138 'icons-editing-core', // oojs-ui.styles.icons-editing-core
139 'icons-editing-list', // oojs-ui.styles.icons-editing-list
140 'icons-editing-styling', // oojs-ui.styles.icons-editing-styling
141 'icons-interactions', // oojs-ui.styles.icons-interactions
142 'icons-layout', // oojs-ui.styles.icons-layout
143 'icons-location', // oojs-ui.styles.icons-location
144 'icons-media', // oojs-ui.styles.icons-media
145 'icons-moderation', // oojs-ui.styles.icons-moderation
146 'icons-movement', // oojs-ui.styles.icons-movement
147 'icons-user', // oojs-ui.styles.icons-user
148 'icons-wikimedia', // oojs-ui.styles.icons-wikimedia
149 ];
150 $rootPath = 'resources/lib/oojs-ui/themes';
151
152 foreach ( $imageSets as $name ) {
153 $module = [
154 'position' => 'top',
155 'class' => 'ResourceLoaderOOUIImageModule',
156 'name' => $name,
157 'rootPath' => $rootPath,
158 ];
159
160 if ( substr( $name, 0, 5 ) === 'icons' ) {
161 $module['selectorWithoutVariant'] = '.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
162 $module['selectorWithVariant'] = '
163 .oo-ui-image-{variant}.oo-ui-icon-{name}, .mw-ui-icon-{name}-{variant}:before,
164 /* Hack for Flow, see T110051 */
165 .mw-ui-hovericon:hover .mw-ui-icon-{name}-{variant}-hover:before,
166 .mw-ui-hovericon.mw-ui-icon-{name}-{variant}-hover:hover:before';
167 }
168
169 $modules["oojs-ui.styles.$name"] = $module;
170 }
171
172 return $modules;
173 } );