r59551 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59550‎ | r59551 | r59552 >
Date:16:50, 29 November 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed issue with default geocoding service.
Modified paths:
  • /trunk/extensions/Maps/Geocoders/Maps_Geocoder.php (modified) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_ParamManager.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_DisplayPoint.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_DisplayPoint.php
@@ -68,7 +68,7 @@
6969 }
7070
7171 private static function initializeParams() {
72 - global $egMapsDefaultCentre, $egMapsAvailableGeoServices, $egMapsDefaultGeoService, $egMapsDefaultTitle, $egMapsDefaultLabel;
 72+ global $egMapsDefaultCentre, $egMapsDefaultTitle, $egMapsDefaultLabel;
7373
7474 self::$parameters = array_merge(MapsParserFunctions::$parameters, array(
7575 'centre' => array(
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
@@ -56,7 +56,7 @@
5757 private static function initializeParams() {
5858 global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
5959
60 - self::$parameters = array(
 60+ self::$parameters = array(
6161 'coordinates' => array(
6262 'aliases' => array('coords', 'location', 'locations'),
6363 'criteria' => array(
@@ -66,10 +66,10 @@
6767 'geoservice' => array(
6868 'aliases' => array(),
6969 'criteria' => array(
70 - 'in_array' => $egMapsAvailableGeoServices
 70+ 'in_array' => array_keys($egMapsAvailableGeoServices)
7171 ),
72 - 'default' => array($egMapsDefaultGeoService)
73 - ),
 72+ 'default' => $egMapsDefaultGeoService
 73+ ),
7474 );
7575 }
7676
Index: trunk/extensions/Maps/Maps.php
@@ -23,7 +23,7 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('Maps_VERSION', '0.5 a6');
 27+define('Maps_VERSION', '0.5 a7');
2828
2929 // Constants indicating the strictness of the parameter validation.
3030 define('Maps_ERRORS_NONE', 0);
@@ -68,7 +68,7 @@
6969 $egMapsDefaultService = in_array($egMapsDefaultService, $egMapsAvailableServices) ? $egMapsDefaultService : $egMapsAvailableServices[0];
7070 if (!in_array($egMapsDefaultGeoService, $egMapsAvailableGeoServices)) {
7171 reset($egMapsAvailableGeoServices);
72 - $egMapsDefaultGeoService = current($egMapsAvailableGeoServices);
 72+ $egMapsDefaultGeoService = key($egMapsAvailableGeoServices);
7373 }
7474
7575 wfLoadExtensionMessages( 'Maps' );
Index: trunk/extensions/Maps/Maps_ParamManager.php
@@ -95,7 +95,7 @@
9696 }
9797 }
9898
99 - return $errorList. implode($errors, '<br />') . '</i>';
 99+ return $errorList. implode($errors, '<br />') . '</i><br />';
100100 }
101101 else {
102102 return '';
Index: trunk/extensions/Maps/Geocoders/Maps_Geocoder.php
@@ -39,6 +39,7 @@
4040 * @param string $service
4141 * @param string $mappingService
4242 * @param string $format
 43+ *
4344 * @return formatted coordinate string or false
4445 */
4546 public static function geocodeToString($address, $service = '', $mappingService = '', $format = '%1$s, %2$s') {
@@ -53,6 +54,7 @@
5455 * @param string $address
5556 * @param string $service
5657 * @param string $mappingService
 58+ *
5759 * @return array with coordinates or false
5860 */
5961 public static function geocode($address, $service, $mappingService) {
@@ -89,6 +91,7 @@
9092 *
9193 * @param string $service
9294 * @param string $mappingService
 95+ *
9396 * @return string
9497 */
9598 private static function getValidGeoService($service, $mappingService) {
@@ -99,7 +102,7 @@
100103 foreach ($egMapsAvailableGeoServices as $geoService => $serviceData) {
101104 if (in_array($mappingService, $serviceData)) {
102105 $service = $geoService; // Use the override
103 - continue;
 106+ break;
104107 }
105108 }
106109
@@ -108,7 +111,7 @@
109112 }
110113 else {
111114 // If a service is provided, but is not supported, use the default.
112 - if(!array_key_exists($service, $egMapsAvailableGeoServices)) $service = $egMapsDefaultGeoService;
 115+ if(! array_key_exists($service, $egMapsAvailableGeoServices)) $service = $egMapsDefaultGeoService;
113116 }
114117
115118 return $service;

Status & tagging log