Index: trunk/extensions/Maps/ParserFunctions/Geocode/Maps_GeocodeFunctions.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * This file contains registration |
| 5 | + * This file contains the registration functions for the following parser functions: |
6 | 6 | * |
7 | 7 | * {{#geocode:<Address>|<param1>=<value1>|<param2>=<value2>}} |
8 | 8 | * {{#geocodelat:<Address>|<param1>=<value1>|<param2>=<value2>}} |
— | — | @@ -67,9 +67,95 @@ |
68 | 68 | * |
69 | 69 | * @return string |
70 | 70 | */ |
71 | | - public static function renderGeocoder( Parser $parser, $coordsOrAddress, $service = '', $mappingService = '' ) { |
72 | | - if ( self::geocoderIsAvailable() ) $geovalues = MapsGeocoder::attemptToGeocodeToString( $coordsOrAddress, $service, $mappingService ); |
73 | | - return $geovalues ? $geovalues : ''; |
| 71 | + public static function renderGeocoder( Parser $parser ) { |
| 72 | + global $egMapsAvailableServices, $egMapsAvailableGeoServices, $egMapsAvailableCoordNotations; |
| 73 | + global $egMapsDefaultServices, $egMapsDefaultGeoService, $egMapsCoordinateNotation; |
| 74 | + global $egMapsAllowCoordsGeocoding, $egMapsCoordinateDirectional; |
| 75 | + |
| 76 | + $args = func_get_args(); |
| 77 | + |
| 78 | + // We already know the $parser. |
| 79 | + array_shift( $args ); |
| 80 | + |
| 81 | + // For backward compatibility with pre 0.6. |
| 82 | + $defaultParams = array( 'location', 'service', 'mappingservice' ); |
| 83 | + $parameters = array(); |
| 84 | + |
| 85 | + // Determine all parameter names and value, and take care of default (nameless) |
| 86 | + // parameters, by turning them into named ones. |
| 87 | + foreach( $args as $arg ) { |
| 88 | + $parts = explode( '=', $arg ); |
| 89 | + if ( count( $parts ) == 1 ) { |
| 90 | + if ( count( $defaultParams ) > 0 ) { |
| 91 | + $defaultParam = array_shift( $defaultParams ); |
| 92 | + $parameters[$defaultParam] = $parts[0]; |
| 93 | + } |
| 94 | + } else { |
| 95 | + $name = array_shift( $parts ); |
| 96 | + $parameters[$name] = implode( $parts ); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + $parameterInfo = array( |
| 101 | + 'location' => array( |
| 102 | + 'required' => true |
| 103 | + ), |
| 104 | + 'mappingservice' => array( |
| 105 | + 'criteria' => array( |
| 106 | + 'in_array' => $egMapsAvailableServices |
| 107 | + ), |
| 108 | + 'default' => $egMapsDefaultServices['pf'] |
| 109 | + ), |
| 110 | + 'service' => array( |
| 111 | + 'criteria' => array( |
| 112 | + 'in_array' => array_keys( $egMapsAvailableGeoServices ) |
| 113 | + ), |
| 114 | + 'default' => $egMapsDefaultGeoService |
| 115 | + ), |
| 116 | + 'notation' => array( |
| 117 | + 'criteria' => array( |
| 118 | + 'in_array' => $egMapsAvailableCoordNotations |
| 119 | + ), |
| 120 | + 'default' => $egMapsCoordinateNotation |
| 121 | + ), |
| 122 | + 'allowcoordinates' => array( |
| 123 | + 'type' => 'boolean', |
| 124 | + 'default' => $egMapsAllowCoordsGeocoding |
| 125 | + ), |
| 126 | + 'directional' => array( |
| 127 | + 'type' => 'boolean', |
| 128 | + 'default' => $egMapsCoordinateDirectional |
| 129 | + ), |
| 130 | + ); |
| 131 | + |
| 132 | + $manager = new ValidatorManager(); |
| 133 | + |
| 134 | + $parameters = $manager->manageMapparameters( $parameters, $parameterInfo ); |
| 135 | + |
| 136 | + $doGeocoding = $parameters !== false; |
| 137 | + |
| 138 | + if ( $doGeocoding ) { |
| 139 | + if ( self::geocoderIsAvailable() ) { |
| 140 | + $geovalues = MapsGeocoder::attemptToGeocodeToString( |
| 141 | + $parameters['location'], |
| 142 | + $parameters['service'], |
| 143 | + $parameters['mappingservice'], |
| 144 | + $parameters['allowcoordinates'], |
| 145 | + $parameters['notation'], |
| 146 | + $parameters['directional'] |
| 147 | + ); |
| 148 | + return ( $geovalues ? $geovalues : '' ) . $manager->getErrorList(); |
| 149 | + } |
| 150 | + else { |
| 151 | + return htmlspecialchars( wfMsg( 'maps-geocoder-not-available' ) ); |
| 152 | + } |
| 153 | + } else { |
| 154 | + return $manager->getErrorList(); |
| 155 | + } |
| 156 | + |
| 157 | + //$egMapsAvailableCoordNotations |
| 158 | + |
| 159 | + ; |
74 | 160 | } |
75 | 161 | |
76 | 162 | /** |
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -52,19 +52,19 @@ |
53 | 53 | 'service' => array( |
54 | 54 | 'criteria' => array( |
55 | 55 | 'in_array' => $egMapsAvailableServices |
56 | | - ), |
| 56 | + ), |
57 | 57 | 'default' => $egMapsDefaultServices['pf'] |
58 | | - ), |
| 58 | + ), |
59 | 59 | 'coordinates' => array( |
60 | 60 | 'aliases' => array( 'coords', 'location', 'locations' ), |
61 | | - ), |
| 61 | + ), |
62 | 62 | 'geoservice' => array( |
63 | 63 | 'criteria' => array( |
64 | 64 | 'in_array' => array_keys( $egMapsAvailableGeoServices ) |
65 | | - ), |
| 65 | + ), |
66 | 66 | 'default' => $egMapsDefaultGeoService |
67 | | - ), |
68 | | - ); |
| 67 | + ), |
| 68 | + ); |
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
Index: trunk/extensions/Maps/Maps.i18n.php |
— | — | @@ -40,6 +40,9 @@ |
41 | 41 | $1', |
42 | 42 | 'maps_map_cannot_be_displayed' => 'The map cannot be displayed.', |
43 | 43 | |
| 44 | + // Geocoding |
| 45 | + 'maps-geocoder-not-available' => 'The geocoding feature is of Maps is not available, your location can not be geocoded.', |
| 46 | + |
44 | 47 | // Mapping services |
45 | 48 | 'maps_googlemaps2' => 'Google Maps v2', |
46 | 49 | 'maps_googlemaps3' => 'Google Maps v3', |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -118,11 +118,12 @@ |
119 | 119 | |
120 | 120 | # Enum. The default output format of coordinates. |
121 | 121 | # Possible values: Maps_COORDS_FLOAT, Maps_COORDS_DMS, Maps_COORDS_DM, Maps_COORDS_DD |
122 | | -$egMapsCoordinateNotation = Maps_COORDS_FLOAT; |
| 122 | +$egMapsCoordinateNotation = Maps_COORDS_DMS; |
123 | 123 | |
124 | 124 | # Boolean. Indicates if coordinates should be outputted in directional notation by default. |
125 | 125 | $egMapsCoordinateDirectional = false; |
126 | 126 | |
| 127 | +$egMapsAllowCoordsGeocoding = true; |
127 | 128 | |
128 | 129 | |
129 | 130 | |