r59855 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59854‎ | r59855 | r59856 >
Date:22:33, 8 December 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added getParameters support.
Modified paths:
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFunctions.js (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFunctions.js (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php
@@ -88,4 +88,17 @@
8989
9090 }
9191
 92+ public function getParameters() {
 93+ $params = parent::getParameters();
 94+
 95+ $allowedTypes = MapsYahooMaps::getTypeNames();
 96+
 97+ $params[] = array('name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_controls'), 'values' => MapsYahooMaps::getControlNames());
 98+ $params[] = array('name' => 'types', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_types'), 'values' => $allowedTypes);
 99+ $params[] = array('name' => 'type', 'type' => 'enumeration', 'description' => wfMsg('semanticmaps_paramdesc_type'), 'values' => $allowedTypes);
 100+ $params[] = array('name' => 'autozoom', 'type' => 'enumeration', 'description' => wfMsg('semanticmaps_paramdesc_autozoom'), 'values' => array('on', 'off'));
 101+
 102+ return $params;
 103+ }
 104+
92105 }
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFunctions.js
@@ -60,31 +60,6 @@
6161 if (!window.OLMaps) window.OLMaps = new Object;
6262 eval("window.OLMaps." + mapName + " = map;");
6363 }
64 -
65 -
66 -/**
67 - * This function holds spesific functionallity for the Open Layers form input of Semantic Maps
68 - * TODO: Refactor as much code as possible to non specific functions
69 - */
70 -function showOLAddress(address, mapName, outputElementName, notFoundFormat) {
71 -
72 - var map = OLMaps[mapName];
73 - var geocoder = new GClientGeocoder();
74 -
75 - geocoder.getLatLng(address,
76 - function(point) {
77 - if (!point) {
78 - window.alert(address + ' ' + notFoundFormat);
79 - } else {
80 - var loc = new OpenLayers.LonLat(point.x, point.y);
81 -
82 - replaceMarker(mapName, loc);
83 - document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x);
84 - }
85 - }
86 - );
87 -
88 -}
8964
9065 /**
9166 * Remove all markers from an OL map (that's in window.OLMaps), and place a new one.
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php
@@ -80,4 +80,13 @@
8181 /*]]>*/ </script>";
8282 }
8383
 84+ public function getParameters() {
 85+ $params = parent::getParameters();
 86+
 87+ $params[] = array('name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_controls'), 'values' => MapsOpenLayers::getControlNames());
 88+ $params[] = array('name' => 'layers', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_layers'), 'values' => MapsOpenLayers::getLayerNames());
 89+
 90+ return $params;
 91+ }
 92+
8493 }
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php
@@ -25,7 +25,6 @@
2626 global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
2727
2828 $this->elementNamePrefix = $egMapsOpenLayersPrefix;
29 - $this->showAddresFunction = 'showOLAddress';
3029
3130 $this->earthZoom = 1;
3231
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFunctions.js
@@ -9,16 +9,15 @@
1010
1111 /**
1212 * This function holds spesific functionallity for the OpenStreetMap form input of Semantic Maps
13 - * TODO: Refactor as much code as possible to non specific functions
1413 */
15 -function makeOSMFormInput(mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls, height) {
 14+function makeOSMFormInput(mapName, locationFieldName, mapParams) {
1615 var markers = Array();
1716
1817 // Show a starting marker only if marker coordinates are provided
19 - if (marker_lat != null && marker_lon != null) {
20 - markers.push(getOSMMarkerData(marker_lon, marker_lat, '', ''));
 18+ if (mapParams.lat != null && mapParams.lon != null) {
 19+ mapParams.markers = [(getOSMMarkerData(mapParams.lon, mapParams.lat, '', ''))];
2120 }
22 -
 21+
2322 // Click event handler for updating the location of the marker
2423 // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
2524 OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
@@ -42,7 +41,7 @@
4342 'click': this.trigger
4443 }, this.handlerOptions
4544 );
46 - },
 45+ },
4746
4847 trigger: function(e) {
4948 replaceMarker(mapName, map.getLonLatFromViewPortPx(e.xy));
@@ -50,41 +49,15 @@
5150 }
5251
5352 });
54 -
 53+
5554 var clickHanler = new OpenLayers.Control.Click();
56 - controls.push(clickHanler);
 55+ mapParams.initializedContols = [clickHanler];
 56+
 57+ var map = new slippymap_map(mapName, mapParams);
5758
58 - var map = initOpenLayer(mapName, lon, lat, zoom, layers, controls, markers, height);
59 -
60 - // Make the map variable available for other functions
61 - if (!window.OSMMaps) window.OSMMaps = new Object;
62 - eval("window.OSMMaps." + mapName + " = map;");
 59+ // Make the map variable available for other functions
 60+ eval("window.slippymaps." + mapName + " = map;");
6361 }
64 -
65 -
66 -/**
67 - * This function holds spesific functionallity for the OpenStreetMap form input of Semantic Maps
68 - * TODO: Refactor as much code as possible to non specific functions
69 - */
70 -function showOSMAddress(address, mapName, outputElementName, notFoundFormat) {
71 -
72 - var map = OSMMaps[mapName];
73 - var geocoder = new GClientGeocoder();
74 -
75 - geocoder.getLatLng(address,
76 - function(point) {
77 - if (!point) {
78 - window.alert(address + ' ' + notFoundFormat);
79 - } else {
80 - var loc = new OpenLayers.LonLat(point.x, point.y);
81 -
82 - replaceMarker(mapName, loc);
83 - document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x);
84 - }
85 - }
86 - );
87 -
88 -}
8962
9063 /**
9164 * Remove all markers from an OSM map (that's in window.OSMMaps), and place a new one.
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMQP.php
@@ -92,4 +92,12 @@
9393 EOT;
9494 }
9595
 96+ public function getParameters() {
 97+ $params = parent::getParameters();
 98+
 99+ $params[] = array('name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_controls'), 'values' => MapsOSM::getControlNames());
 100+
 101+ return $params;
 102+ }
 103+
96104 }
Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFormInput.php
@@ -24,8 +24,7 @@
2525 protected function setMapSettings() {
2626 global $egMapsOSMZoom, $egMapsOSMPrefix;
2727
28 - $this->elementNamePrefix = $egMapsOSMPrefix;
29 - $this->showAddresFunction = 'showOSMAddress';
 28+ $this->elementNamePrefix = $egMapsOSMPrefix;
3029
3130 $this->earthZoom = 1;
3231
@@ -74,8 +73,9 @@
7574
7675 $this->output .= <<<EOT
7776 <script type='$wgJsMimeType'>
78 - slippymaps['$this->mapName'] = new slippymap_map(
 77+ makeOSMFormInput(
7978 '$this->mapName',
 79+ '$this->coordsFieldName',
8080 {
8181 mode: 'osm-wm',
8282 layer: 'osm-like',
@@ -86,9 +86,10 @@
8787 width: $this->width,
8888 height: $this->height,
8989 controls: [$controlItems],
90 - coordField: '$this->coordsFieldName'
9190 }
92 - );
 91+ );
 92+
 93+
9394 </script>
9495
9596 <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -25,7 +25,7 @@
2626
2727 // Only initialize the extension when all dependencies are present.
2828 if (defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' )) {
29 - define('SM_VERSION', '0.5 a18');
 29+ define('SM_VERSION', '0.5 a19');
3030
3131 $smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
3232 $smgIP = $IP . '/extensions/SemanticMaps';
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
@@ -309,4 +309,16 @@
310310 return wfMsg('maps_' . $this->serviceName);
311311 }
312312
 313+ public function getParameters() {
 314+ global $egMapsMapWidth, $egMapsMapHeight;
 315+
 316+ $params = parent::exportFormatParameters();
 317+
 318+ $params[] = array('name' => 'zoom', 'type' => 'int', 'description' => wfMsg('semanticmaps_paramdesc_zoom'));
 319+ $params[] = array('name' => 'width', 'type' => 'int', 'description' => wfMsgExt('semanticmaps_paramdesc_width', 'parsemag', $egMapsMapWidth));
 320+ $params[] = array('name' => 'height', 'type' => 'int', 'description' => wfMsgExt('semanticmaps_paramdesc_height', 'parsemag', $egMapsMapHeight));
 321+
 322+ return $params;
 323+ }
 324+
313325 }
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php
@@ -120,11 +120,19 @@
121121 $this->output .= $onloadFunctions;
122122 }
123123
124 - public function getParameters() {
125 - return array_merge(parent::getParameters(),
126 - array()
127 - );
128 - }
 124+ public function getParameters() {
 125+ $params = parent::getParameters();
 126+
 127+ $allowedTypes = MapsGoogleMaps::getTypeNames();
 128+
 129+ $params[] = array('name' => 'controls', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_controls'), 'values' => MapsGoogleMaps::getControlNames());
 130+ $params[] = array('name' => 'types', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_types'), 'values' => $allowedTypes);
 131+ $params[] = array('name' => 'type', 'type' => 'enumeration', 'description' => wfMsg('semanticmaps_paramdesc_type'), 'values' => $allowedTypes);
 132+ $params[] = array('name' => 'overlays', 'type' => 'enum-list', 'description' => wfMsg('semanticmaps_paramdesc_overlays'), 'values' => MapsGoogleMaps::getOverlayNames());
 133+ $params[] = array('name' => 'autozoom', 'type' => 'enumeration', 'description' => wfMsg('semanticmaps_paramdesc_autozoom'), 'values' => array('on', 'off'));
 134+
 135+ return $params;
 136+ }
129137
130138 }
131139

Status & tagging log