Completed
Push — master ( 107e98...308e27 )
by Jeroen De
02:59
created

LeafletService::getAliases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Maps;
4
5
use Html;
6
7
/**
8
 * @licence GNU GPL v2+
9
 */
10
class LeafletService extends MappingService {
0 ignored issues
show
Deprecated Code introduced by
The class Maps\MappingService has been deprecated.

This class, trait or interface has been deprecated.

Loading history...
11
12 13
	public function getName(): string {
13 13
		return 'leaflet';
14
	}
15
16 20
	public function getAliases(): array {
17 20
		return [ 'leafletmaps', 'leaflet' ]; // TODO: main name should not be in here?
18
	}
19
20 1
	public function hasAlias( string $alias ): bool {
21 1
		return in_array( $alias, [ 'leafletmaps', 'leaflet' ] );
22
	}
23
24 13
	public function getParameterInfo(): array {
25 13
		global $GLOBALS;
26
27 13
		$params = [];
28
29 13
		$params['zoom'] = [
30
			'type' => 'integer',
31
			'range' => [ 0, 20 ],
32
			'default' => false,
33
			'message' => 'maps-par-zoom'
34
		];
35
36 13
		$params['defzoom'] = [
37 13
			'type' => 'integer',
38
			'range' => [ 0, 20 ],
39 13
			'default' => self::getDefaultZoom(),
40 13
			'message' => 'maps-leaflet-par-defzoom'
41
		];
42
43 13
		$params['layers'] = [
44 13
			'aliases' => 'layer',
45 13
			'type' => 'string',
46 13
			'values' => array_keys( $GLOBALS['egMapsLeafletAvailableLayers'], true, true ),
47 13
			'default' => $GLOBALS['egMapsLeafletLayers'],
48 13
			'message' => 'maps-leaflet-par-layers',
49
			'islist' => true,
50
		];
51
52 13
		$params['overlaylayers'] = [
53 13
			'type' => 'string',
54 13
			'values' => array_keys( $GLOBALS['egMapsLeafletAvailableOverlayLayers'], true, true ),
55 13
			'default' => $GLOBALS['egMapsLeafletOverlayLayers'],
56 13
			'message' => 'maps-leaflet-par-overlaylayers',
57
			'islist' => true,
58
		];
59
60 13
		$params['resizable'] = [
61 13
			'type' => 'boolean',
62 13
			'default' => $GLOBALS['egMapsResizableByDefault'],
63 13
			'message' => 'maps-par-resizable'
64
		];
65
66 13
		$params['enablefullscreen'] = [
67
			'type' => 'boolean',
68
			'default' => false,
69
			'message' => 'maps-par-enable-fullscreen',
70
		];
71
72 13
		$params['scrollwheelzoom'] = [
73
			'type' => 'boolean',
74
			'default' => true,
75
			'message' => 'maps-par-scrollwheelzoom',
76
		];
77
78 13
		$params['markercluster'] = [
79
			'type' => 'boolean',
80
			'default' => false,
81
			'message' => 'maps-par-markercluster',
82
		];
83
84 13
		$params['clustermaxzoom'] = [
85
			'type' => 'integer',
86
			'default' => 20,
87
			'message' => 'maps-par-clustermaxzoom',
88
		];
89
90 13
		$params['clusterzoomonclick'] = [
91
			'type' => 'boolean',
92
			'default' => true,
93
			'message' => 'maps-par-clusterzoomonclick',
94
		];
95
96 13
		$params['clustermaxradius'] = [
97
			'type' => 'integer',
98
			'default' => 80,
99
			'message' => 'maps-par-maxclusterradius',
100
		];
101
102 13
		$params['clusterspiderfy'] = [
103
			'type' => 'boolean',
104
			'default' => true,
105
			'message' => 'maps-leaflet-par-clusterspiderfy',
106
		];
107
108 13
		$params['geojson'] = [
109
			'type' => 'jsonfile',
110
			'default' => '',
111
			'message' => 'maps-displaymap-par-geojson',
112
		];
113
114 13
		return $params;
115
	}
116
117
	/**
118
	 * @since 3.0
119
	 */
120 13
	public function getDefaultZoom() {
121 13
		return $GLOBALS['egMapsLeafletZoom'];
122
	}
123
124 13
	public function getMapId(): string {
125 13
		static $mapsOnThisPage = 0;
126
127 13
		$mapsOnThisPage++;
128
129 13
		return 'map_leaflet_' . $mapsOnThisPage;
130
	}
131
132 13
	public function getResourceModules(): array {
133 13
		return [ 'ext.maps.leaflet', 'ext.sm.fi.leafletajax' ];
134
	}
135
136 13
	protected function getDependencies() {
137 13
		$leafletPath = $GLOBALS['wgScriptPath'] . '/extensions/Maps/resources/leaflet/leaflet';
138
		return [
139 13
			Html::linkedStyle( "$leafletPath/leaflet.css" ),
140 13
			Html::linkedScript( "$leafletPath/leaflet.js" ),
141
		];
142
	}
143
144
}
145