1 | <?php |
||
2 | /** |
||
3 | * An extension providing the Bootstrap library to other extensions |
||
4 | * |
||
5 | * @see https://www.mediawiki.org/wiki/Extension:Bootstrap |
||
6 | * @see https://getbootstrap.com/ |
||
7 | * |
||
8 | * @author Stephan Gambke |
||
9 | * |
||
10 | * @defgroup Bootstrap Bootstrap |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * The main file of the Bootstrap extension |
||
15 | * |
||
16 | * @copyright (C) 2013 - 2018, Stephan Gambke |
||
17 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later) |
||
18 | * |
||
19 | * This file is part of the MediaWiki extension Bootstrap. |
||
20 | * The Bootstrap extension is free software: you can redistribute it and/or |
||
21 | * modify it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation, either version 3 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * The Bootstrap extension is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
32 | * |
||
33 | * @file |
||
34 | * @ingroup Bootstrap |
||
35 | * |
||
36 | * @codeCoverageIgnore |
||
37 | */ |
||
38 | call_user_func( function () { |
||
39 | |||
40 | if ( !defined( 'MEDIAWIKI' ) ) { |
||
41 | die( 'This file is part of the MediaWiki extension Bootstrap, it is not a valid entry point.' ); |
||
0 ignored issues
–
show
|
|||
42 | } |
||
43 | |||
44 | if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.22', 'lt' ) ) { |
||
45 | die( '<b>Error:</b> This version of <a href="https://www.mediawiki.org/wiki/Extension:Bootstrap">Bootstrap</a> is only compatible with MediaWiki 1.22 or above. You need to upgrade MediaWiki first.' ); |
||
0 ignored issues
–
show
|
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * The extension version |
||
50 | */ |
||
51 | define( 'BS_VERSION', '1.3.0' ); |
||
52 | |||
53 | // register the extension |
||
54 | $GLOBALS[ 'wgExtensionCredits' ][ 'other' ][ ] = array( |
||
55 | 'path' => __FILE__, |
||
56 | 'name' => 'Bootstrap', |
||
57 | 'author' => array( '[https://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]', 'James Hong Kong' ), |
||
58 | 'url' => 'https://www.mediawiki.org/wiki/Extension:Bootstrap', |
||
59 | 'descriptionmsg' => 'bootstrap-desc', |
||
60 | 'version' => BS_VERSION, |
||
61 | 'license-name' => 'GPL-3.0+', |
||
62 | ); |
||
63 | |||
64 | // register message files |
||
65 | $GLOBALS[ 'wgMessagesDirs' ][ 'Bootstrap' ] = __DIR__ . '/i18n'; |
||
66 | $GLOBALS[ 'wgExtensionMessagesFiles' ][ 'Bootstrap' ] = __DIR__ . '/Bootstrap.i18n.php'; |
||
67 | |||
68 | // register classes |
||
69 | $GLOBALS[ 'wgAutoloadClasses' ][ 'Bootstrap\ResourceLoaderBootstrapModule' ] = __DIR__ . '/src/ResourceLoaderBootstrapModule.php'; |
||
70 | $GLOBALS[ 'wgAutoloadClasses' ][ 'Bootstrap\BootstrapManager' ] = __DIR__ . '/src/BootstrapManager.php'; |
||
71 | $GLOBALS[ 'wgAutoloadClasses' ][ 'Bootstrap\Hooks\SetupAfterCache' ] = __DIR__ . '/src/Hooks/SetupAfterCache.php'; |
||
72 | $GLOBALS[ 'wgAutoloadClasses' ][ 'Bootstrap\Definition\ModuleDefinition' ] = __DIR__ . '/src/Definition/ModuleDefinition.php'; |
||
73 | $GLOBALS[ 'wgAutoloadClasses' ][ 'Bootstrap\Definition\V3ModuleDefinition' ] = __DIR__ . '/src/Definition/V3ModuleDefinition.php'; |
||
74 | |||
75 | $GLOBALS[ 'wgHooks' ][ 'SetupAfterCache' ][ ] = function() { |
||
76 | |||
77 | $configuration = array(); |
||
78 | $configuration[ 'IP' ] = $GLOBALS[ 'IP' ]; |
||
79 | $configuration[ 'remoteBasePath' ] = $GLOBALS[ 'wgExtensionAssetsPath' ] . '/Bootstrap/resources/bootstrap'; |
||
80 | |||
81 | if ( isset( $GLOBALS[ 'wgExtensionDirectory' ] ) ) { // MW >= 1.25 |
||
82 | $configuration[ 'localBasePath' ] = $GLOBALS[ 'wgExtensionDirectory' ] . '/Bootstrap/resources/bootstrap'; |
||
83 | } else { |
||
84 | $configuration[ 'localBasePath' ] = __DIR__ . '/resources/bootstrap'; |
||
85 | } |
||
86 | |||
87 | $setupAfterCache = new \Bootstrap\Hooks\SetupAfterCache( $configuration ); |
||
88 | $setupAfterCache->process(); |
||
89 | }; |
||
90 | |||
91 | // register skeleton resource module with the Resource Loader |
||
92 | // do not add paths, globals are not set yet |
||
93 | $GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.styles' ] = array( |
||
94 | 'class' => 'Bootstrap\ResourceLoaderBootstrapModule', |
||
95 | 'position' => 'top', |
||
96 | 'styles' => array(), |
||
97 | 'variables' => array(), |
||
98 | 'dependencies' => array(), |
||
99 | 'cachetriggers' => array( |
||
100 | 'LocalSettings.php' => null, |
||
101 | 'composer.lock' => null, |
||
102 | ), |
||
103 | ); |
||
104 | |||
105 | $GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap.scripts' ] = array( |
||
106 | 'scripts' => array(), |
||
107 | ); |
||
108 | |||
109 | $GLOBALS[ 'wgResourceModules' ][ 'ext.bootstrap' ] = array( |
||
110 | 'dependencies' => array( 'ext.bootstrap.styles', 'ext.bootstrap.scripts' ), |
||
111 | ); |
||
112 | |||
113 | } ); |
||
114 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.