forked from SemanticMediaWiki/SemanticScribunto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SemanticScribunto.php
77 lines (64 loc) · 2.16 KB
/
SemanticScribunto.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
<?php
use SMW\Scribunto\HookRegistry;
/**
* @see https://github.com/SemanticMediaWiki/SemanticScribunto/
*
* @defgroup SemanticScribunto Semantic Scribunto
*/
SemanticScribunto::load();
/**
* @codeCoverageIgnore
*/
class SemanticScribunto {
/**
* @since 1.0
*
* @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';
}
}
/**
* @since 1.0
*/
public static function initExtension( $credits = [] ) {
// See https://phabricator.wikimedia.org/T151136
define( 'SMW_SCRIBUNTO_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' );
// Register message files
$GLOBALS['wgMessagesDirs']['SemanticScribunto'] = __DIR__ . '/i18n';
}
/**
* @since 1.0
*/
public static function onExtensionFunction() {
if ( !defined( 'SMW_VERSION' ) ) {
if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
die( "\nThe 'Semantic Scribunto' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" );
} else {
die(
'<b>Error:</b> The <a href="https://github.com/SemanticMediaWiki/SemanticScribunto/">Semantic Scribunto</a> ' .
'extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> '.
'to be installed and enabled.<br />'
);
}
}
// Using the constant as indicator to avoid class_exists
if ( !defined( 'CONTENT_MODEL_SCRIBUNTO' ) ) {
if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
die( "\nThe 'Semantic Scribunto' extension requires the 'Scribunto' extension to be installed and enabled.\n" );
} else {
die(
'<b>Error:</b> <a href="https://github.com/SemanticMediaWiki/SemanticScribunto/">Semantic Scribunto</a> ' .
'requires <a href="https://www.mediawiki.org/wiki/Extension:Scribunto">Scribunto</a>. Please install and ' .
'enable the extension first.<br />'
);
}
}
$hookRegistry = new HookRegistry();
$hookRegistry->register();
}
}