blob: f74224b5830bebf9c810f16bb66280d6bcb53fa1 (
plain)
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
|
<?php
use SMW\NamespaceManager;
use SMW\ApplicationFactory;
use SMW\Setup;
/**
* @codeCoverageIgnore
*
* ExtensionRegistry only maps classes and functions after all extensions have
* been queued from the LocalSettings.php resulting in DefaultSettings not being
* loaded in-time.
*
* When changing the load order, please ensure that this function is run either
* via Composer's autoloading or as part of your internal registration.
*/
SemanticMediaWiki::load();
/**
* @codeCoverageIgnore
*
* This documentation group collects source code files belonging to Semantic
* MediaWiki.
*
* For documenting extensions of SMW, please do not use groups starting with
* "SMW" but make your own groups instead. Browsing at
* https://doc.semantic-mediawiki.org/ is assumed to be easier this way.
*
* @defgroup SMW Semantic MediaWiki
*/
class SemanticMediaWiki {
/**
* @since 2.5
*
* @note It is expected that this function is loaded before LocalSettings.php
* to ensure that settings and global functions are available by the time
* the extension is activated.
*/
public static function load() {
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once __DIR__ . '/vendor/autoload.php';
}
include_once __DIR__ . '/src/Aliases.php';
include_once __DIR__ . '/src/Defines.php';
include_once __DIR__ . '/src/GlobalFunctions.php';
// If the function is called more than once then this will fail on
// purpose
foreach ( include __DIR__ . '/DefaultSettings.php' as $key => $value ) {
if ( !isset( $GLOBALS[$key] ) ) {
$GLOBALS[$key] = $value;
}
}
}
/**
* @since 2.4
*/
public static function initExtension( $credits = [] ) {
define( 'SMW_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'N/A' );
// Registration point for required early registration
Setup::initExtension( $GLOBALS );
}
/**
* 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() {
$applicationFactory = ApplicationFactory::getInstance();
$namespace = new NamespaceManager();
$namespace->init( $GLOBALS );
$setup = new Setup( $applicationFactory );
$setup->loadSchema( $GLOBALS );
$setup->init( $GLOBALS, __DIR__ );
}
/**
* @since 2.4
*
* @return string|null
*/
public static function getVersion() {
if ( !defined( 'SMW_VERSION' ) ) {
return null;
}
return SMW_VERSION;
}
}
|