Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | // Only initialize the extension when all dependencies are present. |
38 | 38 | if (defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' )) { |
39 | | - define('SM_VERSION', '0.5.2 rc1'); |
| 39 | + define('SM_VERSION', '0.5.2 rc2'); |
40 | 40 | |
41 | 41 | $smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps'; |
42 | 42 | $smgIP = $IP . '/extensions/SemanticMaps'; |
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php |
— | — | @@ -82,7 +82,12 @@ |
83 | 83 | 'aliases' => array('show title'), |
84 | 84 | 'default' => true, |
85 | 85 | 'output-type' => 'boolean' |
86 | | - ), |
| 86 | + ), |
| 87 | + 'icon' => array( |
| 88 | + 'criteria' => array( |
| 89 | + 'not_empty' => array() |
| 90 | + ) |
| 91 | + ), |
87 | 92 | // SMW #Ask: parameters |
88 | 93 | 'limit' => array( |
89 | 94 | 'type' => 'integer', |
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php |
— | — | @@ -241,11 +241,9 @@ |
242 | 242 | $legend_labels = array(); |
243 | 243 | |
244 | 244 | // Look for display_options field, which can be set by Semantic Compound Queries |
245 | | - // the location of this field changed in SMW 1.5 |
246 | | - if (method_exists($row[0], 'getResultSubject')) // SMW 1.5+ |
247 | | - $display_location = $row[0]->getResultSubject(); |
248 | | - else |
249 | | - $display_location = $row[0]; |
| 245 | + // the location of this field changed in SMW 1.5 |
| 246 | + $display_location = method_exists($row[0], 'getResultSubject') ? $display_location = $row[0]->getResultSubject() : $row[0]; |
| 247 | + |
250 | 248 | if (property_exists($display_location, 'display_options') && is_array($display_location->display_options)) { |
251 | 249 | $display_options = $display_location->display_options; |
252 | 250 | if (array_key_exists('icon', $display_options)) { |
— | — | @@ -262,12 +260,10 @@ |
263 | 261 | } |
264 | 262 | } |
265 | 263 | // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here |
266 | | - } elseif (array_key_exists('icon', $this->m_params)) { |
267 | | - |
268 | | - $icon_title = Title::newFromText($this->m_params['icon']); |
269 | | - $icon_image_page = new ImagePage($icon_title); |
| 264 | + } elseif (strlen($this->icon) > 0) { |
| 265 | + $icon_image_page = new ImagePage( Title::newFromText($this->icon) ); |
270 | 266 | $icon = $icon_image_page->getDisplayedFile()->getURL(); |
271 | | - } |
| 267 | + } |
272 | 268 | |
273 | 269 | return $icon; |
274 | 270 | } |
— | — | @@ -293,33 +289,31 @@ |
294 | 290 | * |
295 | 291 | */ |
296 | 292 | private function setCentre() { |
297 | | - // If there are no results, centre on the default coordinates. |
298 | | - if ( count($this->m_locations) < 1 ) { |
299 | | - global $egMapsMapLat, $egMapsMapLon; |
300 | | - $this->centre_lat = $egMapsMapLat; |
301 | | - $this->centre_lon = $egMapsMapLon; |
| 293 | + // If a centre value is set, use it. |
| 294 | + if (strlen($this->centre) > 0) { |
| 295 | + // Geocode and convert if required. |
| 296 | + $centre = MapsGeocodeUtils::attemptToGeocode($this->centre, $this->geoservice, $this->serviceName); |
| 297 | + $centre = MapsUtils::getLatLon($centre); |
| 298 | + |
| 299 | + $this->centre_lat = $centre['lat']; |
| 300 | + $this->centre_lon = $centre['lon']; |
302 | 301 | } |
| 302 | + elseif (count($this->m_locations) > 1) { |
| 303 | + // If centre is not set, and there are multiple points, set the values to null, to be auto determined by the JS of the mapping API. |
| 304 | + $this->centre_lat = 'null'; |
| 305 | + $this->centre_lon = 'null'; |
| 306 | + } |
| 307 | + elseif (count($this->m_locations) == 1) { |
| 308 | + // If centre is not set and there is exactelly one marker, use it's coordinates. |
| 309 | + $this->centre_lat = $this->m_locations[0][0]; |
| 310 | + $this->centre_lon = $this->m_locations[0][1]; |
| 311 | + } |
303 | 312 | else { |
304 | | - // If a centre value is set, use it. |
305 | | - if (strlen($this->centre) > 0) { |
306 | | - // Geocode and convert if required. |
307 | | - $centre = MapsGeocodeUtils::attemptToGeocode($this->centre, $this->geoservice, $this->serviceName); |
308 | | - $centre = MapsUtils::getLatLon($centre); |
309 | | - |
310 | | - $this->centre_lat = $centre['lat']; |
311 | | - $this->centre_lon = $centre['lon']; |
312 | | - } |
313 | | - elseif (count($this->m_locations) > 1) { |
314 | | - // If centre is not set, and there are multiple points, set the values to null, to be auto determined by the JS of the mapping API. |
315 | | - $this->centre_lat = 'null'; |
316 | | - $this->centre_lon = 'null'; |
317 | | - } |
318 | | - else { |
319 | | - // If centre is not set and there is exactelly one marker, use it's coordinates. |
320 | | - $this->centre_lat = $this->m_locations[0][0]; |
321 | | - $this->centre_lon = $this->m_locations[0][1]; |
322 | | - } |
323 | | - } |
| 313 | + // If centre is not set and there are no results, centre on the default coordinates. |
| 314 | + global $egMapsMapLat, $egMapsMapLon; |
| 315 | + $this->centre_lat = $egMapsMapLat; |
| 316 | + $this->centre_lon = $egMapsMapLon; |
| 317 | + } |
324 | 318 | } |
325 | 319 | |
326 | 320 | /** |