forked from SemanticMediaWiki/SemanticExtraSpecialProperties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SemanticExtraSpecialProperties.php
131 lines (107 loc) · 3.68 KB
/
SemanticExtraSpecialProperties.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
<?php
use SESP\HookRegistry;
/**
* Extension SemanticExtraSpecialProperties - Adds some extra special properties to all pages.
*
* @see https://github.com/SemanticMediaWiki/SemanticExtraSpecialProperties
*
* @defgroup SemanticExtraSpecialProperties Semantic Extra Special Properties
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is part of the SemanticExtraSpecialProperties extension, it is not a valid entry point.' );
}
if ( version_compare( $GLOBALS['wgVersion'], '1.25', '<' ) ) {
die( '<b>Error:</b> This version of Semantic Extra Special Properties requires MediaWiki 1.25 or above.' );
}
if ( !defined( 'SMW_VERSION' ) ) {
die( '<b>Error:</b> This version of Semantic Extra Special Properties requires <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> installed.<br />' );
}
if ( defined( 'SESP_VERSION' ) ) {
// Do not initialize more than once.
return 1;
}
SemanticExtraSpecialProperties::load();
/**
* @codeCoverageIgnore
*/
class SemanticExtraSpecialProperties {
/**
* @since 1.4
*
* @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() {
// Load DefaultSettings
require_once __DIR__ . '/DefaultSettings.php';
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once __DIR__ . '/vendor/autoload.php';
}
// In case extension.json is being used, the the succeeding steps will
// be handled by the ExtensionRegistry
self::initExtension();
// PHP 5.3
// "Fatal error: Cannot access self:: when no class scope is active"
$GLOBALS['wgExtensionFunctions'][] = function() {
SemanticExtraSpecialProperties::onExtensionFunction();
};
}
/**
* @since 1.4
*/
public static function initExtension() {
define( 'SESP_VERSION', '1.4.0-alpha' );
// Register extension info
$GLOBALS['wgExtensionCredits']['semantic'][] = array(
'path' => __FILE__,
'name' => 'Semantic Extra Special Properties',
'author' => array(
'[https://github.com/rotsee Leo Wallentin]',
'[https://www.semantic-mediawiki.org/wiki/User:MWJames James Hong Kong]',
'...'
),
'version' => SESP_VERSION,
'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticExtraSpecialProperties',
'descriptionmsg' => 'sesp-desc',
'license-name' => 'GPL-2.0+'
);
$GLOBALS['wgMessagesDirs']['SemanticExtraSpecialProperties'] = __DIR__ . '/i18n';
$GLOBALS['wgExtensionMessagesFiles']['SemanticExtraSpecialProperties'] = __DIR__ . '/i18n/SemanticExtraSpecialProperties.i18n.php';
self::onBeforeExtensionFunction();
}
/**
* Register hooks that require to be listed as soon as possible and preferable
* before the execution of onExtensionFunction
*
* @since 1.4
*/
public static function onBeforeExtensionFunction() {
$GLOBALS['wgHooks']['SMW::Config::BeforeCompletion'][] = '\SESP\HookRegistry::onBeforeConfigCompletion';
}
/**
* @since 1.4
*/
public static function onExtensionFunction() {
$configuration = array(
'wgDisableCounters' => $GLOBALS['wgDisableCounters'],
'sespUseAsFixedTables' => $GLOBALS['sespUseAsFixedTables'],
'sespSpecialProperties' => $GLOBALS['sespSpecialProperties'],
'wgSESPExcludeBots' => $GLOBALS['wgSESPExcludeBots'],
'wgShortUrlPrefix' => $GLOBALS['wgShortUrlPrefix'],
'sespCacheType' => $GLOBALS['sespCacheType']
);
$hookRegistry = new HookRegistry(
$configuration
);
$hookRegistry->register();
}
/**
* @since 1.4
*
* @return string|null
*/
public static function getVersion() {
return SESP_VERSION;
}
}