Completed
Push — master ( 684184...9a35aa )
by Jeroen De
08:07
created

includes/services/Leaflet/Leaflet.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 102 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
call_user_func( function() {
22
	global $wgHooks, $wgResourceModules;
23
24
	// Specify the function that will initialize the parser function.
25
	$wgHooks['MappingServiceLoad'][] = 'efMapsInitLeaflet';
26
27
	$pathParts = ( explode( DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 ) );
28
29
	$wgResourceModules['ext.maps.leaflet'] = [
30
		'dependencies' => [ 'ext.maps.common' ],
31
		'localBasePath' => __DIR__,
32
		'remoteExtPath' => end( $pathParts ),
33
		'group' => 'ext.maps',
34
		'targets' => [
35
			'mobile',
36
			'desktop'
37
		],
38
		'scripts' => [
39
			'jquery.leaflet.js',
40
			'ext.maps.leaflet.js',
41
		],
42
		'messages' => [
43
			'maps-markers',
44
			'maps-copycoords-prompt',
45
			'maps-searchmarkers-text',
46
		],
47
	];
48
49
	$wgResourceModules['ext.maps.leaflet.fullscreen'] = [
50
		'localBasePath' => __DIR__ . '/leaflet.fullscreen',
51
		'remoteExtPath' => end( $pathParts ) . '/leaflet.fullscreen',
52
		'group' => 'ext.maps',
53
		'targets' => [
54
			'mobile',
55
			'desktop'
56
		],
57
		'scripts' => [
58
			'Control.FullScreen.js',
59
		],
60
		'styles' => [
61
			'Control.FullScreen.css',
62
		],
63
	];
64
65
	$wgResourceModules['ext.maps.leaflet.markercluster'] = [
66
		'localBasePath' => __DIR__ . '/leaflet.markercluster',
67
		'remoteExtPath' => end( $pathParts ),
68
		'group' => 'ext.maps',
69
		'targets' => [
70
			'mobile',
71
			'desktop'
72
		],
73
		'scripts' => [
74
			'leaflet.markercluster.js',
75
		],
76
		'styles' => [
77
			'MarkerCluster.css',
78
		],
79
	];
80
81
	$wgResourceModules['ext.maps.leaflet.providers'] = [
82
		'localBasePath' => __DIR__ . '/leaflet-providers',
83
		'remoteExtPath' => end( $pathParts ) . '/leaflet-providers',
84
		'group' => 'ext.maps',
85
		'targets' => [
86
			'mobile',
87
			'desktop'
88
		],
89
		'scripts' => [
90
			'leaflet-providers.js',
91
		],
92
	];
93
} );
94
95
/**
96
 * Initialization function for the Leaflet service.
97
 *
98
 * @ingroup Leaflet
99
 *
100
 * @return boolean true
101
 */
102
function efMapsInitLeaflet() {
103
	MapsMappingServices::registerService( 'leaflet', MapsLeaflet::class );
104
	$leafletMaps = MapsMappingServices::getServiceInstance( 'leaflet' );
105
	$leafletMaps->addFeature( 'display_map', MapsDisplayMapRenderer::class );
106
107
	return true;
108
}
109