forked from SemanticMediaWiki/SemanticMetaTags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SemanticMetaTags.php
99 lines (77 loc) · 2.56 KB
/
SemanticMetaTags.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
<?php
use SMT\HookRegistry;
use SMT\Options;
use SMW\ApplicationFactory;
/**
* @see https://github.com/SemanticMediaWiki/SemanticMetaTags/
*
* @defgroup SMT Semantic Meta Tags
*/
SemanticMetaTags::load();
/**
* @codeCoverageIgnore
*/
class SemanticMetaTags {
/**
* @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() {
if ( !defined( 'MEDIAWIKI' ) ) {
return;
}
// Load DefaultSettings
require_once __DIR__ . '/DefaultSettings.php';
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( 'SMT_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' );
// Register message files
$GLOBALS['wgMessagesDirs']['SemanticMetaTags'] = __DIR__ . '/i18n';
}
/**
* @since 1.4
*/
public static function doCheckRequirements() {
if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.27', 'lt' ) ) {
die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/SemanticMetaTags/">SemanticMetaTags</a> is only compatible with MediaWiki 1.27 or above. You need to upgrade MediaWiki first.' );
}
}
/**
* @since 1.0
*/
public static function onExtensionFunction() {
if ( !defined( 'SMW_VERSION' ) ) {
if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
die( "\nThe 'Semantic Meta Tags' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" );
} else {
die(
'<b>Error:</b> The <a href="https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Meta_Tags">Semantic Meta Tags</a> ' .
'extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be ' .
'installed and enabled.<br>'
);
}
}
$configuration = [
'metaTagsContentPropertySelector' => $GLOBALS['smtgTagsProperties'],
'metaTagsStaticContentDescriptor' => $GLOBALS['smtgTagsStrings'],
'metaTagsBlacklist' => $GLOBALS['smtgTagsBlacklist'],
'metaTagsFallbackUseForMultipleProperties' => $GLOBALS['smtgTagsPropertyFallbackUsage'],
'metaTagsMetaPropertyPrefixes' => $GLOBALS['smtgMetaPropertyPrefixes']
];
$hookRegistry = new HookRegistry(
ApplicationFactory::getInstance()->getStore(),
new Options( $configuration )
);
$hookRegistry->register();
}
}