WhatsNearby   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 101
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B initExtension() 0 77 1
A onExtensionFunction() 0 4 1
A getVersion() 0 3 1
1
<?php
2
3
use WNBY\HookRegistry;
4
5
/**
6
 * @see https://github.com/SemanticMediaWiki/WhatsNearby/
7
 * @link https://www.semantic-mediawiki.org/wiki/Extension:WhatsNearby
8
 *
9
 * @defgroup wnby WhatsNearby
10
 */
11
if ( !defined( 'MEDIAWIKI' ) ) {
12
	die( 'This file is part of the WhatsNearby extension, it is not a valid entry point.' );
13
}
14
15
if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.23', 'lt' ) ) {
16
	die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/WhatsNearby/">WhatsNearby</a> is only compatible with MediaWiki 1.23 or above. You need to upgrade MediaWiki first.' );
17
}
18
19
// Do not initialize more than once.
20
if ( defined( 'WNBY_VERSION' ) ) {
21
	return 1;
22
}
23
24
WhatsNearby::initExtension();
25
26
$GLOBALS['wgExtensionFunctions'][] = function() {
27
	WhatsNearby::onExtensionFunction();
28
};
29
30
/**
31
 * @codeCoverageIgnore
32
 */
33
class WhatsNearby {
34
35
	/**
36
	 * @since 1.0
37
	 */
38
	public static function initExtension() {
39
40
		// Load DefaultSettings
41
		require_once __DIR__ . '/DefaultSettings.php';
42
43
		define( 'WNBY_VERSION', '1.0.0-alpha' );
44
45
		$GLOBALS['wgExtensionCredits']['others'][] = array(
46
			'path'           => __FILE__,
47
			'name'           => 'Whats Nearby',
48
			'author'         => array(
49
				'James Hong Kong'
50
			),
51
			'url'            => 'https://www.semantic-mediawiki.org/wiki/Extension:WhatsNearby',
52
			'descriptionmsg' => 'wnby-desc',
53
			'version'        => WNBY_VERSION,
54
			'license-name'   => 'GPL-2.0-or-later'
55
		);
56
57
		// Register message files
58
		$GLOBALS['wgMessagesDirs']['WhatsNearby'] = __DIR__ . '/i18n';
59
		$GLOBALS['wgExtensionMessagesFiles']['WhatsNearbyMagic'] = __DIR__ . '/i18n/WhatsNearby.magic.php';
60
61
		$GLOBALS['wgResourceModules']['ext.whats.nearby.geoip'] = array(
62
			'localBasePath' => __DIR__ ,
63
			'remoteExtPath' => 'WhatsNearby',
64
			'position' => 'bottom',
65
			'scripts'  => array(
66
				'res/ext.whats.nearby.geoip.js'
67
			),
68
			'targets' => array(
69
				'mobile',
70
				'desktop'
71
			)
72
		);
73
74
		$GLOBALS['wgResourceModules']['ext.whats.nearby'] = array(
75
			'localBasePath' => __DIR__ ,
76
			'remoteExtPath' => 'WhatsNearby',
77
			'position' => 'bottom',
78
			'styles'   => array(
79
				'res/ext.whats.nearby.css'
80
			),
81
			'scripts'  => array(
82
				'res/ext.whats.nearby.js'
83
			),
84
			'dependencies'  => array(
85
				'mediawiki.api',
86
				'mediawiki.api.parse',
87
				'ext.maps.services',
88
				'onoi.rangeslider',
89
				'onoi.blockUI',
90
				'onoi.md5',
91
				'onoi.blobstore'
92
			),
93
			'messages' => array(
94
				'wnby-geolocation-disabled',
95
				'wnby-geolocation-unsupported',
96
				'wnby-geolocation-unknown-error',
97
				'wnby-geolocation-timeout-error',
98
				'wnby-geolocation-position-unavailable',
99
				'wnby-geolocation-permission-denied',
100
				'wnby-no-fallback-location',
101
				'wnby-geolocation-geoip-fallback',
102
				'wnby-geolocation-geoip-no-fallback',
103
				'wnby-default-fallback-location',
104
				'wnby-invalid-coordinates-format',
105
				'wnby-localcache-use',
106
				'wnby-template-parameter-missing',
107
				'wnby-loading'
108
			),
109
			'targets' => array(
110
				'mobile',
111
				'desktop'
112
			)
113
		);
114
	}
115
116
	/**
117
	 * @since 1.0
118
	 */
119
	public static function onExtensionFunction() {
120
		$hookRegistry = new HookRegistry();
121
		$hookRegistry->register();
122
	}
123
124
	/**
125
	 * @since 1.0
126
	 *
127
	 * @return string|null
128
	 */
129
	public static function getVersion() {
130
		return WNBY_VERSION;
131
	}
132
133
}
134