Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -54,9 +54,16 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | private static function initializeParams() { |
58 | | - global $egMapsAvailableGeoServices, $egMapsDefaultGeoService; |
| 58 | + global $egMapsAvailableServices, $egMapsDefaultService, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; |
59 | 59 | |
60 | 60 | self::$parameters = array( |
| 61 | + 'service' => array( |
| 62 | + 'aliases' => array(), |
| 63 | + 'criteria' => array( |
| 64 | + 'in_array' => $egMapsAvailableServices |
| 65 | + ), |
| 66 | + 'default' => $egMapsDefaultService |
| 67 | + ), |
61 | 68 | 'coordinates' => array( |
62 | 69 | 'aliases' => array('coords', 'location', 'locations'), |
63 | 70 | 'criteria' => array( |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
27 | | -define('Maps_VERSION', '0.5 a7'); |
| 27 | +define('Maps_VERSION', '0.5 a8'); |
28 | 28 | |
29 | 29 | // Constants indicating the strictness of the parameter validation. |
30 | 30 | define('Maps_ERRORS_NONE', 0); |
Index: trunk/extensions/Maps/Maps_ValidationFunctions.php |
— | — | @@ -83,6 +83,34 @@ |
84 | 84 | }
|
85 | 85 | }
|
86 | 86 | return $true;
|
87 | | - }
|
| 87 | + }
|
88 | 88 |
|
| 89 | + /**
|
| 90 | + * Returns if all items in the string are present in the array.
|
| 91 | + * The first element of the $args array should be the delimieter,
|
| 92 | + * the second one an array holding the haystack.
|
| 93 | + *
|
| 94 | + * @param string $needles
|
| 95 | + * @param array $args
|
| 96 | + *
|
| 97 | + * @return boolean
|
| 98 | + */
|
| 99 | + public static function all_str_in_array($needles, array $args) {
|
| 100 | + return self::all_in_array(explode($args[0], $needles), $args[1]);
|
| 101 | + }
|
| 102 | +
|
| 103 | + /**
|
| 104 | + * Returns if any items in the string are present in the array.
|
| 105 | + * The first element of the $args array should be the delimieter,
|
| 106 | + * the second one an array holding the haystack.
|
| 107 | + *
|
| 108 | + * @param string $needles
|
| 109 | + * @param array $args
|
| 110 | + *
|
| 111 | + * @return boolean
|
| 112 | + */
|
| 113 | + public static function any_str_in_array($needles, array $args) {
|
| 114 | + return self::any_in_array(explode($args[0], $needles), $args[1]);
|
| 115 | + }
|
| 116 | +
|
89 | 117 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps_Mapper.php |
— | — | @@ -29,13 +29,6 @@ |
30 | 30 | |
31 | 31 | self::$mainParams = array |
32 | 32 | ( |
33 | | - 'service' => array( |
34 | | - 'aliases' => array(), |
35 | | - 'criteria' => array( |
36 | | - 'in_array' => $egMapsAvailableServices |
37 | | - ), |
38 | | - 'default' => $egMapsDefaultService |
39 | | - ), |
40 | 33 | 'zoom' => array( |
41 | 34 | 'aliases' => array(), |
42 | 35 | 'criteria' => array( |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -53,26 +53,26 @@ |
54 | 54 | |
55 | 55 | $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
56 | 56 | 'zoom' => array( |
57 | | - 'default' => $egMapsGoogleMapsZoom, |
58 | | - ), |
| 57 | + 'default' => $egMapsGoogleMapsZoom, |
| 58 | + ), |
59 | 59 | 'controls' => array( |
60 | 60 | 'criteria' => array(), // TODO |
61 | 61 | 'default' => implode(',', $egMapsGMapControls) |
62 | | - ), |
| 62 | + ), |
63 | 63 | 'type' => array ( |
64 | 64 | 'aliases' => array('map-type', 'map type'), |
65 | 65 | 'criteria' => array( |
66 | | - 'in_array' => array($allowedTypes) |
| 66 | + 'in_array' => $allowedTypes |
67 | 67 | ), |
68 | 68 | 'default' => $egMapsGoogleMapsType |
69 | 69 | ), |
70 | 70 | 'types' => array ( |
71 | 71 | 'aliases' => array('map-types', 'map types'), |
72 | 72 | 'criteria' => array( |
73 | | - 'all_in_array' => array($allowedTypes) |
| 73 | + 'all_str_in_array' => array(',', $allowedTypes) |
74 | 74 | ), |
75 | 75 | 'default' => implode(',', $egMapsGoogleMapsTypes) |
76 | | - ), |
| 76 | + ), |
77 | 77 | 'autozoom' => array( |
78 | 78 | 'aliases' => array('auto zoom', 'mouse zoom', 'mousezoom'), |
79 | 79 | 'criteria' => array( |
— | — | @@ -92,51 +92,29 @@ |
93 | 93 | ), |
94 | 94 | ); |
95 | 95 | } |
96 | | - |
| 96 | + |
97 | 97 | // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP |
98 | | - // TODO: Add a true alliasing system? Might be overkill. |
99 | 98 | private static $mapTypes = array( |
100 | 99 | 'normal' => 'G_NORMAL_MAP', |
101 | | - 'G_NORMAL_MAP' => 'G_NORMAL_MAP', |
102 | | - |
103 | 100 | 'satellite' => 'G_SATELLITE_MAP', |
104 | | - 'G_SATELLITE_MAP' => 'G_SATELLITE_MAP', |
105 | | - |
106 | 101 | 'hybrid' => 'G_HYBRID_MAP', |
107 | | - 'G_HYBRID_MAP' => 'G_HYBRID_MAP', |
108 | | - |
109 | 102 | 'terrain' => 'G_PHYSICAL_MAP', |
110 | 103 | 'physical' => 'G_PHYSICAL_MAP', |
111 | | - 'G_PHYSICAL_MAP' => 'G_PHYSICAL_MAP', |
112 | | - |
113 | 104 | 'earth' => 'G_SATELLITE_3D_MAP', |
114 | | - 'G_SATELLITE_3D_MAP' => 'G_SATELLITE_3D_MAP', |
115 | | - |
116 | 105 | 'sky' => 'G_SKY_VISIBLE_MAP', |
117 | | - 'G_SKY_VISIBLE_MAP' => 'G_SKY_VISIBLE_MAP', |
118 | | - |
119 | 106 | 'moon' => 'G_MOON_VISIBLE_MAP', |
120 | | - 'G_MOON_VISIBLE_MAP' => 'G_MOON_VISIBLE_MAP', |
121 | | - |
122 | 107 | 'moon-elevation' => 'G_MOON_ELEVATION_MAP', |
123 | | - 'G_MOON_ELEVATION_MAP' => 'G_MOON_ELEVATION_MAP', |
124 | | - |
125 | 108 | 'mars' => 'G_MARS_VISIBLE_MAP', |
126 | | - 'G_MARS_VISIBLE_MAP' => 'G_MARS_VISIBLE_MAP', |
127 | | - |
128 | 109 | 'mars-elevation' => 'G_MARS_ELEVATION_MAP', |
129 | | - 'G_MARS_ELEVATION_MAP' => 'G_MARS_ELEVATION_MAP', |
130 | | - |
131 | | - 'mars-infrared' => 'G_MARS_INFRARED_MAP', |
132 | | - 'G_MARS_INFRARED_MAP' => 'G_MARS_INFRARED_MAP', |
| 110 | + 'mars-infrared' => 'G_MARS_INFRARED_MAP' |
133 | 111 | ); |
134 | | - |
| 112 | + |
135 | 113 | private static $overlayData = array( |
136 | 114 | 'photos' => '0', |
137 | 115 | 'videos' => '1', |
138 | 116 | 'wikipedia' => '2', |
139 | 117 | 'webcams' => '3' |
140 | | - ); |
| 118 | + ); |
141 | 119 | |
142 | 120 | /** |
143 | 121 | * Returns the names of all supported map types. |
— | — | @@ -146,7 +124,7 @@ |
147 | 125 | public static function getTypeNames() { |
148 | 126 | return array_keys(self::$mapTypes); |
149 | 127 | } |
150 | | - |
| 128 | + |
151 | 129 | /** |
152 | 130 | * Returns the Google Map type (defined in MapsGoogleMaps::$mapTypes) |
153 | 131 | * for the provided a general map type. When no match is found, false |
— | — | @@ -182,12 +160,12 @@ |
183 | 161 | public static function addGMapDependencies(&$output) { |
184 | 162 | global $wgJsMimeType, $wgLang; |
185 | 163 | global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage, $egMapsStyleVersion; |
186 | | - |
| 164 | + |
187 | 165 | if (empty($egGoogleMapsOnThisPage)) { |
188 | 166 | $egGoogleMapsOnThisPage = 0; |
189 | 167 | |
190 | 168 | MapsGoogleMaps::validateGoogleMapsKey(); |
191 | | - |
| 169 | + |
192 | 170 | // TODO: use strbuilder for performance gain? |
193 | 171 | $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script> |
194 | 172 | <script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions.js?$egMapsStyleVersion'></script> |
Index: trunk/extensions/Maps/Maps_ParamValidator.php |
— | — | @@ -46,6 +46,8 @@ |
47 | 47 | 'not_empty' => array('MapsValidationFunctions', 'not_empty'), |
48 | 48 | 'all_in_array' => array('MapsValidationFunctions', 'all_in_array'), |
49 | 49 | 'any_in_array' => array('MapsValidationFunctions', 'any_in_array'), |
| 50 | + 'all_str_in_array' => array('MapsValidationFunctions', 'all_str_in_array'), |
| 51 | + 'any_str_in_array' => array('MapsValidationFunctions', 'any_str_in_array'), |
50 | 52 | ); |
51 | 53 | |
52 | 54 | private $parameterInfo; |