1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SWL; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @codeCoverageIgnore |
7
|
|
|
*/ |
8
|
|
|
class SemanticWatchlist { |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @since 1.2 |
12
|
|
|
* |
13
|
|
|
* @note It is expected that this function is loaded before LocalSettings.php |
14
|
|
|
* to ensure that settings and global functions are available by the time |
15
|
|
|
* the extension is activated. |
16
|
|
|
*/ |
17
|
|
|
public static function load() { |
18
|
|
|
// Load DefaultSettings |
19
|
|
|
require_once __DIR__ . '/../DefaultSettings.php'; |
20
|
|
|
|
21
|
|
|
if ( defined( 'SWL_VERSION' ) ) { |
22
|
|
|
// Do not initialize more than once. |
23
|
|
|
return 1; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
define( 'SWL_VERSION', '1.2.0-alpha' ); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* In case extension.json is being used, the succeeding steps are |
30
|
|
|
* expected to be handled by the ExtensionRegistry aka extension.json |
31
|
|
|
* ... |
32
|
|
|
* |
33
|
|
|
* "callback": "SemanticWatchlist::initExtension", |
34
|
|
|
* "ExtensionFunctions": [ |
35
|
|
|
* "SemanticWatchlist::onExtensionFunction" |
36
|
|
|
* ], |
37
|
|
|
*/ |
38
|
|
|
self::initExtension(); |
39
|
|
|
|
40
|
|
|
$GLOBALS['wgExtensionFunctions'][] = function() { |
41
|
|
|
SemanticWatchlist::onExtensionFunction(); |
42
|
|
|
}; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @since 1.2 |
47
|
|
|
*/ |
48
|
|
|
public static function initExtension() { |
49
|
|
|
// Register the extension |
50
|
|
|
$GLOBALS['wgExtensionCredits']['semantic'][] = array( |
51
|
|
|
'path' => __FILE__, |
52
|
|
|
'name' => 'Semantic Watchlist', |
53
|
|
|
'version' => SWL_VERSION, |
54
|
|
|
'author' => array( |
55
|
|
|
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw] for [http://www.wikiworks.com/ WikiWorks]', |
56
|
|
|
'...' |
57
|
|
|
), |
58
|
|
|
'url' => 'https://www.mediawiki.org/wiki/Extension:Semantic_Watchlist', |
59
|
|
|
'descriptionmsg' => 'semanticwatchlist-desc', |
60
|
|
|
'license-name' => 'GPL-3.0-or-later' |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
$GLOBALS['egSwlSqlDatabaseSchemaPath'] = __DIR__ . '/../src/swl-table-schema.sql'; |
64
|
|
|
|
65
|
|
|
// Register message files |
66
|
|
|
$GLOBALS['wgMessagesDirs']['SemanticWatchlist'] = __DIR__ . '/../i18n'; |
67
|
|
|
$GLOBALS['wgExtensionMessagesFiles']['SemanticWatchlistAlias'] = __DIR__ . '/../SemanticWatchlist.i18n.alias.php'; |
68
|
|
|
|
69
|
|
|
$GLOBALS['egSWLScriptPath'] = $GLOBALS['wgExtensionAssetsPath'] === false ? $GLOBALS['wgScriptPath'] . '/extensions/SemanticWatchlist' : $GLOBALS['wgExtensionAssetsPath'] . '/SemanticWatchlist'; |
70
|
|
|
|
71
|
|
|
// wgSpecialPages |
72
|
|
|
$GLOBALS['wgSpecialPages']['SemanticWatchlist'] = 'SpecialSemanticWatchlist'; |
73
|
|
|
$GLOBALS['wgSpecialPageGroups']['SemanticWatchlist'] = 'changes'; |
74
|
|
|
|
75
|
|
|
$GLOBALS['wgSpecialPages']['WatchlistConditions'] = 'SpecialWatchlistConditions'; |
76
|
|
|
$GLOBALS['wgSpecialPageGroups']['WatchlistConditions'] = 'changes'; |
77
|
|
|
|
78
|
|
|
// wgAPIModules |
79
|
|
|
$GLOBALS['wgAPIModules']['addswlgroup'] = 'ApiAddWatchlistGroup'; |
80
|
|
|
$GLOBALS['wgAPIModules']['deleteswlgroup'] = 'ApiDeleteWatchlistGroup'; |
81
|
|
|
$GLOBALS['wgAPIModules']['editswlgroup'] = 'ApiEditWatchlistGroup'; |
82
|
|
|
$GLOBALS['wgAPIListModules']['semanticwatchlist'] = 'ApiQuerySemanticWatchlist'; |
83
|
|
|
|
84
|
|
|
// wgAvailableRights |
85
|
|
|
$GLOBALS['wgAvailableRights'][] = 'semanticwatch'; |
86
|
|
|
$GLOBALS['wgAvailableRights'][] = 'semanticwatchgroups'; |
87
|
|
|
|
88
|
|
|
$moduleTemplate = array( |
89
|
|
|
'localBasePath' => __DIR__ . '/..', |
90
|
|
|
'remoteBasePath' => $GLOBALS['egSWLScriptPath'] |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
$GLOBALS['wgResourceModules']['ext.swl.watchlist'] = $moduleTemplate + array( |
94
|
|
|
'styles' => array( 'specials/ext.swl.watchlist.css' ), |
95
|
|
|
'scripts' => array(), |
96
|
|
|
'dependencies' => array(), |
97
|
|
|
'messages' => array() |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
$GLOBALS['wgResourceModules']['ext.swl.watchlistconditions'] = $moduleTemplate + array( |
101
|
|
|
'styles' => array( 'specials/ext.swl.watchlistconditions.css' ), |
102
|
|
|
'scripts' => array( |
103
|
|
|
'specials/jquery.watchlistcondition.js', |
104
|
|
|
'specials/ext.swl.watchlistconditions.js' |
105
|
|
|
), |
106
|
|
|
'dependencies' => array(), |
107
|
|
|
'messages' => array( |
108
|
|
|
'swl-group-name', |
109
|
|
|
'swl-group-legend', |
110
|
|
|
'swl-group-properties', |
111
|
|
|
'swl-properties-list', |
112
|
|
|
'swl-group-remove-property', |
113
|
|
|
'swl-group-add-property', |
114
|
|
|
'swl-group-page-selection', |
115
|
|
|
'swl-group-save', |
116
|
|
|
'swl-group-saved', |
117
|
|
|
'swl-group-saving', |
118
|
|
|
'swl-group-remove', |
119
|
|
|
'swl-group-category', |
120
|
|
|
'swl-group-namespace', |
121
|
|
|
'swl-group-concept', |
122
|
|
|
'swl-group-confirm-remove', |
123
|
|
|
'swl-custom-legend', |
124
|
|
|
'swl-custom-remove-property', |
125
|
|
|
'swl-custom-text-add', |
126
|
|
|
'swl-custom-input', |
127
|
|
|
) |
128
|
|
|
); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @since 1.2 |
133
|
|
|
*/ |
134
|
|
|
public static function onExtensionFunction() { |
135
|
|
|
|
136
|
|
|
// Check requirements after LocalSetting.php has been processed, thid has |
137
|
|
|
// be done here to ensure SMW is loaded in case |
138
|
|
|
// wfLoadExtension( 'SemanticMediaWiki' ) is used |
139
|
|
|
self::checkRequirements(); |
140
|
|
|
|
141
|
|
|
$configuration = array( |
142
|
|
|
'egSWLEnableTopLink' => $GLOBALS['egSWLEnableTopLink'], |
143
|
|
|
'egSWLEnableEmailNotify' => $GLOBALS['egSWLEnableEmailNotify'], |
144
|
|
|
'egSwlSqlDatabaseSchemaPath' => $GLOBALS['egSwlSqlDatabaseSchemaPath'] |
145
|
|
|
); |
146
|
|
|
|
147
|
|
|
$hookRegistry = new HookRegistry( |
148
|
|
|
$configuration |
149
|
|
|
); |
150
|
|
|
|
151
|
|
|
$hookRegistry->register( $GLOBALS['wgHooks'] ); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
private static function checkRequirements() { |
155
|
|
|
|
156
|
|
|
if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.27', 'lt' ) ) { |
157
|
|
|
die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/SemanticWatchlist/">Semantic Watchlist</a> is only compatible with MediaWiki 1.23 or above. You need to upgrade MediaWiki first.' ); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
if ( !defined( 'SMW_VERSION' ) ) { |
161
|
|
|
die( '<b>Error:</b> <a href="https://github.com/SemanticMediaWiki/SemanticWatchlist/">Semantic Watchlist</a> requires the <a href="https://github.com/SemanticMediaWiki/SemanticMediaWiki/">Semantic MediaWiki</a> extension, please enable or install the extension first.' ); |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @since 1.2 |
167
|
|
|
* |
168
|
|
|
* @return string|null |
169
|
|
|
*/ |
170
|
|
|
public static function getVersion() { |
171
|
|
|
return SWL_VERSION; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
} |
175
|
|
|
|