Completed
Push — leaflet ( 284e1e...b8e3f3 )
by Jeroen De
05:53 queued 03:36
created

Leaflet.php ➔ getLeafletPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 3
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 21 and the first side effect is on line 18.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * This group contains all Leaflet related files of the Maps extension.
5
 *
6
 * @defgroup Leaflet
7
 */
8
9
/**
10
 * This file holds the hook and initialization for the Leaflet service.
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Pavel Astakhov < [email protected] >
14
 */
15
16
// Check to see if we are being called as an extension or directly
17
if ( !defined( 'MEDIAWIKI' ) ) {
18
	die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
19
}
20
21
function getLeafletPath() {
22
	if ( file_exists( __DIR__ . '/../../../vendor/drmonty/leaflet/js/leaflet.js' ) ) {
23
		return __DIR__ . '/../../../vendor/drmonty/leaflet';
24
	}
25
26
	return __DIR__ . '/../../../../../vendor/drmonty/leaflet';
27
}
28
29
call_user_func( function() {
30
	global $wgResourceModules;
31
32
	$pathParts = ( explode( DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 ) );
33
34
	$wgResourceModules['ext.maps.leaflet.core'] = [
35
		'localBasePath' => getLeafletPath(),
36
		'remoteExtPath' => '../vendor/drmonty/leaflet',
37
		'group' => 'ext.maps',
38
		'targets' => [
39
			'mobile',
40
			'desktop'
41
		],
42
		'scripts' => [
43
			"js/leaflet.js",
44
		],
45
		'styles' => [
46
			"css/leaflet.css"
47
		],
48
	];
49
50
	$wgResourceModules['ext.maps.leaflet'] = [
51
		'dependencies' => [ 'ext.maps.common', 'ext.maps.leaflet.core' ],
52
		'localBasePath' => __DIR__,
53
		'remoteExtPath' => end( $pathParts ),
54
		'group' => 'ext.maps',
55
		'targets' => [
56
			'mobile',
57
			'desktop'
58
		],
59
		'scripts' => [
60
			'jquery.leaflet.js',
61
			'ext.maps.leaflet.js',
62
		],
63
		'messages' => [
64
			'maps-markers',
65
			'maps-copycoords-prompt',
66
			'maps-searchmarkers-text',
67
		],
68
	];
69
70
	$wgResourceModules['ext.maps.leaflet.fullscreen'] = [
71
		'localBasePath' => __DIR__ . '/leaflet.fullscreen',
72
		'remoteExtPath' => end( $pathParts ) . '/leaflet.fullscreen',
73
		'group' => 'ext.maps',
74
		'targets' => [
75
			'mobile',
76
			'desktop'
77
		],
78
		'scripts' => [
79
			'Control.FullScreen.js',
80
		],
81
		'styles' => [
82
			'Control.FullScreen.css',
83
		],
84
	];
85
86
	$wgResourceModules['ext.maps.leaflet.markercluster'] = [
87
		'localBasePath' => __DIR__ . '/leaflet.markercluster',
88
		'remoteExtPath' => end( $pathParts ),
89
		'group' => 'ext.maps',
90
		'targets' => [
91
			'mobile',
92
			'desktop'
93
		],
94
		'scripts' => [
95
			'leaflet.markercluster.js',
96
		],
97
		'styles' => [
98
			'MarkerCluster.css',
99
		],
100
	];
101
102
	$wgResourceModules['ext.maps.leaflet.providers'] = [
103
		'localBasePath' => __DIR__ . '/leaflet-providers',
104
		'remoteExtPath' => end( $pathParts ) . '/leaflet-providers',
105
		'group' => 'ext.maps',
106
		'targets' => [
107
			'mobile',
108
			'desktop'
109
		],
110
		'scripts' => [
111
			'leaflet-providers.js',
112
		],
113
	];
114
} );
115