Completed
Push — master ( 4dbba6...2bc122 )
by Jeroen De
03:56
created

MapsFunctions   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 129
ccs 32
cts 32
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getCommonParameters() 0 106 3
A getFileUrl() 0 3 1
1
<?php
2
3
namespace Maps;
4
5
/**
6
 * A class that holds static helper functions for generic mapping-related functions.
7
 *
8
 * @deprecated
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
final class MapsFunctions {
14
15
	/**
16
	 * This function returns the definitions for the parameters used by every map feature.
17
	 *
18
	 * @return array
19
	 */
20 26
	public static function getCommonParameters() {
21 26
		$params = [];
22
23 26
		$params['width'] = [
24 26
			'type' => 'dimension',
25
			'allowauto' => true,
26
			'units' => [ 'px', 'ex', 'em', '%', '' ],
27 26
			'default' => $GLOBALS['egMapsMapWidth'],
28 26
			'message' => 'maps-par-width',
29
		];
30
31 26
		$params['height'] = [
32 26
			'type' => 'dimension',
33
			'units' => [ 'px', 'ex', 'em', '' ],
34 26
			'default' => $GLOBALS['egMapsMapHeight'],
35 26
			'message' => 'maps-par-height',
36
		];
37
38 26
		$params['centre'] = [
39
			'type' => 'string',
40
			'aliases' => [ 'center' ],
41
			'default' => false,
42
			'manipulatedefault' => false,
43
			'message' => 'maps-par-centre',
44
		];
45
46 26
		$params['title'] = [
47 26
			'name' => 'title',
48 26
			'default' => $GLOBALS['egMapsDefaultTitle'],
49
		];
50
51 26
		$params['label'] = [
52 26
			'default' => $GLOBALS['egMapsDefaultLabel'],
53 26
			'aliases' => 'text',
54
		];
55
56 26
		$params['icon'] = [
57
			'default' => '',
58
		];
59
60 26
		$params['lines'] = [
61
			'type' => 'mapsline',
62
			'default' => [],
63
			'delimiter' => ';',
64
			'islist' => true,
65
		];
66
67 26
		$params['polygons'] = [
68
			'type' => 'mapspolygon',
69
			'default' => [],
70
			'delimiter' => ';',
71
			'islist' => true,
72
		];
73
74 26
		$params['circles'] = [
75
			'type' => 'mapscircle',
76
			'default' => [],
77
			'delimiter' => ';',
78
			'islist' => true,
79
		];
80
81 26
		$params['rectangles'] = [
82
			'type' => 'mapsrectangle',
83
			'default' => [],
84
			'delimiter' => ';',
85
			'islist' => true,
86
		];
87
88 26
		$params['maxzoom'] = [
89
			'type' => 'integer',
90
			'default' => false,
91
			'manipulatedefault' => false,
92
			'dependencies' => 'minzoom',
93
		];
94
95 26
		$params['minzoom'] = [
96
			'type' => 'integer',
97
			'default' => false,
98
			'manipulatedefault' => false,
99
			'lowerbound' => 0,
100
		];
101
102 26
		$params['copycoords'] = [
103
			'type' => 'boolean',
104
			'default' => false,
105
		];
106
107 26
		$params['static'] = [
108
			'type' => 'boolean',
109
			'default' => false,
110
		];
111
112
		// Give grep a chance to find the usages:
113
		// maps-displaymap-par-title, maps-displaymap-par-label, maps-displaymap-par-icon,
114
		// aps-displaymap-par-lines, maps-displaymap-par-polygons,
115
		// maps-displaymap-par-circles, maps-displaymap-par-rectangles,
116
		// maps-displaymap-par-maxzoom, maps-displaymap-par-minzoom, maps-displaymap-par-copycoords,
117
		// maps-displaymap-par-static
118 26
		foreach ( $params as $name => &$param ) {
119 26
			if ( !array_key_exists( 'message', $param ) ) {
120 26
				$param['message'] = 'maps-displaymap-par-' . $name;
121
			}
122
		}
123
124 26
		return $params;
125
	}
126
127
	/**
128
	 * Resolves the url of images provided as wiki page; leaves others alone.
129
	 *
130
	 * @since 1.0
131
	 * @deprecated
132
	 *
133
	 * @param string $file
134
	 *
135
	 * @return string
136
	 */
137 5
	public static function getFileUrl( $file ): string {
138 5
		return MapsFactory::globalInstance()->getFileUrlFinder()->getUrlForFileName( $file );
139
	}
140
141
}
142