|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class holding information and functionality specific to Leaflet. |
|
5
|
|
|
* This information and features can be used by any mapping feature. |
|
6
|
|
|
* |
|
7
|
|
|
* @licence GNU GPL v2+ |
|
8
|
|
|
* @author Pavel Astakhov < [email protected] > |
|
9
|
|
|
*/ |
|
10
|
|
|
class MapsLeaflet extends MapsMappingService { |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Constructor |
|
14
|
|
|
*/ |
|
15
|
|
|
public function __construct( $serviceName ) { |
|
16
|
|
|
parent::__construct( |
|
17
|
|
|
$serviceName, |
|
18
|
|
|
[ 'leafletmaps', 'leaflet' ] |
|
19
|
|
|
); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @see MapsMappingService::addParameterInfo |
|
24
|
|
|
* |
|
25
|
|
|
* @since 3.0 |
|
26
|
|
|
*/ |
|
27
|
|
|
public function addParameterInfo( array &$params ) { |
|
|
|
|
|
|
28
|
|
|
$params['zoom'] = [ |
|
29
|
|
|
'type' => 'integer', |
|
30
|
|
|
'range' => [ 0, 20 ], |
|
31
|
|
|
'default' => false, |
|
32
|
|
|
'message' => 'maps-par-zoom' |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
$params['defzoom'] = [ |
|
36
|
|
|
'type' => 'integer', |
|
37
|
|
|
'range' => [ 0, 20 ], |
|
38
|
|
|
'default' => self::getDefaultZoom(), |
|
39
|
|
|
'message' => 'maps-leaflet-par-defzoom' |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
$params['resizable'] = [ |
|
43
|
|
|
'type' => 'boolean', |
|
44
|
|
|
'default' => $GLOBALS['egMapsResizableByDefault'], |
|
45
|
|
|
'message' => 'maps-par-resizable' |
|
46
|
|
|
]; |
|
47
|
|
|
|
|
48
|
|
|
$params['markercluster'] = [ |
|
49
|
|
|
'type' => 'boolean', |
|
50
|
|
|
'default' => false, |
|
51
|
|
|
'message' => 'maps-par-markercluster', |
|
52
|
|
|
]; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @see iMappingService::getDefaultZoom |
|
57
|
|
|
* |
|
58
|
|
|
* @since 3.0 |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getDefaultZoom() { |
|
|
|
|
|
|
61
|
|
|
return $GLOBALS['egMapsLeafletZoom']; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @see MapsMappingService::getMapId |
|
66
|
|
|
* |
|
67
|
|
|
* @since 3.0 |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getMapId( $increment = true ) { |
|
70
|
|
|
static $mapsOnThisPage = 0; |
|
71
|
|
|
|
|
72
|
|
|
if ( $increment ) { |
|
73
|
|
|
$mapsOnThisPage++; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return 'map_leaflet_' . $mapsOnThisPage; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @see MapsMappingService::getResourceModules |
|
81
|
|
|
* |
|
82
|
|
|
* @since 3.0 |
|
83
|
|
|
* |
|
84
|
|
|
* @return array of string |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getResourceModules() { |
|
87
|
|
|
return array_merge( |
|
88
|
|
|
parent::getResourceModules(), |
|
89
|
|
|
[ 'ext.maps.leaflet' ] |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
protected function getDependencies() { |
|
|
|
|
|
|
94
|
|
|
$leafletPath = $GLOBALS['wgScriptPath'] . '/extensions/Maps/includes/services/Leaflet/leaflet'; |
|
95
|
|
|
$leafletClusterPath = $GLOBALS['wgScriptPath'] . '/extensions/Maps/includes/services/Leaflet/leaflet.markercluster'; |
|
|
|
|
|
|
96
|
|
|
return [ |
|
97
|
|
|
Html::linkedStyle( "$leafletPath/leaflet.css" ), |
|
98
|
|
|
Html::linkedScript( "$leafletPath/leaflet.js" ), |
|
99
|
|
|
//Html::linkedStyle( "$leafletClusterPath/MarkerCluster.css" ), |
|
100
|
|
|
//Html::linkedScript( "$leafletClusterPath/leaflet.markercluster.js" ), |
|
101
|
|
|
]; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: