r61220 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61219‎ | r61220 | r61221 >
Date:22:56, 18 January 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.5.2.
* Fixed issue with centre parameter for maps with no results (using forceshow=on).
* Added icon parameter to the query printers, allowing you to set the icon for all markers that do not have a specific icon assigned via a compound query
Modified paths:
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -35,7 +35,7 @@
3636
3737 // Only initialize the extension when all dependencies are present.
3838 if (defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' )) {
39 - define('SM_VERSION', '0.5.2 rc1');
 39+ define('SM_VERSION', '0.5.2 rc2');
4040
4141 $smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
4242 $smgIP = $IP . '/extensions/SemanticMaps';
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php
@@ -82,7 +82,12 @@
8383 'aliases' => array('show title'),
8484 'default' => true,
8585 'output-type' => 'boolean'
86 - ),
 86+ ),
 87+ 'icon' => array(
 88+ 'criteria' => array(
 89+ 'not_empty' => array()
 90+ )
 91+ ),
8792 // SMW #Ask: parameters
8893 'limit' => array(
8994 'type' => 'integer',
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
@@ -241,11 +241,9 @@
242242 $legend_labels = array();
243243
244244 // 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+
250248 if (property_exists($display_location, 'display_options') && is_array($display_location->display_options)) {
251249 $display_options = $display_location->display_options;
252250 if (array_key_exists('icon', $display_options)) {
@@ -262,12 +260,10 @@
263261 }
264262 }
265263 // 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) );
270266 $icon = $icon_image_page->getDisplayedFile()->getURL();
271 - }
 267+ }
272268
273269 return $icon;
274270 }
@@ -293,33 +289,31 @@
294290 *
295291 */
296292 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'];
302301 }
 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+ }
303312 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+ }
324318 }
325319
326320 /**

Status & tagging log