This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSummaryCards.php
132 lines (112 loc) · 2.86 KB
/
SummaryCards.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
132
<?php
use SUC\HookRegistry;
use SUC\Options;
/**
* @see https://github.com/SemanticMediaWiki/SummaryCards/
*
* @defgroup SummaryCards Summary Cards
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is part of the SummaryCards extension, it is not a valid entry point.' );
}
if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.25', 'lt' ) ) {
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.' );
}
if ( defined( 'SUC_VERSION' ) ) {
// Do not initialize more than once.
return 1;
}
SummaryCards::initExtension();
$GLOBALS['wgExtensionFunctions'][] = function() {
SummaryCards::onExtensionFunction();
};
/**
* @codeCoverageIgnore
*/
class SummaryCards {
/**
* @since 1.0
*/
public static function initExtension() {
define( 'SUC_VERSION', '1.0.0-alpha' );
// Register the extension
$GLOBALS['wgExtensionCredits']['others'][ ] = array(
'path' => __FILE__,
'name' => 'Summary Cards',
'author' => array(
'James Hong Kong'
),
'url' => 'https://github.com/SemanticMediaWiki/SummaryCards/',
'descriptionmsg' => 'suc-desc',
'version' => SUC_VERSION,
'license-name' => 'GPL-2.0-or-later',
);
// Register message files
$GLOBALS['wgMessagesDirs']['SummaryCards'] = __DIR__ . '/i18n';
$GLOBALS['wgAPIModules']['summarycards'] = '\SUC\ApiSummaryCardContentParser';
$GLOBALS['wgResourceModules']['ext.summary.cards.styles'] = array(
'styles' => 'res/ext.summaryCards.css',
'localBasePath' => __DIR__ ,
'remoteExtPath' => 'SummaryCards',
'position' => 'top',
'targets' => array(
'mobile',
'desktop'
)
);
$GLOBALS['wgResourceModules']['ext.summary.cards.tooltip'] = array(
'localBasePath' => __DIR__ ,
'remoteExtPath' => 'SummaryCards',
'position' => 'bottom',
'dependencies' => array(
'onoi.qtip',
'onoi.md5',
'onoi.blobstore',
'onoi.util'
),
'targets' => array(
'mobile',
'desktop'
)
);
$GLOBALS['wgResourceModules']['ext.summary.cards'] = array(
'scripts' => array(
'res/ext.summaryCards.js'
),
'localBasePath' => __DIR__ ,
'remoteExtPath' => 'SummaryCards',
'position' => 'bottom',
'dependencies' => array(
'mediawiki.api',
'mediawiki.api.parse',
'ext.summary.cards.styles',
'ext.summary.cards.tooltip',
),
'messages' => array(
'suc-tooltip-title',
'suc-tooltip-error'
),
'targets' => array(
'mobile',
'desktop'
)
);
}
/**
* @since 1.0
*/
public static function onExtensionFunction() {
$hookRegistry = new HookRegistry(
Options::newFromGlobals()
);
$hookRegistry->register();
}
/**
* @since 1.0
*
* @return string|null
*/
public static function getVersion() {
return SUC_VERSION;
}
}