1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use SUC\HookRegistry; |
4
|
|
|
use SUC\Options; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @see https://github.com/SemanticMediaWiki/SummaryCards/ |
8
|
|
|
* |
9
|
|
|
* @defgroup SummaryCards Summary Cards |
10
|
|
|
*/ |
11
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) { |
12
|
|
|
die( 'This file is part of the SummaryCards extension, it is not a valid entry point.' ); |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.25', 'lt' ) ) { |
16
|
|
|
die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/SummaryCards/">SummaryCards</a> is only compatible with MediaWiki 1.25 or above. You need to upgrade MediaWiki first.' ); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
if ( defined( 'SUC_VERSION' ) ) { |
20
|
|
|
// Do not initialize more than once. |
21
|
|
|
return 1; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
SummaryCards::initExtension(); |
25
|
|
|
|
26
|
|
|
$GLOBALS['wgExtensionFunctions'][] = function() { |
27
|
|
|
SummaryCards::onExtensionFunction(); |
28
|
|
|
}; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @codeCoverageIgnore |
32
|
|
|
*/ |
33
|
|
|
class SummaryCards { |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @since 1.0 |
37
|
|
|
*/ |
38
|
|
|
public static function initExtension() { |
39
|
|
|
|
40
|
|
|
define( 'SUC_VERSION', '1.0.0-alpha' ); |
41
|
|
|
|
42
|
|
|
// Register the extension |
43
|
|
|
$GLOBALS['wgExtensionCredits']['others'][ ] = array( |
44
|
|
|
'path' => __FILE__, |
45
|
|
|
'name' => 'Summary Cards', |
46
|
|
|
'author' => array( |
47
|
|
|
'James Hong Kong' |
48
|
|
|
), |
49
|
|
|
'url' => 'https://github.com/SemanticMediaWiki/SummaryCards/', |
50
|
|
|
'descriptionmsg' => 'suc-desc', |
51
|
|
|
'version' => SUC_VERSION, |
52
|
|
|
'license-name' => 'GPL-2.0-or-later', |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
// Register message files |
56
|
|
|
$GLOBALS['wgMessagesDirs']['SummaryCards'] = __DIR__ . '/i18n'; |
57
|
|
|
|
58
|
|
|
$GLOBALS['wgAPIModules']['summarycards'] = '\SUC\ApiSummaryCardContentParser'; |
59
|
|
|
|
60
|
|
|
$GLOBALS['wgResourceModules']['ext.summary.cards.styles'] = array( |
61
|
|
|
'styles' => 'res/ext.summaryCards.css', |
62
|
|
|
'localBasePath' => __DIR__ , |
63
|
|
|
'remoteExtPath' => 'SummaryCards', |
64
|
|
|
'position' => 'top', |
65
|
|
|
'targets' => array( |
66
|
|
|
'mobile', |
67
|
|
|
'desktop' |
68
|
|
|
) |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$GLOBALS['wgResourceModules']['ext.summary.cards.tooltip'] = array( |
72
|
|
|
'localBasePath' => __DIR__ , |
73
|
|
|
'remoteExtPath' => 'SummaryCards', |
74
|
|
|
'position' => 'bottom', |
75
|
|
|
'dependencies' => array( |
76
|
|
|
'onoi.qtip', |
77
|
|
|
'onoi.md5', |
78
|
|
|
'onoi.blobstore', |
79
|
|
|
'onoi.util' |
80
|
|
|
), |
81
|
|
|
'targets' => array( |
82
|
|
|
'mobile', |
83
|
|
|
'desktop' |
84
|
|
|
) |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
$GLOBALS['wgResourceModules']['ext.summary.cards'] = array( |
88
|
|
|
'scripts' => array( |
89
|
|
|
'res/ext.summaryCards.js' |
90
|
|
|
), |
91
|
|
|
'localBasePath' => __DIR__ , |
92
|
|
|
'remoteExtPath' => 'SummaryCards', |
93
|
|
|
'position' => 'bottom', |
94
|
|
|
'dependencies' => array( |
95
|
|
|
'mediawiki.api', |
96
|
|
|
'mediawiki.api.parse', |
97
|
|
|
'ext.summary.cards.styles', |
98
|
|
|
'ext.summary.cards.tooltip', |
99
|
|
|
), |
100
|
|
|
'messages' => array( |
101
|
|
|
'suc-tooltip-title', |
102
|
|
|
'suc-tooltip-error' |
103
|
|
|
), |
104
|
|
|
'targets' => array( |
105
|
|
|
'mobile', |
106
|
|
|
'desktop' |
107
|
|
|
) |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @since 1.0 |
113
|
|
|
*/ |
114
|
|
|
public static function onExtensionFunction() { |
115
|
|
|
|
116
|
|
|
$hookRegistry = new HookRegistry( |
117
|
|
|
Options::newFromGlobals() |
118
|
|
|
); |
119
|
|
|
|
120
|
|
|
$hookRegistry->register(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @since 1.0 |
125
|
|
|
* |
126
|
|
|
* @return string|null |
127
|
|
|
*/ |
128
|
|
|
public static function getVersion() { |
129
|
|
|
return SUC_VERSION; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
} |
133
|
|
|
|