Index: trunk/extensions/Maps/INSTALL |
— | — | @@ -1,4 +1,4 @@ |
2 | | -[[Maps 0.7.4]] |
| 2 | +[[Maps 0.7.5]] |
3 | 3 | |
4 | 4 | In order to use this version of Maps, you need to have Validator 0.3.6 installed. If you get a distribution |
5 | 5 | from this page, you don't need to bother this, since Validator comes bundled with every release, and will |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | die( '<b>Error:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.<br />' ); |
38 | 38 | } |
39 | 39 | else { |
40 | | - define( 'Maps_VERSION', '0.7.5 alpha' ); |
| 40 | + define( 'Maps_VERSION', '0.7.5 rc' ); |
41 | 41 | |
42 | 42 | // The different coordinate notations. |
43 | 43 | define( 'Maps_COORDS_FLOAT', 'float' ); |
— | — | @@ -99,6 +99,7 @@ |
100 | 100 | $manDir = $incDir . 'manipulations/'; |
101 | 101 | $wgAutoloadClasses['MapsParamCoordSet'] = $manDir . 'Maps_ParamCoordSet.php'; |
102 | 102 | $wgAutoloadClasses['MapsParamDimension'] = $manDir . 'Maps_ParamDimension.php'; |
| 103 | + $wgAutoloadClasses['MapsParamGeoService'] = $manDir . 'Maps_ParamGeoService.php'; |
103 | 104 | $wgAutoloadClasses['MapsParamImage'] = $manDir . 'Maps_ParamImage.php'; |
104 | 105 | $wgAutoloadClasses['MapsParamLocation'] = $manDir . 'Maps_ParamLocation.php'; |
105 | 106 | $wgAutoloadClasses['MapsParamService'] = $manDir . 'Maps_ParamService.php'; |
Index: trunk/extensions/Maps/RELEASE-NOTES |
— | — | @@ -7,6 +7,13 @@ |
8 | 8 | http://mapping.referata.com/wiki/Maps/Version_history#Maps_change_log |
9 | 9 | |
10 | 10 | |
| 11 | +=== Maps 0.7.5 === |
| 12 | +(2011-02-16) |
| 13 | + |
| 14 | +* Fixed incorrect defaulting of geocoding service. |
| 15 | + |
| 16 | +* Improved default width of maps. |
| 17 | + |
11 | 18 | === Maps 0.7.4 === |
12 | 19 | (2011-01-20) |
13 | 20 | |
Index: trunk/extensions/Maps/includes/Maps_Geocoders.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | * |
37 | 37 | * @var array of string => string |
38 | 38 | */ |
39 | | - protected static $registeredGeocoders = array(); |
| 39 | + public static $registeredGeocoders = array(); |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * The global geocoder cache, holding geocoded data when enabled. |
— | — | @@ -297,22 +297,16 @@ |
298 | 298 | * main identifier. If it's not recognized at all (or empty), the default will be used. |
299 | 299 | * Only call this function when there are geocoders available, else an erro will be thrown. |
300 | 300 | * |
301 | | - * TODO: implement overrides |
302 | | - * |
303 | 301 | * @since 0.7 |
304 | 302 | * |
305 | 303 | * @param string $geocoderIdentifier |
306 | | - * @param string $mappingService |
307 | 304 | * |
308 | 305 | * @return string or false |
309 | 306 | */ |
310 | | - protected static function getValidGeocoderIdentifier( $geocoderIdentifier /*, $mappingService */ ) { |
| 307 | + protected static function getValidGeocoderIdentifier( $geocoderIdentifier ) { |
311 | 308 | global $egMapsDefaultGeoService, $egMapsUserGeoOverrides; |
312 | 309 | static $validatedDefault = false; |
313 | 310 | |
314 | | - // Get rid of any aliases. |
315 | | - $geocoderIdentifier = self::getMainGeocoderIndentifier( $geocoderIdentifier ); |
316 | | - |
317 | 311 | if ( $geocoderIdentifier == '' || !array_key_exists( $geocoderIdentifier, self::$registeredGeocoders ) ) { |
318 | 312 | if ( !$validatedDefault ) { |
319 | 313 | if ( !array_key_exists( $egMapsDefaultGeoService, self::$registeredGeocoders ) ) { |
— | — | @@ -334,18 +328,4 @@ |
335 | 329 | return $geocoderIdentifier; |
336 | 330 | } |
337 | 331 | |
338 | | - /** |
339 | | - * Gets the main geocoder identifier by resolving aliases. |
340 | | - * |
341 | | - * @since 0.7 |
342 | | - * |
343 | | - * @param string $geocoderIdentifier |
344 | | - * |
345 | | - * @return string |
346 | | - */ |
347 | | - protected static function getMainGeocoderIndentifier( $geocoderIdentifier ) { |
348 | | - // TODO: implement actual function |
349 | | - return $geocoderIdentifier; |
350 | | - } |
351 | | - |
352 | | -} |
\ No newline at end of file |
| 332 | +} |
Index: trunk/extensions/Maps/includes/manipulations/Maps_ParamGeoService.php |
— | — | @@ -0,0 +1,120 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation ensuring the value is a geocoding service, |
| 6 | + * and taking care of both alias resolving and overrides handling. |
| 7 | + * |
| 8 | + * @since 0.7.5 |
| 9 | + * |
| 10 | + * @file Maps_ParamGeoService.php |
| 11 | + * @ingroup Maps |
| 12 | + * @ingroup ParameterManipulations |
| 13 | + * |
| 14 | + * @author Jeroen De Dauw |
| 15 | + */ |
| 16 | +class MapsParamGeoService extends ItemParameterManipulation { |
| 17 | + |
| 18 | + /** |
| 19 | + * @since 0.7.5 |
| 20 | + * |
| 21 | + * @var string or false |
| 22 | + */ |
| 23 | + protected $mappingServiceParam; |
| 24 | + |
| 25 | + /** |
| 26 | + * Constructor. |
| 27 | + * |
| 28 | + * @since 0.7.5 |
| 29 | + */ |
| 30 | + public function __construct( $mappingServiceParam = false ) { |
| 31 | + parent::__construct(); |
| 32 | + |
| 33 | + $this->mappingServiceParam = $mappingServiceParam; |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * @see ItemParameterManipulation::doManipulation |
| 38 | + * |
| 39 | + * @since 0.7.5 |
| 40 | + */ |
| 41 | + public function doManipulation( &$value, Parameter $parameter, array &$parameters ) { |
| 42 | + global $egMapsDefaultGeoService, $egMapsUserGeoOverrides; |
| 43 | + static $validatedDefault = false; |
| 44 | + |
| 45 | + if ( !MapsGeocoders::canGeocode() ) { |
| 46 | + throw new Exception( 'There are no geocoders registered, so no geocoding can happen.' ); |
| 47 | + } |
| 48 | + |
| 49 | + // Get rid of any aliases. |
| 50 | + $value = $this->getMainIndentifier( $value ); |
| 51 | + |
| 52 | + // Override the defaulting. |
| 53 | + if ( $parameter->wasSetToDefault() && $this->mappingServiceParam !== false ) { |
| 54 | + $value = self::resolveOverrides( $value, $parameters[$this->mappingServiceParam]->getValue() ); |
| 55 | + } |
| 56 | + |
| 57 | + if ( $value == '' || !array_key_exists( $value, MapsGeocoders::$registeredGeocoders ) ) { |
| 58 | + if ( !$validatedDefault ) { |
| 59 | + if ( !array_key_exists( $egMapsDefaultGeoService, MapsGeocoders::$registeredGeocoders ) ) { |
| 60 | + $egMapsDefaultGeoService = array_shift( array_keys( MapsGeocoders::$registeredGeocoders ) ); |
| 61 | + if ( is_null( $egMapsDefaultGeoService ) ) { |
| 62 | + throw new Exception( 'Tried to geocode while there are no geocoders available at ' . __METHOD__ ); |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + if ( array_key_exists( $egMapsDefaultGeoService, MapsGeocoders::$registeredGeocoders ) ) { |
| 68 | + $value = $egMapsDefaultGeoService; |
| 69 | + } |
| 70 | + else { |
| 71 | + throw new Exception( 'Attempt to use the default geocoder while it does not exist.' ); |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Replaces the geocoder identifier in case there is an override specified by |
| 78 | + * one of the registered geocoders. |
| 79 | + * |
| 80 | + * @since 0.7.5 |
| 81 | + * |
| 82 | + * @param string $geocoderIdentifier |
| 83 | + * @param string $mappingService |
| 84 | + * |
| 85 | + * @return string |
| 86 | + */ |
| 87 | + protected static function resolveOverrides( $geocoderIdentifier, $mappingService ) { |
| 88 | + static $overrides = false; |
| 89 | + |
| 90 | + if ( $overrides === false ) { |
| 91 | + $overrides = array(); |
| 92 | + |
| 93 | + foreach ( MapsGeocoders::$registeredGeocoders as $key => $class ) { |
| 94 | + $overrides[$key] = call_user_func( array( $class, 'getOverrides' ) ); |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + foreach ( $overrides as $geocoder => $services ) { |
| 99 | + if ( in_array( $mappingService, $services ) ) { |
| 100 | + return $geocoder; |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + return $geocoderIdentifier; |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Gets the main geocoder identifier by resolving aliases. |
| 109 | + * |
| 110 | + * @since 0.7.5 |
| 111 | + * |
| 112 | + * @param string $geocoderIdentifier |
| 113 | + * |
| 114 | + * @return string |
| 115 | + */ |
| 116 | + protected function getMainIndentifier( $geocoderIdentifier ) { |
| 117 | + // TODO: implement actual function |
| 118 | + return $geocoderIdentifier; |
| 119 | + } |
| 120 | + |
| 121 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Maps/includes/manipulations/Maps_ParamGeoService.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 122 | + native |
Index: trunk/extensions/Maps/includes/Maps_Mapper.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | * |
70 | 70 | * This is a copy of |
71 | 71 | * @see Xml::encodeJsVar |
72 | | - * which fixes incorrect behaviour with floats. |
| 72 | + * which fixes incorrect behaviour with floats (fixed in MW 1.18). |
73 | 73 | * |
74 | 74 | * @since 0.7.1 |
75 | 75 | * |
— | — | @@ -125,16 +125,11 @@ |
126 | 126 | $params['mappingservice']->setDefault( $egMapsDefaultService ); |
127 | 127 | $params['mappingservice']->addCriteria( new CriterionInArray( MapsMappingServices::getAllServiceValues() ) ); |
128 | 128 | |
129 | | - $params['geoservice'] = new Parameter( |
130 | | - 'geoservice', |
131 | | - Parameter::TYPE_STRING, |
132 | | - $egMapsDefaultGeoService, |
133 | | - array(), |
134 | | - array( |
135 | | - new CriterionInArray( $egMapsAvailableGeoServices ), |
136 | | - ), |
137 | | - array( 'mappingservice' ) |
138 | | - ); |
| 129 | + $params['geoservice'] = new Parameter( 'geoservice' ); |
| 130 | + $params['geoservice']->setDefault( $egMapsDefaultGeoService ); |
| 131 | + $params['geoservice']->addCriteria( new CriterionInArray( $egMapsAvailableGeoServices ) ); |
| 132 | + $params['geoservice']->addDependencies( 'mappingservice' ); |
| 133 | + $params['geoservice']->addManipulations( new MapsParamGeoService( 'mappingservice' ) ); |
139 | 134 | |
140 | 135 | $params['zoom'] = new Parameter( |
141 | 136 | 'zoom', |
Index: trunk/extensions/Maps/includes/Maps_Geocoder.php |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | * |
145 | 145 | * @return array |
146 | 146 | */ |
147 | | - public function getOverrides() { |
| 147 | + public static function getOverrides() { |
148 | 148 | return array(); |
149 | 149 | } |
150 | 150 | |
Index: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php |
— | — | @@ -141,7 +141,7 @@ |
142 | 142 | // Get an instance of the class handling the current parser hook and service. |
143 | 143 | $mapClass = $service->getFeatureInstance( 'display_point' ); |
144 | 144 | |
145 | | - return $mapClass->getMapHtml( $parameters, $this->parser ); |
| 145 | + return $mapClass->getMapHtml( $parameters, $this->parser, $this->frame ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
Index: trunk/extensions/Maps/includes/geocoders/Maps_GoogleGeocoder.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | * |
76 | 76 | * @return array |
77 | 77 | */ |
78 | | - public function getOverrides() { |
| 78 | + public static function getOverrides() { |
79 | 79 | return array( 'googlemaps2', 'googlemaps3' ); |
80 | 80 | } |
81 | 81 | |
Index: trunk/extensions/Maps/includes/geocoders/Maps_YahooGeocoder.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | * |
71 | 71 | * @return array |
72 | 72 | */ |
73 | | - public function getOverrides() { |
| 73 | + public static function getOverrides() { |
74 | 74 | return array( 'yahoomaps' ); |
75 | 75 | } |
76 | 76 | |
Index: trunk/extensions/Maps/includes/features/Maps_BasePointMap.php |
— | — | @@ -81,10 +81,10 @@ |
82 | 82 | * |
83 | 83 | * @return html |
84 | 84 | */ |
85 | | - public final function getMapHtml( array $params, Parser $parser ) { |
| 85 | + public final function getMapHtml( array $params, Parser $parser, PPFrame $frame = null ) { |
86 | 86 | $this->setMapProperties( $params ); |
87 | 87 | |
88 | | - $this->setMarkerData(); |
| 88 | + $this->setMarkerData( $parser, $frame ); |
89 | 89 | |
90 | 90 | $this->setCentre(); |
91 | 91 | |
— | — | @@ -112,15 +112,12 @@ |
113 | 113 | /** |
114 | 114 | * Fills the $markerData array with the locations and their meta data. |
115 | 115 | */ |
116 | | - private function setMarkerData() { |
| 116 | + private function setMarkerData( Parser $parser, PPFrame $frame = null ) { |
117 | 117 | global $wgTitle; |
118 | 118 | |
119 | | - // New parser object to render popup contents with. |
120 | | - $parser = new Parser(); |
| 119 | + $this->title = $parser->recursiveTagParse( $this->title, $frame ); |
| 120 | + $this->label = $parser->recursiveTagParse( $this->label, $frame ); |
121 | 121 | |
122 | | - $this->title = $parser->parse( $this->title, $wgTitle, new ParserOptions() )->getText(); |
123 | | - $this->label = $parser->parse( $this->label, $wgTitle, new ParserOptions() )->getText(); |
124 | | - |
125 | 122 | // Each $args is an array containg the coordinate set as first element, possibly followed by meta data. |
126 | 123 | foreach ( $this->coordinates as $args ) { |
127 | 124 | $markerData = MapsCoordinateParser::parseCoordinates( array_shift( $args ) ); |
— | — | @@ -131,11 +128,11 @@ |
132 | 129 | |
133 | 130 | if ( count( $args ) > 0 ) { |
134 | 131 | // Parse and add the point specific title if it's present. |
135 | | - $markerData['title'] = $parser->parse( $args[0], $wgTitle, new ParserOptions() )->getText(); |
| 132 | + $markerData['title'] = $parser->recursiveTagParse( $args[0], $frame ); |
136 | 133 | |
137 | 134 | if ( count( $args ) > 1 ) { |
138 | 135 | // Parse and add the point specific label if it's present. |
139 | | - $markerData['label'] = $parser->parse( $args[1], $wgTitle, new ParserOptions() )->getText(); |
| 136 | + $markerData['label'] = $parser->recursiveTagParse( $args[1], $frame ); |
140 | 137 | |
141 | 138 | if ( count( $args ) > 2 ) { |
142 | 139 | // Add the point specific icon if it's present. |