forked from SemanticMediaWiki/SemanticMediaWiki
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.php
171 lines (137 loc) · 4.76 KB
/
load.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
use SMW\NamespaceManager;
use SMW\ApplicationFactory;
use SMW\Setup;
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'Not an entry point.' );
}
SemanticMediaWiki::initExtension();
$GLOBALS['wgExtensionFunctions'][] = function() {
SemanticMediaWiki::onExtensionFunction();
};
$GLOBALS['wgHooks']['LanguageGetNamespaces'][] = function( array &$namespaces ) {
NamespaceManager::initCustomNamespace( $GLOBALS );
$namespaces += NamespaceManager::getCanonicalNames();
return true;
};
/**
* @codeCoverageIgnore
*/
class SemanticMediaWiki {
/**
* @since 2.4
*/
public static function initExtension() {
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once __DIR__ . '/vendor/autoload.php';
}
define( 'SMW_VERSION', '2.4.6' );
// Registration of the extension credits, see Special:Version.
$GLOBALS['wgExtensionCredits']['semantic'][] = array(
'path' => __FILE__,
'name' => 'Semantic MediaWiki',
'version' => SMW_VERSION,
'author' => array(
'[http://korrekt.org Markus Krötzsch]',
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]',
'James Hong Kong',
'[https://www.semantic-mediawiki.org/wiki/Contributors ...]',
),
'url' => 'https://www.semantic-mediawiki.org',
'descriptionmsg' => 'smw-desc',
'license-name' => 'GPL-2.0+',
);
// A flag used to indicate SMW defines a semantic extension type for extension credits.
// @deprecated, removal in SMW 3.0
define( 'SEMANTIC_EXTENSION_TYPE', true );
// Load class_alias
require_once __DIR__ . '/src/Aliases.php';
// Load global constants
require_once __DIR__ . '/src/Defines.php';
// Temporary measure to ease Composer/MW 1.22 migration
require_once __DIR__ . '/src/NamespaceManager.php';
// Load global functions
require_once __DIR__ . '/src/GlobalFunctions.php';
// Load default settings
require_once __DIR__ . '/DefaultSettings.php';
// Wikia change - begin
// SUS-1232: allow SemanticMediaWiki config variables to be customized via WikiFactory
/** @var array $smwDefaults */
foreach ( $smwDefaults as $variableName => $variableDefaultValue ) {
if ( !array_key_exists( $variableName, $GLOBALS ) ) {
// variable was not set via WikiFactory, so we can safely use a default coming from SMW's DefaultSettings.php (i.e. $smwDefaults)
$GLOBALS[ $variableName ] = $variableDefaultValue;
}
}
// Wikia change - end
// Because of MW 1.19 we need to register message files here
$GLOBALS['wgMessagesDirs']['SemanticMediaWiki'] = $GLOBALS['smwgIP'] . 'i18n';
$GLOBALS['wgExtensionMessagesFiles']['SemanticMediaWiki'] = $GLOBALS['smwgIP'] . 'languages/SMW_Messages.php';
$GLOBALS['wgExtensionMessagesFiles']['SemanticMediaWikiAlias'] = $GLOBALS['smwgIP'] . 'languages/SMW_Aliases.php';
$GLOBALS['wgExtensionMessagesFiles']['SemanticMediaWikiMagic'] = $GLOBALS['smwgIP'] . 'languages/SMW_Magic.php';
self::onCanonicalNamespaces();
}
/**
* CanonicalNamespaces initialization
*
* @note According to T104954 registration via wgExtensionFunctions can be
* too late and should happen before that in case RequestContext::getLanguage
* invokes Language::getNamespaces before the `wgExtensionFunctions` execution.
*
* @see https://phabricator.wikimedia.org/T104954#2391291
* @see https://www.mediawiki.org/wiki/Manual:Hooks/CanonicalNamespaces
* @Bug 34383
*
* @since 2.5
*/
public static function onCanonicalNamespaces() {
$GLOBALS['wgHooks']['CanonicalNamespaces'][] = 'SMW\NamespaceManager::initCanonicalNamespaces';
}
/**
* Setup and initialization
*
* @note $wgExtensionFunctions variable is an array that stores
* functions to be called after most of MediaWiki initialization
* has finalized
*
* @see https://www.mediawiki.org/wiki/Manual:$wgExtensionFunctions
*
* @since 1.9
*/
public static function onExtensionFunction() {
// 3.x reverse the order to ensure that smwgMainCacheType is used
// as main and smwgCacheType being deprecated with 3.x
$GLOBALS['smwgMainCacheType'] = $GLOBALS['smwgCacheType'];
$applicationFactory = ApplicationFactory::getInstance();
$namespace = new NamespaceManager( $GLOBALS );
$namespace->init();
$setup = new Setup( $applicationFactory, $GLOBALS, __DIR__ );
$setup->run();
}
/**
* @since 2.4
*
* @return string|null
*/
public static function getVersion() {
return SMW_VERSION;
}
/**
* @since 2.4
*
* @return array
*/
public static function getEnvironment() {
$store = '';
if ( isset( $GLOBALS['smwgDefaultStore'] ) ) {
$store = $GLOBALS['smwgDefaultStore'];
};
if ( strpos( strtolower( $store ), 'sparql' ) ) {
$store .= '::' . strtolower( $GLOBALS['smwgSparqlDatabaseConnector'] );
}
return array(
'store' => $store,
'db' => isset( $GLOBALS['wgDBtype'] ) ? $GLOBALS['wgDBtype'] : 'N/A',
);
}
}