http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54803

Revision: 54803
Author:   jeroendedauw
Date:     2009-08-11 18:36:33 +0000 (Tue, 11 Aug 2009)

Log Message:
-----------
Changes for 0.3

Modified Paths:
--------------
    trunk/extensions/Maps/Maps.i18n.php
    trunk/extensions/Maps/Maps.php
    trunk/extensions/Maps/Maps_BaseMap.php
    trunk/extensions/Maps/Maps_Geocoder.php
    trunk/extensions/Maps/Maps_MapFeature.php
    trunk/extensions/Maps/Maps_Mapper.php
    trunk/extensions/Maps/Maps_ParserFunctions.php

Modified: trunk/extensions/Maps/Maps.i18n.php
===================================================================
--- trunk/extensions/Maps/Maps.i18n.php 2009-08-11 18:29:33 UTC (rev 54802)
+++ trunk/extensions/Maps/Maps.i18n.php 2009-08-11 18:36:33 UTC (rev 54803)
@@ -1,4 +1,4 @@
-<?php
+<?php
 
 /**
  * Internationalization file for the Maps extension
@@ -18,6 +18,10 @@
        'maps_name' => 'Maps',
        'maps_desc' => "Provides the ability to display coordinate data in 
maps, and geocode addresses ([http://wiki.bn2vs.com/wiki/Maps demo]).
 Available mapping services: $1",
+
+       'maps_coordinates_missing' => 'No coordinates provided for the map.',
+       'maps_geocoding_failed' => 'Geocoding of the provided addresses failed. 
The map can not be displayed.',
+       'maps_geocoding_failed_for' => 'Geocoding of some of the provided 
addresses failed, causing these to be omitted from the map. Omitted results: 
$1',
 );
 
 /** Message documentation (Message documentation)

Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php      2009-08-11 18:29:33 UTC (rev 54802)
+++ trunk/extensions/Maps/Maps.php      2009-08-11 18:36:33 UTC (rev 54803)
@@ -10,6 +10,15 @@
  * @author Jeroen De Dauw
  */
 
+/**
+ * This documenation group collects source code files belonging to Maps.
+ *
+ * Please do not use this group name for other code. If you have an extension 
to 
+ * Maps, please use your own group defenition.
+ * 
+ * @defgroup Maps Maps
+ */
+
 if( !defined( 'MEDIAWIKI' ) ) {
        die( 'Not an entry point.' );
 }
@@ -132,17 +141,17 @@
        global $wgParser;
        
        // A hooks to enable the '#display_point' and '#display_points' parser 
functions
-       $wgParser->setFunctionHook( 'display_point', 
array('MapsParserFunctions', 'displayPointRender' ));
-       $wgParser->setFunctionHook( 'display_points', 
array('MapsParserFunctions', 'displayPointsRender' ));
+       $wgParser->setFunctionHook( 'display_point', 
array('MapsParserFunctions', 'displayPointRender') );
+       $wgParser->setFunctionHook( 'display_points', 
array('MapsParserFunctions', 'displayPointsRender') );
 
        // A hooks to enable the '#display_adress' and '#display_adresses' 
parser functions
-       $wgParser->setFunctionHook( 'display_address', 
array('MapsParserFunctions', 'displayAddressRender' ));
-       $wgParser->setFunctionHook( 'display_addresses', 
array('MapsParserFunctions', 'displayAddressesRender' ));
+       $wgParser->setFunctionHook( 'display_address', 
array('MapsParserFunctions', 'displayAddressRender') );
+       $wgParser->setFunctionHook( 'display_addresses', 
array('MapsParserFunctions', 'displayAddressesRender') );
 
        // A hook to enable the geocoder parser functions
-       $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 
'renderGeocoder' ));
-       $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 
'renderGeocoderLat' ));
-       $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 
'renderGeocoderLng' ));
+       $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 
'renderGeocoder') );
+       $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 
'renderGeocoderLat') );
+       $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 
'renderGeocoderLng') );
 }
 
 /**

Modified: trunk/extensions/Maps/Maps_BaseMap.php
===================================================================
--- trunk/extensions/Maps/Maps_BaseMap.php      2009-08-11 18:29:33 UTC (rev 
54802)
+++ trunk/extensions/Maps/Maps_BaseMap.php      2009-08-11 18:36:33 UTC (rev 
54803)
@@ -15,7 +15,7 @@
 
 abstract class MapsBaseMap extends MapsMapFeature {
        
-       // TODO: move this abstract function to a new MApsBaseMapUtils file?
+       // TODO: move this abstract function to a new MapsBaseMapUtils file?
        //protected abstract static function getDefaultParams();
        
        protected $markerData = array();
@@ -28,7 +28,7 @@
         * @param unknown_type $map
         * @return unknown
         */
-       public final function displayMap(&$parser, $map) {              
+       public final function displayMap($map) {                
                $this->setMapSettings();
                
                $this->doMapServiceLoad();
@@ -72,7 +72,7 @@
         *
         */
        private function setCoordinates() {
-               $this->coordinates = explode(';', $this->coordinates);
+               $this->coordinates = explode(';', $this->coordinates);          
                
                foreach($this->coordinates as $coordinates) {
                        $args = explode('~', $coordinates);

Modified: trunk/extensions/Maps/Maps_Geocoder.php
===================================================================
--- trunk/extensions/Maps/Maps_Geocoder.php     2009-08-11 18:29:33 UTC (rev 
54802)
+++ trunk/extensions/Maps/Maps_Geocoder.php     2009-08-11 18:36:33 UTC (rev 
54803)
@@ -19,32 +19,89 @@
 }
 
 final class MapsGeocoder {
-       // TODO: some refactoring: the arrays containing the result should be 
generalized - currently only logical for the Google Geocoder service
+
+       /**
+        * Holds if geocoded data should be cached or not.
+        *
+        * @var boolean
+        */
+       private static $mEnableCache = true;
        
-       private static $mEnableCache = true;
+       /**
+        * The geocoder cache, holding geocoded data when enabled.
+        *
+        * @var array
+        */
        private static $mGeocoderCache = array();
 
+       /**
+        * Handler for the geocode parser function. Returns the latitude and 
longitude
+        * for the provided address, or an empty string, when the geocoding 
fails.
+        *
+        * @param unknown_type $parser
+        * @param string $address The address to geocode.
+        * @param string $service Optional. The geocoding service to use.
+        * @param string $mappingService Optional. The mapping service that 
will use the geocoded data.
+        * @return string
+        */
        public static function renderGeocoder($parser, $address, $service = '', 
$mappingService = '') {
                $geovalues = MapsGeocoder::geocode($address, $service, 
$mappingService);
                return $geovalues ? $geovalues['lat'].', '.$geovalues['lon'] : 
'';
        }
 
+       /**
+        * Handler for the geocode parser function. Returns the latitude
+        * for the provided address, or an empty string, when the geocoding 
fails.
+        *
+        * @param unknown_type $parser
+        * @param string $address The address to geocode.
+        * @param string $service Optional. The geocoding service to use.
+        * @param string $mappingService Optional. The mapping service that 
will use the geocoded data.
+        * @return string
+        */     
        public static function renderGeocoderLat(&$parser, $address, $service = 
'', $mappingService = '') {
                $geovalues = MapsGeocoder::geocode($address, $service, 
$mappingService);
                return $geovalues ? $geovalues['lat'] : '';
        }
-
+       
+       /**
+        * Handler for the geocode parser function. Returns the longitude
+        * for the provided address, or an empty string, when the geocoding 
fails.
+        *
+        * @param unknown_type $parser
+        * @param string $address The address to geocode.
+        * @param string $service Optional. The geocoding service to use.
+        * @param string $mappingService Optional. The mapping service that 
will use the geocoded data.
+        * @return string
+        */     
        public static function renderGeocoderLng(&$parser, $address, $service = 
'', $mappingService = '') {
                $geovalues = MapsGeocoder::geocode($address, $service, 
$mappingService);
                return $geovalues ? $geovalues['lon'] : '';
        }
+       
+       /**
+        * Geocodes an address with the provided geocoding service and returns 
the result 
+        * as a string with the optionally provided format, or false when the 
geocoding failed.
+        * 
+        * @param string $address
+        * @param string $service
+        * @param string $mappingService
+        * @param string $format
+        * @return formatted coordinate string or false
+        */
+       public static function geocodeToString($address, $service = '', 
$mappingService = '', $format = '%1$s, %2$s') {
+               $geovalues = MapsGeocoder::geocode($address, $service, 
$mappingService);
+               return $geovalues ? sprintf($format, $geovalues['lat'], 
$geovalues['lon']) : false;
+       }
 
        /**
-        * Geocode an address with the provided geocoding service
+        * Geocodes an address with the provided geocoding service and returns 
the result 
+        * as an array, or false when the geocoding failed.
         *
-        * @param unknown_type $address
-        * @param unknown_type $service
-        * @return unknown
+        * @param string $address
+        * @param string $service
+        * @param string $mappingService
+        * @return array with coordinates or false
         */
        private static function geocode($address, $service, $mappingService) {
                global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
@@ -54,8 +111,10 @@
                        return self::$mGeocoderCache[$address];
                }
                
+               $coordinates = false;
+               
                $service = self::getValidGeoService($service, $mappingService);
-
+               
                // If not, use the selected geocoding service to geocode the 
provided adress
                switch(strtolower($service)) {
                        case 'yahoo':
@@ -69,23 +128,31 @@
                }
 
                // Add the obtained coordinates to the cache when there is a 
result and the cache is enabled
-               if (self::$mEnableCache && isset($coordinates)) {
+               if (self::$mEnableCache && $coordinates) {
                        MapsGeocoder::$mGeocoderCache[$address] = $coordinates;
                }
 
                return $coordinates;
        }
 
+       /**
+        * Add a geocoder class to the $wgAutoloadClasses array when it's not 
present yet.
+        *
+        * @param string $className
+        * @param string $fileName
+        */
        private static function addAutoloadClassIfNeeded($className, $fileName) 
{
                global $wgAutoloadClasses, $egMapsIP;
                if (!array_key_exists($className, $wgAutoloadClasses)) 
$wgAutoloadClasses[$className] = $egMapsIP . '/Geocoders/' . $fileName;
        }
        
        /**
-        * Make sure that the geo service is one of the available
+        * Makes sure that the geo service is one of the available ones.
+        * Also enforces licencing restrictions when no geocoding service is 
explicitly provided.
         *
-        * @param unknown_type $service
-        * @return unknown
+        * @param string $service
+        * @param string $mappingService
+        * @return string
         */
        private static function getValidGeoService($service, $mappingService) {
                global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;

Modified: trunk/extensions/Maps/Maps_MapFeature.php
===================================================================
--- trunk/extensions/Maps/Maps_MapFeature.php   2009-08-11 18:29:33 UTC (rev 
54802)
+++ trunk/extensions/Maps/Maps_MapFeature.php   2009-08-11 18:36:33 UTC (rev 
54803)
@@ -63,7 +63,7 @@
                // Go through the array with map parameters and create new 
variables
                // with the name of the key and value of the item if they don't 
exist on class level yet.
                foreach($mapProperties as $paramName => $paramValue) {
-                       if (!property_exists($className, $paramName)) {
+                       if (! property_exists($className, $paramName)) {
                                $this->{$paramName} = $paramValue;
                        }
                }

Modified: trunk/extensions/Maps/Maps_Mapper.php
===================================================================
--- trunk/extensions/Maps/Maps_Mapper.php       2009-08-11 18:29:33 UTC (rev 
54802)
+++ trunk/extensions/Maps/Maps_Mapper.php       2009-08-11 18:36:33 UTC (rev 
54803)
@@ -24,7 +24,7 @@
        private static $mainParams = array
                        (
                        'service' => array(),
-                       'coordinates' => array('coords', 'location'),
+                       'coordinates' => array('coords', 'location', 
'locations'),
                        'zoom' => array(),
                        'centre' => array('center'),
                        'width' => array(),
@@ -35,6 +35,71 @@
                        );
        
        /**
+        * Gets if a provided name is present in the aliases array of a 
parameter
+        * name in the $mainParams array.
+        *
+        * @param string $name
+        * @param string $mainParamName
+        * @param string $compareMainName
+        * @return boolean
+        */
+       public static function inParamAliases($name, $mainParamName, 
$compareMainName = true) {
+               $equals = $compareMainName && $mainParamName = $name;
+               
+               if (array_key_exists($mainParamName, self::$mainParams)) {
+                       $equals = $equals || in_array($name, 
self::$mainParams[$mainParamName]);
+               }
+               
+               return $equals;
+       }
+       
+       /**
+        * Gets if a parameter is present as key in the $stack. Also checks for
+        * the presence of aliases in the $mainParams array unless specified 
not to.
+        *
+        * @param string $paramName
+        * @param array $stack
+        * @param boolean $checkForAliases
+        * @return boolean
+        */             
+       public static function paramIsPresent($paramName, array $stack, 
$checkForAliases = true) {
+               $isPresent = array_key_exists($paramName, $stack);
+               
+               if ($checkForAliases) {
+                       foreach(self::$mainParams[$paramName] as $alias) {
+                               if (array_key_exists($alias, $stack)) 
$isPresent = true;
+                       }
+               }
+               
+               return $isPresent;
+       }                       
+       
+       /**
+        * Returns the value of a parameter represented as key in the $stack.
+        * Also checks for the presence of aliases in the $mainParams array
+        * and returns the value of the alies unless specified not to. When
+        * no array key name match is found, false will be returned.
+        *
+        * @param string $paramName
+        * @param array $stack
+        * @param boolean $checkForAliases
+        * @return the parameter value or false
+        */
+       public static function getParamValue($paramName, array $stack, 
$checkForAliases = true) {
+               $paramValue = false;
+               
+               if (array_key_exists($paramName, $stack)) $paramValue = 
$stack[$paramName];
+               
+               if ($checkForAliases) {
+                       foreach(self::$mainParams[$paramName] as $alias) {
+                               if (array_key_exists($alias, $stack)) 
$paramValue = $stack[$alias];
+                       }
+               }
+               
+               return $paramValue;             
+       }
+                       
+       /**
         * Sets the default map properties and returns the new array.
         * This function also ensures all the properties are present, even when 
being empty,
         * which is important for the weakly typed classes using them.
@@ -115,16 +180,14 @@
         * @param array $serviceParameters
         * @return array
         */
-       public static function getValidParams(array $paramz, array 
$serviceParameters) {
+       public static function getValidParams(array $paramz, array 
$serviceParameters, $strict = true) {
                $validParams = array();
                
                $allowedParms = array_merge(self::$mainParams, 
$serviceParameters);
                
                foreach($paramz as $paramName => $paramValue) {         
-                       //echo "$paramName ->into-> ";
                        $paramName = self::getMainParamName($paramName, 
$allowedParms);
-                       //echo "$paramName ,withval, "; var_dump($paramValue); 
echo " <br />\n";
-                       if(array_key_exists($paramName, $allowedParms)) 
$validParams[$paramName] = $paramValue;
+                       if(array_key_exists($paramName, $allowedParms) || 
!$strict) $validParams[$paramName] = $paramValue;
                }
                
                return $validParams;            
@@ -139,7 +202,6 @@
         * @return string
         */
        private static function getMainParamName($paramName, array 
$allowedParms) {
-               //echo "$paramName -> ";
                if (!array_key_exists($paramName, $allowedParms)) {
                        foreach ($allowedParms as $name => $aliases) {
                                if (in_array($paramName, $aliases)) {
@@ -147,7 +209,6 @@
                                }
                        }
                }
-               //echo "$paramName<br />";
                return $paramName;
        }               
                
@@ -162,7 +223,7 @@
                global $egMapsAvailableServices, $egMapsDefaultService;
                
                $service = self::getMainServiceName($service);
-               if(!in_array($service, $egMapsAvailableServices)) $service = 
$egMapsDefaultService;
+               if(! in_array($service, $egMapsAvailableServices)) $service = 
$egMapsDefaultService;
                
                return $service;
        }
@@ -177,7 +238,7 @@
        public static function getMainServiceName($service) {
                global $egMapsServices;
                
-               if (!array_key_exists($service, $egMapsServices)) {
+               if (! array_key_exists($service, $egMapsServices)) {
                        foreach ($egMapsServices as $serviceName => 
$serviceInfo) {
                                if (in_array($service, 
$serviceInfo['aliases'])) {
                                         $service = $serviceName;
@@ -188,13 +249,22 @@
                return $service;
        }
        
-       public static function getValidTypes($types, &$defaults, 
&$defaultsAreValid, $validationFunction) {
+       /**
+        * Returns a valid version of the types.
+        *
+        * @param array $types
+        * @param array $defaults
+        * @param boolean $defaultsAreValid
+        * @param function $validationFunction
+        * @return array
+        */
+       public static function getValidTypes(array $types, array &$defaults, 
&$defaultsAreValid, $validationFunction) {
                $validTypes = array();
+               $phpAtLeast523 = MapsMapper::phpVersionIsEqualOrBigger('5.2.3');
                
                // Ensure every type is valid and uses the relevant map API's 
name.
                for($i = 0 ; $i < count($types); $i++) {
-                       // TODO: make copatible with php version that not 
support notation?
-                       $type = call_user_func($validationFunction, $types[$i]);
+                       $type = call_user_func($validationFunction, 
$phpAtLeast523 ? $types[$i] : array($types[$i]));
                        if ($type) $validTypes[] = $type; 
                }
                
@@ -208,8 +278,7 @@
                        // ensure every type is valid and uses the relevant map 
API's name.
                        if (empty($defaultsAreValid)) {
                                for($i = 0 ; $i < count($defaults); $i++) {
-                                       // TODO: make copatible with php 
version that not support notation?
-                                       $type = 
call_user_func($validationFunction, $defaults[$i]);
+                                       $type = 
call_user_func($validationFunction, $phpAtLeast523 ? $defaults[$i] : 
array($defaults[$i]));
                                        if ($type) $validTypes[] = $type; 
                                }
                                
@@ -222,4 +291,26 @@
 
                return $types;
        }
+       
+       /**
+        * Returns if the current php version is equal of bigger then the 
provided one.
+        *
+        * @param string $requiredVersion
+        * @return boolean
+        */
+       private static function phpVersionIsEqualOrBigger($requiredVersion) {
+               // TODO: Ensure this works, and does not cause errors for some 
versions.
+               $currentVersion = phpversion();
+
+               for($i = 0; $i < 3; $i++) {
+                       if ($currentVersion[$i] < $requiredVersion[$i]) {
+                               return false; 
+                       }
+                       else if($currentVersion[$i] > $requiredVersion[$i]) {
+                               return true;
+                       } 
+               }
+               
+               return true;
+       }
 }

Modified: trunk/extensions/Maps/Maps_ParserFunctions.php
===================================================================
--- trunk/extensions/Maps/Maps_ParserFunctions.php      2009-08-11 18:29:33 UTC 
(rev 54802)
+++ trunk/extensions/Maps/Maps_ParserFunctions.php      2009-08-11 18:36:33 UTC 
(rev 54803)
@@ -16,21 +16,9 @@
 
 final class MapsParserFunctions {
 
-       /**
-        * Sets the default map properties, gets the map HTML depending 
-        * on the provided service, and then returns it.
-        *
-        * @param unknown_type $parser
-        * @return array
-        */
-       public static function displayPointRender(&$parser) {
+       private static function getMapHtml(array $params, array $coordFails = 
array()) {
                global $egMapsServices;
                
-               $params = func_get_args();
-               array_shift( $params ); // We already know the $parser ...
-               
-               if (is_array($params[0])) $params = $params[0];
-                               
                $map = array();
                
                foreach($params as $param) {
@@ -40,21 +28,35 @@
                                $paramValue = trim($split[1]);
                                $map[$paramName] = $paramValue;
                        }
-                       if (count($split) == 1) { // Default parameter (without 
name)
+                       else if (count($split) == 1) { // Default parameter 
(without name)
                                $map['coordinates'] = trim($split[0]);
                        }
                }
                
-               if (! array_key_exists('service', $map)) $map['service'] = '';
-               $map['service'] = MapsMapper::getValidService($map['service']); 
                        
+               $coords = MapsMapper::getParamValue('coordinates', $map);
                
-               $mapClass = new 
$egMapsServices[$map['service']]['pf']['class']();
+               if ($coords) {
+                       if (! MapsMapper::paramIsPresent('service', $map)) 
$map['service'] = '';
+                       $map['service'] = 
MapsMapper::getValidService($map['service']);                         
+       
+                       $mapClass = new 
$egMapsServices[$map['service']]['pf']['class']();
+       
+                       // Call the function according to the map service to 
get the HTML output
+                       $output = $mapClass->displayMap($map);  
+                       
+                       if (count($coordFails) > 0) {
+                               $output .= '<i>'.wfMsg( 
'maps_geocoding_failed_for', implode(',', $coordFails) ).'</i>';
+                       }
+               }
+               elseif (trim($coords) == "" && count($coordFails) > 0) {
+                       $output = '<i>'.wfMsg( 'maps_geocoding_failed' ).'</i>';
+               }
+               else {
+                       $output = '<i>'.wfMsg( 'maps_coordinates_missing' 
).'</i>';
+               }
                
-               // Call the function according to the map service to get the 
HTML output
-               $output = $mapClass->displayMap($parser, $map);
-               
                // Return the result
-               return array( $output, 'noparse' => true, 'isHTML' => true );
+               return array( $output, 'noparse' => true, 'isHTML' => true );   
        
        }
 
        /**
@@ -62,19 +64,31 @@
         * on the provided service, and then returns it.
         *
         * @param unknown_type $parser
+        * @return array
         */
+       public static function displayPointRender(&$parser) {           
+               $params = func_get_args();
+               array_shift( $params ); // We already know the $parser ...
+                               
+               return self::getMapHtml($params);
+       }
+       
+       /**
+        * Sets the default map properties, gets the map HTML depending 
+        * on the provided service, and then returns it.
+        *
+        * @param unknown_type $parser
+        */
        public static function displayPointsRender(&$parser) {
                $params = func_get_args();
                array_shift( $params ); // We already know the $parser ...
                
-               if (is_array($params[0])) $params = $params[0];
-               
-               return self::displayPointRender($parser, $params);
+               return self::getMapHtml($params);
        }
        
        /**
-        * Turns the address parameter into coordinates, then lets 
-        * @see MapsMapper::displayPointRender() do the work and returns it.
+        * Turns the address parameter into coordinates, then calls
+        * getMapHtml() and returns it's result. 
         *
         * @param unknown_type $parser
         * @return array
@@ -83,14 +97,14 @@
                $params = func_get_args();
                array_shift( $params ); // We already know the $parser ...
                
-               self::changeAddressToCoords($params);
+               $fails = self::changeAddressToCoords($params);
                
-               return self::displayPointRender($parser, $params);
+               return self::getMapHtml($params, $fails);
        }
        
        /**
-        * Turns the address parameter into coordinates, then lets 
-        * @see MapsMapper::displayPointRender() do the work and returns it.
+        * Turns the address parameter into coordinates, then calls
+        * getMapHtml() and returns it's result. 
         *
         * @param unknown_type $parser
         */
@@ -98,23 +112,26 @@
                $params = func_get_args();
                array_shift( $params ); // We already know the $parser ...
                
-               self::changeAddressToCoords($params);
+               $fails = self::changeAddressToCoords($params);
                
-               return self::displayPointsRender($parser, $params);
+               return self::getMapHtml($params, $fails);
        }
        
        /**
         * Changes the values of the address or addresses parameter into 
coordinates
-        * in the provided array.
+        * in the provided array. Returns an array containing the addresses that
+        * could not be geocoded.
         *
         * @param array $params
         */
        private static function changeAddressToCoords(&$params) {
                global $egMapsDefaultService;
 
+               $fails = array();
+               
                for ($i = 0; $i < count($params); $i++) {
                        $split = split('=', $params[$i]);
-                       if (strtolower(trim($split[0])) == 'service' && 
count($split) > 1) {
+                       if 
(MapsMapper::inParamAliases(strtolower(trim($split[0])), 'service') && 
count($split) > 1) {
                                $service = trim($split[1]);
                        }
                        else if (strtolower(trim($split[0])) == 'geoservice' && 
count($split) > 1) {
@@ -136,14 +153,23 @@
                                
                                foreach($addresses as $address) {
                                        $args = explode('~', $address);
-                                       $args[0] =  
MapsGeocoder::renderGeocoder(null, trim($args[0]), $geoservice, $service);
-                                       $coordinates[] = implode('~', $args);
+                                       $coords =  
MapsGeocoder::geocodeToString(trim($args[0]), $geoservice, $service);
+                                       
+                                       if ($coords) {
+                                               $args[0] = $coords;
+                                               $coordinates[] = implode('~', 
$args);
+                                       }
+                                       else {
+                                               $fails[] = $args[0];
+                                       }
                                }                               
                                
                                $params[$i] = 'coordinates=' . implode(';', 
$coordinates);
 
                        }
-               }               
+               }
+
+               return $fails;
        }
 
 }
\ No newline at end of file



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to