This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
/
Chameleon.php
144 lines (125 loc) · 4.54 KB
/
Chameleon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* The Chameleon skin. A Mediawiki skin using Twitter Bootstrap.
*
* @see https://www.mediawiki.org/wiki/Skin:Chameleon
*
* @author Stephan Gambke
* @version 1.0-alpha
*
*/
/**
* The main file of the Chameleon skin
*
* @copyright (C) 2013, Stephan Gambke
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later)
*
* This file is part of the MediaWiki skin Chameleon.
* The Chameleon skin is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Chameleon skin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @file
* @ingroup Skins
*
* @codeCoverageIgnore
*/
call_user_func( function () {
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is part of a MediaWiki extension, it is not a valid entry point.' );
}
if ( !defined( 'BS_VERSION' ) ) {
die( '<b>Error:</b> The <a href="https://www.mediawiki.org/wiki/Skin:Chameleon">Chameleon</a> skin depends on the Bootstrap extension. You need to install the <a href="https://www.mediawiki.org/wiki/Extension:Bootstrap">Bootstrap</a> extension first.' );
}
// define the skin's version
define( 'CHAMELEON_VERSION', '1.0-alpha' );
// set extension credits
$GLOBALS[ 'wgExtensionCredits' ][ 'skin' ][ ] = array(
'path' => __FILE__,
'name' => 'Chameleon',
'descriptionmsg' => 'chameleon-desc',
'author' => '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]',
'url' => 'https://www.mediawiki.org/wiki/Skin:Chameleon',
'version' => CHAMELEON_VERSION,
);
// register skin
$GLOBALS[ 'wgValidSkinNames' ][ 'chameleon' ] = 'Chameleon';
// register message file for i18n
$GLOBALS[ 'wgExtensionMessagesFiles' ][ 'Chameleon' ] = __DIR__ . '/Chameleon.i18n.php';
$GLOBALS[ 'wgMessagesDirs' ][ 'Chameleon' ] = __DIR__ . '/i18n';
$chameleonComponents = array(
'Component',
'Structure',
'Container',
'Row',
'Cell',
'Grid',
'NavbarHorizontal',
'NavMenu',
'PageTools',
'NewtalkNotifier',
'PersonalTools',
'Logo',
'SearchBar',
'SiteNotice',
'ToolbarHorizontal',
'FooterInfo',
'FooterPlaces',
'FooterIcons',
'MainContent',
'Html',
);
foreach ( $chameleonComponents as $component ) {
$GLOBALS[ 'wgAutoloadClasses' ][ 'Skins\\Chameleon\\Components\\' . $component ] = __DIR__ . '/src/Components/' . $component . '.php';
}
$GLOBALS[ 'wgAutoloadClasses' ][ 'SkinChameleon' ] = dirname( __FILE__ ) . '/src/SkinChameleon.php'; // register skin class (must be 'Skin' . SkinName)
$GLOBALS[ 'wgAutoloadClasses' ][ 'Skins\Chameleon\ChameleonTemplate' ] = dirname( __FILE__ ) . '/src/ChameleonTemplate.php';
$GLOBALS[ 'wgAutoloadClasses' ][ 'Skins\Chameleon\IdRegistry' ] = dirname( __FILE__ ) . '/src/IdRegistry.php';
$GLOBALS[ 'wgAutoloadClasses' ][ 'Skins\Chameleon\Hooks\SetupAfterCache' ] = __DIR__ . '/src/Hooks/SetupAfterCache.php';
/**
* Using callbacks for hook registration
*
* The hook registry should contain as less knowledge about a process as
* necessary therefore a callback is used as Factory/Builder that instantiates
* a business / domain object.
*
* GLOBAL state should be encapsulated by the callback and not leaked into
* a instantiated class
*/
/**
* @see https://www.mediawiki.org/wiki/Manual:Hooks/SetupAfterCache
*/
$GLOBALS[ 'wgHooks' ][ 'SetupAfterCache' ][ ] = function() {
$configKeysToCopy = array(
'egChameleonExternalStyleModules',
'egChameleonExternalLessVariables',
'egChameleonEnableVisualEditor',
'IP',
'wgStyleDirectory',
'wgStylePath',
'wgVisualEditorSupportedSkins',
);
$configuration = array_intersect_key(
$GLOBALS,
array_flip( $configKeysToCopy )
);
$setupAfterCache = new \Skins\Chameleon\Hooks\SetupAfterCache(
\Bootstrap\BootstrapManager::getInstance(),
$configuration
);
$setupAfterCache->process()->adjustConfiguration( $GLOBALS );
};
// set default skin layout
$GLOBALS[ 'egChameleonLayoutFile' ] = dirname( __FILE__ ) . '/layouts/standard.xml';
// enable the VisualEditor for this skin
$GLOBALS[ 'egChameleonEnableVisualEditor' ] = true;
} );