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 @@ |
17 | 17 | |
18 | 18 | public $serviceName = MapsYahooMaps::SERVICE_NAME; |
19 | 19 | |
20 | | - public function getName() { |
21 | | - wfLoadExtensionMessages('SemanticMaps'); |
22 | | - return wfMsg('sm_yahoomaps_printername'); |
23 | | - } |
24 | | - |
25 | 20 | /** |
26 | 21 | * @see SMMapPrinter::setQueryPrinterSettings() |
27 | 22 | * |
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -34,18 +34,34 @@ |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
| 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 | + /** |
38 | 55 | * @see MapsMapFeature::doMapServiceLoad() |
39 | 56 | * |
40 | 57 | */ |
41 | 58 | protected function doMapServiceLoad() { |
42 | | - global $egYahooMapsOnThisPage; |
| 59 | + global $egYahooMapsOnThisPage, $smgYahooFormsOnThisPage; |
43 | 60 | |
44 | | - if (empty($egYahooMapsOnThisPage)) { |
45 | | - $egYahooMapsOnThisPage = 0; |
46 | | - MapsYahooMapsUtils::addYMapDependencies($this->output); |
47 | | - } |
48 | | - $egYahooMapsOnThisPage++; |
| 61 | + self::addFormDependencies($this->output); |
49 | 62 | |
| 63 | + $egYahooMapsOnThisPage++; |
| 64 | + $smgYahooFormsOnThisPage++; |
| 65 | + |
50 | 66 | $this->elementNr = $egYahooMapsOnThisPage; |
51 | 67 | } |
52 | 68 | |
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 @@ |
18 | 18 | |
19 | 19 | public $serviceName = MapsOpenLayers::SERVICE_NAME; |
20 | 20 | |
21 | | - public function getName() { |
22 | | - wfLoadExtensionMessages('SemanticMaps'); |
23 | | - return wfMsg('sm_openlayers_printername'); |
24 | | - } |
25 | | - |
26 | 21 | /** |
27 | 22 | * @see SMMapPrinter::setQueryPrinterSettings() |
28 | 23 | * |
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -34,14 +34,33 @@ |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
| 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 | + /** |
38 | 55 | * @see MapsMapFeature::doMapServiceLoad() |
39 | 56 | * |
40 | 57 | */ |
41 | 58 | protected function doMapServiceLoad() { |
42 | | - global $egOpenLayersOnThisPage; |
| 59 | + global $egOpenLayersOnThisPage, $smgOLFormsOnThisPage; |
43 | 60 | |
44 | | - MapsOpenLayersUtils::addOLDependencies($this->output); |
| 61 | + self::addFormDependencies($this->output); |
| 62 | + |
45 | 63 | $egOpenLayersOnThisPage++; |
| 64 | + $smgOLFormsOnThisPage++; |
46 | 65 | |
47 | 66 | $this->elementNr = $egOpenLayersOnThisPage; |
48 | 67 | } |
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 @@ |
110 | 110 | $lat = ''; |
111 | 111 | $lon = ''; |
112 | 112 | |
| 113 | + $coords = array(); |
| 114 | + |
113 | 115 | // Loop throught all fields of the record |
114 | 116 | foreach ($row as $i => $field) { |
115 | 117 | $pr = $field->getPrintRequest(); |
— | — | @@ -120,19 +122,27 @@ |
121 | 123 | } |
122 | 124 | |
123 | 125 | 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 />'; |
125 | 127 | } |
126 | 128 | |
127 | 129 | if ($pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo') { |
128 | | - list($lat,$lon) = explode(',', $object->getXSDValue()); |
| 130 | + $coords[] = explode(',', $object->getXSDValue()); |
129 | 131 | } |
130 | 132 | } |
131 | 133 | } |
132 | 134 | |
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 | + } |
136 | 145 | } |
| 146 | + |
137 | 147 | } |
138 | 148 | |
139 | 149 | /** |
— | — | @@ -237,4 +247,8 @@ |
238 | 248 | $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr; |
239 | 249 | } |
240 | 250 | |
| 251 | + public final function getName() { |
| 252 | + return wfMsg('maps_' . $this->serviceName); |
| 253 | + } |
| 254 | + |
241 | 255 | } |
Index: trunk/extensions/SemanticMaps/SM_FormInput.php |
— | — | @@ -20,6 +20,11 @@ |
21 | 21 | */ |
22 | 22 | protected abstract function manageGeocoding(); |
23 | 23 | |
| 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 | + |
24 | 29 | protected $marker_lat; |
25 | 30 | protected $marker_lon; |
26 | 31 | |
— | — | @@ -71,7 +76,7 @@ |
72 | 77 | $sfgTabIndex++; |
73 | 78 | |
74 | 79 | // Retrieve language values |
75 | | - wfLoadExtensionMessages( 'SemanticMaps' ); |
| 80 | + // wfLoadExtensionMessages( 'SemanticMaps' ); // TODO: remove? |
76 | 81 | $enter_address_here_text = wfMsg('semanticmaps_enteraddresshere'); |
77 | 82 | $lookup_coordinates_text = wfMsg('semanticmaps_lookupcoordinates'); |
78 | 83 | $not_found_text = wfMsg('semanticmaps_notfound'); |
Index: trunk/extensions/SemanticMaps/SemanticMaps.i18n.php |
— | — | @@ -22,21 +22,13 @@ |
23 | 23 | 'semanticmaps_lookupcoordinates' => 'Look up coordinates', |
24 | 24 | 'semanticmaps_enteraddresshere' => 'Enter address here', |
25 | 25 | 'semanticmaps_notfound' => 'not found', |
26 | | - 'sm_googlemaps_printername' => 'Google Maps', |
27 | | - 'sm_yahoomaps_printername' => 'Yahoo! Maps', |
28 | | - 'sm_openlayers_printername' => 'OpenLayers', |
29 | 26 | ); |
30 | 27 | |
31 | 28 | /** Message documentation (Message documentation) |
32 | 29 | * @author Raymond |
33 | 30 | */ |
34 | 31 | $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}}', |
41 | 33 | ); |
42 | 34 | |
43 | 35 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -23,21 +23,27 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
27 | | -define('SM_VERSION', '0.3.3'); |
| 27 | +define('SM_VERSION', '0.3.4'); |
28 | 28 | |
29 | | -$smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps'; |
30 | | -$smgIP = $IP . '/extensions/SemanticMaps'; |
| 29 | +$smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps'; |
| 30 | +$smgIP = $IP . '/extensions/SemanticMaps'; |
| 31 | +$smgIncludePath = $wgServer . $smgScriptPath; |
31 | 32 | |
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 | +} |
33 | 39 | |
34 | 40 | $wgHooks['AdminLinks'][] = 'smfAddToAdminLinks'; |
35 | 41 | |
36 | 42 | $wgExtensionMessagesFiles['SemanticMaps'] = $smgIP . '/SemanticMaps.i18n.php'; |
37 | 43 | |
38 | 44 | // 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'; |
42 | 48 | |
43 | 49 | // Add the services |
44 | 50 | $egMapsServices['googlemaps']['qp'] = array('class' => 'SMGoogleMaps', 'file' => 'GoogleMaps/SM_GoogleMaps.php', 'local' => true); |
— | — | @@ -55,27 +61,30 @@ |
56 | 62 | */ |
57 | 63 | function smfSetup() { |
58 | 64 | global $wgExtensionCredits, $egMapsServices; |
59 | | - |
60 | | - $services_list = implode(', ', array_keys($egMapsServices)); |
61 | 65 | |
| 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 | + |
62 | 71 | wfLoadExtensionMessages( 'SemanticMaps' ); |
63 | 72 | |
64 | 73 | $wgExtensionCredits['other'][]= array( |
65 | 74 | 'path' => __FILE__, |
66 | 75 | 'name' => wfMsg('semanticmaps_name'), |
67 | 76 | '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'), |
69 | 78 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Maps', |
70 | 79 | 'description' => wfMsgExt( 'semanticmaps_desc', 'parsemag', $services_list ), |
71 | 80 | 'descriptionmsg' => wfMsgExt( 'semanticmaps_desc', 'parsemag', $services_list ), |
72 | 81 | ); |
73 | 82 | |
74 | | - smfInitFormHook('map'); |
| 83 | + if (isset($sfgFormPrinter)) smfInitFormHook('map'); |
75 | 84 | smfInitFormat('map', array('class' => 'SMMapper', 'file' => 'SM_Mapper.php', 'local' => true)); |
76 | 85 | |
77 | 86 | foreach($egMapsServices as $serviceName => $serviceData) { |
78 | 87 | $hasQP = array_key_exists('qp', $serviceData); |
79 | | - $hasFI = array_key_exists('fi', $serviceData); |
| 88 | + $hasFI = array_key_exists('fi', $serviceData) && isset($sfgFormPrinter); |
80 | 89 | |
81 | 90 | // If the service has no QP and no FI, skipt it and continue with the next one. |
82 | 91 | if (!$hasQP && !$hasFI) continue; |
— | — | @@ -91,6 +100,7 @@ |
92 | 101 | } |
93 | 102 | } |
94 | 103 | |
| 104 | + return true; |
95 | 105 | } |
96 | 106 | |
97 | 107 | /** |
— | — | @@ -167,16 +177,11 @@ |
168 | 178 | |
169 | 179 | $service_name = MapsMapper::getValidService($service_name, 'fi'); |
170 | 180 | |
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'](); |
180 | 182 | |
| 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 | + |
181 | 186 | } |
182 | 187 | |
183 | 188 | /** |
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 @@ |
19 | 19 | |
20 | 20 | public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
21 | 21 | |
22 | | - public function getName() { |
23 | | - wfLoadExtensionMessages('SemanticMaps'); |
24 | | - return wfMsg('sm_googlemaps_printername'); |
25 | | - } |
26 | | - |
27 | 22 | /** |
28 | 23 | * @see SMMapPrinter::setQueryPrinterSettings() |
29 | 24 | * |
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -35,21 +35,35 @@ |
36 | 36 | $this->defaultZoom = $egMapsGoogleMapsZoom; |
37 | 37 | } |
38 | 38 | |
39 | | - |
40 | 39 | /** |
| 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 | + /** |
41 | 57 | * @see MapsMapFeature::doMapServiceLoad() |
42 | 58 | * |
43 | 59 | */ |
44 | 60 | protected function doMapServiceLoad() { |
45 | | - global $egGoogleMapsOnThisPage; |
46 | | - |
47 | | - if (empty($egGoogleMapsOnThisPage)) { |
48 | | - $egGoogleMapsOnThisPage = 0; |
49 | | - MapsGoogleMapsUtils::addGMapDependencies($this->output); |
50 | | - } |
| 61 | + global $egGoogleMapsOnThisPage, $smgGoogleFormsOnThisPage; |
51 | 62 | |
52 | | - $egGoogleMapsOnThisPage++; |
| 63 | + self::addFormDependencies($this->output); |
53 | 64 | |
| 65 | + $egGoogleMapsOnThisPage++; |
| 66 | + $smgGoogleFormsOnThisPage++; |
| 67 | + |
54 | 68 | $this->elementNr = $egGoogleMapsOnThisPage; |
55 | 69 | } |
56 | 70 | |