diff options
author | Yaco <franco@reevo.org> | 2021-10-19 20:24:11 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2021-10-19 20:24:11 -0300 |
commit | e3880a1c86acaa3bbd05786ad2f5c586e6511a58 (patch) | |
tree | ec77bfc5b69f259a159c95188797bd0dade92357 /www/wiki/extensions/Maps/src/GoogleMapsService.php | |
parent | 20ca0685509f8010580d3b45036a64ab48616af1 (diff) |
updates Maps to 7.13.0
Diffstat (limited to 'www/wiki/extensions/Maps/src/GoogleMapsService.php')
-rw-r--r-- | www/wiki/extensions/Maps/src/GoogleMapsService.php | 71 |
1 files changed, 62 insertions, 9 deletions
diff --git a/www/wiki/extensions/Maps/src/GoogleMapsService.php b/www/wiki/extensions/Maps/src/GoogleMapsService.php index 9c1b91b9..b1ccba34 100644 --- a/www/wiki/extensions/Maps/src/GoogleMapsService.php +++ b/www/wiki/extensions/Maps/src/GoogleMapsService.php @@ -3,6 +3,8 @@ namespace Maps; use Html; +use ParamProcessor\ProcessedParam; +use ParamProcessor\ProcessingResult; /** * @licence GNU GPL v2+ @@ -49,7 +51,19 @@ class GoogleMapsService implements MappingService { global $egMapsGMaps3DefTypeStyle, $egMapsGMaps3DefZoomStyle, $egMapsGMaps3AutoInfoWindows; global $egMapsResizableByDefault; - $params = []; + $params = MapsFunctions::getCommonParameters(); + + $params['visitedicon'] = [ + 'default' => '', + 'message' => 'maps-displaymap-par-visitedicon', + ]; + + $params['wmsoverlay'] = [ + 'type' => 'wmsoverlay', + 'default' => false, + 'delimiter' => ' ', + 'message' => 'maps-displaymap-par-wmsoverlay', + ]; $params['zoom'] = [ 'type' => 'integer', @@ -150,7 +164,8 @@ class GoogleMapsService implements MappingService { 'message' => 'maps-googlemaps3-par-poi', ]; - $params['markercluster'] = [ + $params['cluster'] = [ + 'aliases' => [ 'markercluster' ], 'type' => 'boolean', 'default' => false, 'message' => 'maps-par-markercluster', @@ -199,11 +214,18 @@ class GoogleMapsService implements MappingService { 'message' => 'maps-par-kml', 'islist' => true, 'post-format' => function( array $kmlFileNames ) { - return array_map( - function( string $fileName ) { - return wfExpandUrl( MapsFunctions::getFileUrl( $fileName ) ); - }, - $kmlFileNames + return array_values( + array_filter( + array_map( + function( string $fileName ) { + return wfExpandUrl( MapsFunctions::getFileUrl( $fileName ) ); + }, + $kmlFileNames + ), + function( string $fileName ) { + return $fileName !== ''; + } + ) ); } ]; @@ -220,13 +242,15 @@ class GoogleMapsService implements MappingService { // new CriterionSearchMarkers() FIXME ]; - $params['enablefullscreen'] = [ + $params['fullscreen'] = [ + 'aliases' => [ 'enablefullscreen' ], 'type' => 'boolean', 'default' => false, 'message' => 'maps-par-enable-fullscreen', ]; $params['scrollwheelzoom'] = [ + 'aliases' => [ 'scrollzoom' ], 'type' => 'boolean', 'default' => false, 'message' => 'maps-par-scrollwheelzoom', @@ -251,7 +275,7 @@ class GoogleMapsService implements MappingService { } public function getResourceModules(): array { - return [ 'ext.maps.googlemaps3', 'ext.sm.googlemaps3ajax' ]; + return [ 'ext.maps.googlemaps3', 'ext.maps.googlemaps3ajax' ]; } public static function getApiScript( $langCode, array $urlArgs = [] ) { @@ -311,4 +335,33 @@ class GoogleMapsService implements MappingService { ) ]; } + + public function processingResultToMapParams( ProcessingResult $processingResult ): array { + $parameters = $processingResult->getParameters(); + + if ( array_key_exists( 'zoom', $parameters ) && $parameters['zoom']->wasSetToDefault() && count( + $parameters['coordinates']->getValue() + ) > 1 ) { + $parameters['zoom'] = $this->getParameterWithValue( $parameters['zoom'], false ); + } + + $mapParams = []; + + foreach ( $parameters as $parameter ) { + $mapParams[$parameter->getName()] = $parameter->getValue(); + } + + return $mapParams; + } + + private function getParameterWithValue( ProcessedParam $param, $value ) { + return new ProcessedParam( + $param->getName(), + $value, + $param->wasSetToDefault(), + $param->getOriginalName(), + $param->getOriginalValue() + ); + } + } |