r55773 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55772‎ | r55773 | r55774 >
Date:16:56, 3 September 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.3.4
Modified paths:
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFunctions.js (added) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayers.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFunctions.js (added) (history)
  • /trunk/extensions/SemanticMaps/SM_FormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SM_Settings.php (added) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.i18n.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFunctions.js (added) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFunctions.js
@@ -0,0 +1,54 @@
 2+ /**
 3+ * Javascript functions for Yahoo! Maps functionallity in Semantic Maps
 4+ *
 5+ * @file SM_YahooMapsFunctions.js
 6+ * @ingroup SemanticMaps
 7+ *
 8+ * @author Jeroen De Dauw
 9+ */
 10+
 11+/**
 12+ * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps
 13+ * TODO: Refactor as much code as possible to non specific functions
 14+ */
 15+function makeFormInputYahooMap(mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon) {
 16+ var map = createYahooMap(document.getElementById(mapName), new YGeoPoint(lat, lon), zoom, type, types, controls, scrollWheelZoom, [getYMarkerData(marker_lat, marker_lon, '', '', '')]);
 17+
 18+ // Show a starting marker only if marker coordinates are provided
 19+ if (marker_lat != null && marker_lon != null) {
 20+ map.addOverlay(createYMarker(new YGeoPoint(marker_lat, marker_lon)));
 21+ }
 22+
 23+ // Click event handler for updating the location of the marker
 24+ YEvent.Capture(map, EventsList.MouseClick,
 25+ function(_e, point) {
 26+ var loc = new YGeoPoint(point.Lat, point.Lon)
 27+ map.removeMarkersAll();
 28+ document.getElementById(locationFieldName).value = convertLatToDMS(point.Lat)+', '+convertLngToDMS(point.Lon);
 29+ map.addMarker(loc);
 30+ map.panToLatLon(loc);
 31+ }
 32+ );
 33+
 34+ // Make the map variable available for other functions
 35+ if (!window.YMaps) window.YMaps = new Object;
 36+ eval("window.YMaps." + mapName + " = map;");
 37+}
 38+
 39+/**
 40+ * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps
 41+ * TODO: Refactor as much code as possible to non specific functions
 42+ */
 43+function showYAddress(address, mapName, outputElementName, notFoundFormat) {
 44+ var map = YMaps[mapName];
 45+
 46+ map.removeMarkersAll();
 47+ map.drawZoomAndCenter(address);
 48+
 49+ YEvent.Capture(map, EventsList.onEndGeoCode,
 50+ function(resultObj) {
 51+ map.addOverlay(new YMarker(resultObj.GeoPoint));
 52+ document.getElementById(outputElementName).value = convertLatToDMS(resultObj.GeoPoint.Lat) + ', ' + convertLngToDMS(resultObj.GeoPoint.Lon);
 53+ }
 54+ );
 55+}
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMaps.php
@@ -16,11 +16,6 @@
1717
1818 public $serviceName = MapsYahooMaps::SERVICE_NAME;
1919
20 - public function getName() {
21 - wfLoadExtensionMessages('SemanticMaps');
22 - return wfMsg('sm_yahoomaps_printername');
23 - }
24 -
2520 /**
2621 * @see SMMapPrinter::setQueryPrinterSettings()
2722 *
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php
@@ -34,18 +34,34 @@
3535 }
3636
3737 /**
 38+ * @see MapsMapFeature::addFormDependencies()
 39+ *
 40+ * @param string $output
 41+ */
 42+ protected function addFormDependencies(&$output) {
 43+ global $wgJsMimeType;
 44+ global $smgIncludePath, $smgYahooFormsOnThisPage;
 45+
 46+ MapsYahooMapsUtils::addYMapDependencies($output);
 47+
 48+ if (empty($smgYahooFormsOnThisPage)) {
 49+ $smgYahooFormsOnThisPage = 0;
 50+ $output .= "<script type='$wgJsMimeType' src='$smgIncludePath/YahooMaps/SM_YahooMapsFunctions.js'></script>";
 51+ }
 52+ }
 53+
 54+ /**
3855 * @see MapsMapFeature::doMapServiceLoad()
3956 *
4057 */
4158 protected function doMapServiceLoad() {
42 - global $egYahooMapsOnThisPage;
 59+ global $egYahooMapsOnThisPage, $smgYahooFormsOnThisPage;
4360
44 - if (empty($egYahooMapsOnThisPage)) {
45 - $egYahooMapsOnThisPage = 0;
46 - MapsYahooMapsUtils::addYMapDependencies($this->output);
47 - }
48 - $egYahooMapsOnThisPage++;
 61+ self::addFormDependencies($this->output);
4962
 63+ $egYahooMapsOnThisPage++;
 64+ $smgYahooFormsOnThisPage++;
 65+
5066 $this->elementNr = $egYahooMapsOnThisPage;
5167 }
5268
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFunctions.js
@@ -0,0 +1,118 @@
 2+ /**
 3+ * Javascript functions for OpenLayers functionallity in Semantic Maps
 4+ *
 5+ * @file SM_OpenLayersFunctions.js
 6+ * @ingroup SemanticMaps
 7+ *
 8+ * @author Jeroen De Dauw
 9+ */
 10+
 11+/**
 12+ * This function holds spesific functionallity for the Open Layers form input of Semantic Maps
 13+ * TODO: Refactor as much code as possible to non specific functions
 14+ */
 15+function makeFormInputOpenLayer(mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls) {
 16+ var markers = Array();
 17+
 18+ // Show a starting marker only if marker coordinates are provided
 19+ if (marker_lat != null && marker_lon != null) {
 20+ markers.push(getOLMarkerData(marker_lon, marker_lat, '', ''));
 21+ }
 22+
 23+ // Click event handler for updating the location of the marker
 24+ // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
 25+ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
 26+ defaultHandlerOptions: {
 27+ 'single': true,
 28+ 'double': false,
 29+ 'pixelTolerance': 0,
 30+ 'stopSingle': false,
 31+ 'stopDouble': false
 32+ },
 33+
 34+ initialize: function(options) {
 35+ this.handlerOptions = OpenLayers.Util.extend(
 36+ {}, this.defaultHandlerOptions
 37+ );
 38+ OpenLayers.Control.prototype.initialize.apply(
 39+ this, arguments
 40+ );
 41+ this.handler = new OpenLayers.Handler.Click(
 42+ this, {
 43+ 'click': this.trigger
 44+ }, this.handlerOptions
 45+ );
 46+ },
 47+
 48+ trigger: function(e) {
 49+ replaceMarker(mapName, map.getLonLatFromViewPortPx(e.xy));
 50+ document.getElementById(locationFieldName).value = convertLatToDMS(map.getLonLatFromViewPortPx(e.xy).lat)+', '+convertLngToDMS(map.getLonLatFromViewPortPx(e.xy).lon);
 51+ }
 52+
 53+ });
 54+
 55+ var clickHanler = new OpenLayers.Control.Click();
 56+ controls.push(clickHanler);
 57+
 58+ var map = initOpenLayer(mapName, lon, lat, zoom, layers, controls, markers);
 59+
 60+ // Make the map variable available for other functions
 61+ if (!window.OLMaps) window.OLMaps = new Object;
 62+ eval("window.OLMaps." + mapName + " = map;");
 63+}
 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+}
 89+
 90+/**
 91+ * Remove all markers from an OL map (that's in window.OLMaps), and pplace a new one.
 92+ *
 93+ * @param mapName Name of the map as in OLMaps[mapName].
 94+ * @param newLocation The location for the new marker.
 95+ * @return
 96+ */
 97+function replaceMarker(mapName, newLocation) {
 98+ var map = OLMaps[mapName];
 99+ var markerLayer = map.getLayer('markerLayer');
 100+
 101+ removeMarkers(markerLayer);
 102+ markerLayer.addMarker(getOLMarker(markerLayer, getOLMarkerData(newLocation.lon, newLocation.lat, '', ''), map.getProjectionObject()));
 103+
 104+ map.panTo(newLocation);
 105+}
 106+
 107+/**
 108+ * Removes all markers from a marker layer.
 109+ *
 110+ * @param markerLayer The layer to remove all markers from.
 111+ * @return
 112+ */
 113+function removeMarkers(markerLayer) {
 114+ var markerCollection = markerLayer.markers;
 115+
 116+ for (i in markerCollection) {
 117+ markerLayer.removeMarker(markerCollection[i]);
 118+ }
 119+}
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayers.php
@@ -17,11 +17,6 @@
1818
1919 public $serviceName = MapsOpenLayers::SERVICE_NAME;
2020
21 - public function getName() {
22 - wfLoadExtensionMessages('SemanticMaps');
23 - return wfMsg('sm_openlayers_printername');
24 - }
25 -
2621 /**
2722 * @see SMMapPrinter::setQueryPrinterSettings()
2823 *
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php
@@ -34,14 +34,33 @@
3535 }
3636
3737 /**
 38+ * @see MapsMapFeature::addFormDependencies()
 39+ *
 40+ * @param string $output
 41+ */
 42+ protected function addFormDependencies(&$output) {
 43+ global $wgJsMimeType;
 44+ global $smgIncludePath, $smgOLFormsOnThisPage;
 45+
 46+ MapsOpenLayersUtils::addOLDependencies($output);
 47+
 48+ if (empty($smgOLFormsOnThisPage)) {
 49+ $smgOLFormsOnThisPage = 0;
 50+ $output .= "<script type='$wgJsMimeType' src='$smgIncludePath/OpenLayers/SM_OpenLayersFunctions.js'></script>";
 51+ }
 52+ }
 53+
 54+ /**
3855 * @see MapsMapFeature::doMapServiceLoad()
3956 *
4057 */
4158 protected function doMapServiceLoad() {
42 - global $egOpenLayersOnThisPage;
 59+ global $egOpenLayersOnThisPage, $smgOLFormsOnThisPage;
4360
44 - MapsOpenLayersUtils::addOLDependencies($this->output);
 61+ self::addFormDependencies($this->output);
 62+
4563 $egOpenLayersOnThisPage++;
 64+ $smgOLFormsOnThisPage++;
4665
4766 $this->elementNr = $egOpenLayersOnThisPage;
4867 }
Index: trunk/extensions/SemanticMaps/SM_Settings.php
@@ -0,0 +1,31 @@
 2+<?php
 3+
 4+/**
 5+ * File defining the settings for the Semantic Maps extension
 6+ * More info can be found at http://www.mediawiki.org/wiki/Extension:Semantic Maps#Settings
 7+ *
 8+ * NOTICE:
 9+ * Changing one of these settings can be done by copieng or cutting it,
 10+ * and placing it in LocalSettings.php, AFTER the inclusion of Semantic Maps.
 11+ *
 12+ * @file SM_Settings.php
 13+ * @ingroup SemanticMaps
 14+ *
 15+ * @author Jeroen De Dauw
 16+ */
 17+
 18+if( !defined( 'MEDIAWIKI' ) ) {
 19+ die( 'Not an entry point.' );
 20+}
 21+
 22+
 23+
 24+
 25+# Map features configuration
 26+# (named) Array of String. This array contains the available features for Maps.
 27+# The array element name contains an abbriviation, used for code references,
 28+# and in the service data arrays, the value is the human readible version for displaying purpouses.
 29+$egMapsAvailableFeatures['qp'] = 'Query Printer';
 30+$egMapsAvailableFeatures['fi'] = 'Form input';
 31+
 32+
Index: trunk/extensions/SemanticMaps/SM_MapPrinter.php
@@ -109,6 +109,8 @@
110110 $lat = '';
111111 $lon = '';
112112
 113+ $coords = array();
 114+
113115 // Loop throught all fields of the record
114116 foreach ($row as $i => $field) {
115117 $pr = $field->getPrintRequest();
@@ -120,19 +122,27 @@
121123 }
122124
123125 if ($object->getTypeID() != '_geo' && $i != 0) {
124 - $text .= $pr->getHTMLText($skin) . ": " . $object->getLongText($outputmode, $skin) . "<br />";
 126+ $text .= $pr->getHTMLText($skin) . ': ' . $object->getLongText($outputmode, $skin) . '<br />';
125127 }
126128
127129 if ($pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo') {
128 - list($lat,$lon) = explode(',', $object->getXSDValue());
 130+ $coords[] = explode(',', $object->getXSDValue());
129131 }
130132 }
131133 }
132134
133 - if (strlen($lat) > 0 && strlen($lon) > 0) {
134 - $icon = $this->getLocationIcon($row);
135 - $this->m_locations[] = array($lat, $lon, $title, $text, $icon);
 135+ foreach ($coords as $coord) {
 136+ if (count($coord) == 2) {
 137+ list($lat, $lon) = $coord;
 138+
 139+ if (strlen($lat) > 0 && strlen($lon) > 0) {
 140+ $icon = $this->getLocationIcon($row);
 141+ $this->m_locations[] = array($lat, $lon, $title, $text, $icon);
 142+ }
 143+
 144+ }
136145 }
 146+
137147 }
138148
139149 /**
@@ -237,4 +247,8 @@
238248 $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr;
239249 }
240250
 251+ public final function getName() {
 252+ return wfMsg('maps_' . $this->serviceName);
 253+ }
 254+
241255 }
Index: trunk/extensions/SemanticMaps/SM_FormInput.php
@@ -20,6 +20,11 @@
2121 */
2222 protected abstract function manageGeocoding();
2323
 24+ /**
 25+ * Ensures all dependencies for the used map are loaded, and increases that map service's count
 26+ */
 27+ protected abstract function addFormDependencies();
 28+
2429 protected $marker_lat;
2530 protected $marker_lon;
2631
@@ -71,7 +76,7 @@
7277 $sfgTabIndex++;
7378
7479 // Retrieve language values
75 - wfLoadExtensionMessages( 'SemanticMaps' );
 80+ // wfLoadExtensionMessages( 'SemanticMaps' ); // TODO: remove?
7681 $enter_address_here_text = wfMsg('semanticmaps_enteraddresshere');
7782 $lookup_coordinates_text = wfMsg('semanticmaps_lookupcoordinates');
7883 $not_found_text = wfMsg('semanticmaps_notfound');
Index: trunk/extensions/SemanticMaps/SemanticMaps.i18n.php
@@ -22,21 +22,13 @@
2323 'semanticmaps_lookupcoordinates' => 'Look up coordinates',
2424 'semanticmaps_enteraddresshere' => 'Enter address here',
2525 'semanticmaps_notfound' => 'not found',
26 - 'sm_googlemaps_printername' => 'Google Maps',
27 - 'sm_yahoomaps_printername' => 'Yahoo! Maps',
28 - 'sm_openlayers_printername' => 'OpenLayers',
2926 );
3027
3128 /** Message documentation (Message documentation)
3229 * @author Raymond
3330 */
3431 $messages['qqq'] = array(
35 - 'semanticmaps_desc' => '{{desc}}
36 -
37 -* $1: a list of available map services',
38 - 'sm_googlemaps_printername' => '{{optional}}',
39 - 'sm_yahoomaps_printername' => '{{optional}}',
40 - 'sm_openlayers_printername' => '{{optional}}',
 32+ 'semanticmaps_desc' => '{{desc}}',
4133 );
4234
4335 /** Afrikaans (Afrikaans)
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -23,21 +23,27 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('SM_VERSION', '0.3.3');
 27+define('SM_VERSION', '0.3.4');
2828
29 -$smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
30 -$smgIP = $IP . '/extensions/SemanticMaps';
 29+$smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
 30+$smgIP = $IP . '/extensions/SemanticMaps';
 31+$smgIncludePath = $wgServer . $smgScriptPath;
3132
32 -$wgExtensionFunctions[] = 'smfSetup';
 33+// Add the extensions initializing function
 34+if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
 35+ $wgHooks['ParserFirstCallInit'][] = 'smfSetup';
 36+} else {
 37+ $wgExtensionFunctions[] = 'smfSetup'; // Legacy support
 38+}
3339
3440 $wgHooks['AdminLinks'][] = 'smfAddToAdminLinks';
3541
3642 $wgExtensionMessagesFiles['SemanticMaps'] = $smgIP . '/SemanticMaps.i18n.php';
3743
3844 // Autoload the general classes
39 -$wgAutoloadClasses['SMMapPrinter'] = $smgIP . '/SM_MapPrinter.php';
40 -$wgAutoloadClasses['SMMapper'] = $smgIP . '/SM_Mapper.php';
41 -$wgAutoloadClasses['SMFormInput'] = $smgIP . '/SM_FormInput.php';
 45+$wgAutoloadClasses['SMMapPrinter'] = $smgIP . '/SM_MapPrinter.php';
 46+$wgAutoloadClasses['SMMapper'] = $smgIP . '/SM_Mapper.php';
 47+$wgAutoloadClasses['SMFormInput'] = $smgIP . '/SM_FormInput.php';
4248
4349 // Add the services
4450 $egMapsServices['googlemaps']['qp'] = array('class' => 'SMGoogleMaps', 'file' => 'GoogleMaps/SM_GoogleMaps.php', 'local' => true);
@@ -55,27 +61,30 @@
5662 */
5763 function smfSetup() {
5864 global $wgExtensionCredits, $egMapsServices;
59 -
60 - $services_list = implode(', ', array_keys($egMapsServices));
6165
 66+ // Creation of a list of internationalized service names
 67+ $services = array();
 68+ foreach (array_keys($egMapsServices) as $name) $services[] = wfMsg('maps_'.$name);
 69+ $services_list = implode(', ', $services);
 70+
6271 wfLoadExtensionMessages( 'SemanticMaps' );
6372
6473 $wgExtensionCredits['other'][]= array(
6574 'path' => __FILE__,
6675 'name' => wfMsg('semanticmaps_name'),
6776 'version' => SM_VERSION,
68 - 'author' => array("[http://bn2vs.com Jeroen De Dauw]", "Yaron Koren", "Robert Buzink"),
 77+ 'author' => array('[http://bn2vs.com Jeroen De Dauw]', 'Yaron Koren', 'Robert Buzink'),
6978 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Maps',
7079 'description' => wfMsgExt( 'semanticmaps_desc', 'parsemag', $services_list ),
7180 'descriptionmsg' => wfMsgExt( 'semanticmaps_desc', 'parsemag', $services_list ),
7281 );
7382
74 - smfInitFormHook('map');
 83+ if (isset($sfgFormPrinter)) smfInitFormHook('map');
7584 smfInitFormat('map', array('class' => 'SMMapper', 'file' => 'SM_Mapper.php', 'local' => true));
7685
7786 foreach($egMapsServices as $serviceName => $serviceData) {
7887 $hasQP = array_key_exists('qp', $serviceData);
79 - $hasFI = array_key_exists('fi', $serviceData);
 88+ $hasFI = array_key_exists('fi', $serviceData) && isset($sfgFormPrinter);
8089
8190 // If the service has no QP and no FI, skipt it and continue with the next one.
8291 if (!$hasQP && !$hasFI) continue;
@@ -91,6 +100,7 @@
92101 }
93102 }
94103
 104+ return true;
95105 }
96106
97107 /**
@@ -167,16 +177,11 @@
168178
169179 $service_name = MapsMapper::getValidService($service_name, 'fi');
170180
171 - if (array_key_exists('fi', $egMapsServices[$service_name])) {
172 - $formInput = new $egMapsServices[$service_name]['fi']['class']();
173 -
174 - // Get and return the form input HTML from the hook corresponding with the provided service
175 - return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
176 - }
177 - else {
178 - return "<b>ERROR: Form input for ".$field_args['service']." not found</b>";
179 - }
 181+ $formInput = new $egMapsServices[$service_name]['fi']['class']();
180182
 183+ // Get and return the form input HTML from the hook corresponding with the provided service
 184+ return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
 185+
181186 }
182187
183188 /**
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFunctions.js
@@ -0,0 +1,65 @@
 2+ /**
 3+ * Javascript functions for Google Maps functionallity in Semantic Maps
 4+ *
 5+ * @file SM_GoogleMapFunctions.js
 6+ * @ingroup SemanticMaps
 7+ *
 8+ * @author Jeroen De Dauw
 9+ */
 10+
 11+/**
 12+ * This function holds spesific functionallity for the Google Maps form input of Semantic Maps
 13+ * TODO: Refactor as much code as possible to non specific functions
 14+ */
 15+function makeFormInputGoogleMap(mapName, locationFieldName, width, height, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon) {
 16+ if (GBrowserIsCompatible()) { // TODO: This function should probably be used after the loading of the G Maps API
 17+ var map = createGoogleMap(document.getElementById(mapName), new GSize(width, height), new GLatLng(lat, lon), zoom, type, types, controls, scrollWheelZoom, [getGMarkerData(marker_lat, marker_lon, '', '', '')]);
 18+
 19+ // Show a starting marker only if marker coordinates are provided
 20+ if (marker_lat != null && marker_lon != null) {
 21+ map.addOverlay(new GMarker(new GLatLng(marker_lat, marker_lon)));
 22+ }
 23+
 24+ // Click event handler for updating the location of the marker
 25+ GEvent.addListener(map, "click",
 26+ function(overlay, point) {
 27+ if (overlay) {
 28+ map.removeOverlay(overlay);
 29+ } else {
 30+ map.clearOverlays();
 31+ document.getElementById(locationFieldName).value = convertLatToDMS(point.y)+', '+convertLngToDMS(point.x);
 32+ map.addOverlay(new GMarker(point));
 33+ map.panTo(point);
 34+ }
 35+ }
 36+ );
 37+
 38+ // Make the map variable available for other functions
 39+ if (!window.GMaps) window.GMaps = new Object;
 40+ eval("window.GMaps." + mapName + " = map;");
 41+ }
 42+}
 43+
 44+/**
 45+ * This function holds spesific functionallity for the Google Maps form input of Semantic Maps
 46+ * TODO: Refactor as much code as possible to non specific functions
 47+ */
 48+function showGAddress(address, mapName, outputElementName, notFoundFormat) {
 49+ var map = GMaps[mapName];
 50+ var geocoder = new GClientGeocoder();
 51+
 52+ geocoder.getLatLng(address,
 53+ function(point) {
 54+ if (!point) {
 55+ window.alert(address + ' ' + notFoundFormat);
 56+ } else {
 57+ map.clearOverlays();
 58+ map.setCenter(point, 14);
 59+ var marker = new GMarker(point);
 60+ map.addOverlay(marker);
 61+ document.getElementById(outputElementName).value = convertLatToDMS(point.y) + ', ' + convertLngToDMS(point.x);
 62+ }
 63+ }
 64+ );
 65+
 66+}
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMaps.php
@@ -18,11 +18,6 @@
1919
2020 public $serviceName = MapsGoogleMaps::SERVICE_NAME;
2121
22 - public function getName() {
23 - wfLoadExtensionMessages('SemanticMaps');
24 - return wfMsg('sm_googlemaps_printername');
25 - }
26 -
2722 /**
2823 * @see SMMapPrinter::setQueryPrinterSettings()
2924 *
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php
@@ -35,21 +35,35 @@
3636 $this->defaultZoom = $egMapsGoogleMapsZoom;
3737 }
3838
39 -
4039 /**
 40+ * @see MapsMapFeature::addFormDependencies()
 41+ *
 42+ * @param string $output
 43+ */
 44+ protected function addFormDependencies(&$output) {
 45+ global $wgJsMimeType;
 46+ global $smgIncludePath, $smgGoogleFormsOnThisPage;
 47+
 48+ MapsGoogleMapsUtils::addGMapDependencies($output);
 49+
 50+ if (empty($smgGoogleFormsOnThisPage)) {
 51+ $smgGoogleFormsOnThisPage = 0;
 52+ $output .= "<script type='$wgJsMimeType' src='$smgIncludePath/GoogleMaps/SM_GoogleMapFunctions.js'></script>";
 53+ }
 54+ }
 55+
 56+ /**
4157 * @see MapsMapFeature::doMapServiceLoad()
4258 *
4359 */
4460 protected function doMapServiceLoad() {
45 - global $egGoogleMapsOnThisPage;
46 -
47 - if (empty($egGoogleMapsOnThisPage)) {
48 - $egGoogleMapsOnThisPage = 0;
49 - MapsGoogleMapsUtils::addGMapDependencies($this->output);
50 - }
 61+ global $egGoogleMapsOnThisPage, $smgGoogleFormsOnThisPage;
5162
52 - $egGoogleMapsOnThisPage++;
 63+ self::addFormDependencies($this->output);
5364
 65+ $egGoogleMapsOnThisPage++;
 66+ $smgGoogleFormsOnThisPage++;
 67+
5468 $this->elementNr = $egGoogleMapsOnThisPage;
5569 }
5670

Status & tagging log