MapsFunctions::getFileUrl()   A
last analyzed

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