r74982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74981‎ | r74982 | r74983 >
Date:23:51, 18 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7.1 - Fixed issues with OpenLayers form input
Modified paths:
  • /trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/services/OpenLayers/SM_OpenLayersForms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/services/OpenLayers/SM_OpenLayersForms.js
@@ -71,14 +71,17 @@
7272 *
7373 * @param mapName Name of the map as in OLMaps[mapName].
7474 * @param newLocation The location for the new marker.
75 - * @return
7675 */
7776 function replaceMarker(mapName, newLocation) {
7877 var map = OLMaps[mapName];
7978 var markerLayer = map.getLayer('markerLayer');
8079
8180 removeMarkers(markerLayer);
82 - markerLayer.addMarker(getOLMarker(markerLayer, getOLMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject()));
 81+ markerLayer.addMarker(getOLMarker(
 82+ markerLayer,
 83+ { lonlat:newLocation, title: "", label:"", icon:"" },
 84+ map.getProjectionObject())
 85+ );
8386
8487 map.panTo(newLocation);
8588 }
Index: trunk/extensions/SemanticMaps/includes/forminputs/SM_FormInput.php
@@ -183,6 +183,29 @@
184184
185185 $geocodingFunction = $this->getShowAddressFunction();
186186
 187+ static $addedFormJs = false;
 188+ if ( !$addedFormJs ) {
 189+ global $wgOut;
 190+ $addedFormJs = true;
 191+
 192+ $n = Xml::escapeJsString( wfMsgForContent( 'maps-abb-north' ) );
 193+ $e = Xml::escapeJsString( wfMsgForContent( 'maps-abb-east' ) );
 194+ $s = Xml::escapeJsString( wfMsgForContent( 'maps-abb-south' ) );
 195+ $w = Xml::escapeJsString( wfMsgForContent( 'maps-abb-west' ) );
 196+ $deg = Xml::escapeJsString( MapsCoordinateParser::SYMBOL_DEG );
 197+
 198+ $wgOut->addInlineScript(
 199+ <<<EOT
 200+function convertLatToDMS (val) {
 201+ return Math.abs(val) + "$deg " + ( val < 0 ? "$s" : "$n" );
 202+}
 203+function convertLngToDMS (val) {
 204+ return Math.abs(val) + "$deg " + ( val < 0 ? "$w" : "$e" );
 205+}
 206+EOT
 207+ );
 208+ }
 209+
187210 // Create the non specific form HTML.
188211 $this->output .= Html::input(
189212 $input_name,
@@ -205,7 +228,7 @@
206229
207230 if ( $geocodingFunction !== false ) {
208231 $this->addGeocodingField( $geocodingFunction, $mapName, $mapName . '_geocode_' . $sfgTabIndex );
209 - }
 232+ }
210233
211234 if ( $this->markerCoords === false ) {
212235 $this->markerCoords = array(
@@ -233,30 +256,9 @@
234257 * @param string $geocodeFieldName
235258 */
236259 private function addGeocodingField( $geocodingFunction, $mapName, $geocodeFieldId ) {
237 - global $sfgTabIndex, $wgOut, $smgAddedFormJs;
 260+ global $sfgTabIndex;
238261 $sfgTabIndex++;
239262
240 - if ( !$smgAddedFormJs ) {
241 - $smgAddedFormJs = true;
242 -
243 - $n = Xml::escapeJsString( wfMsgForContent( 'maps-abb-north' ) );
244 - $e = Xml::escapeJsString( wfMsgForContent( 'maps-abb-east' ) );
245 - $s = Xml::escapeJsString( wfMsgForContent( 'maps-abb-south' ) );
246 - $w = Xml::escapeJsString( wfMsgForContent( 'maps-abb-west' ) );
247 - $deg = Xml::escapeJsString( MapsCoordinateParser::SYMBOL_DEG );
248 -
249 - $wgOut->addInlineScript(
250 - <<<EOT
251 -function convertLatToDMS (val) {
252 - return Math.abs(val) + "$deg " + ( val < 0 ? "$s" : "$n" );
253 -}
254 -function convertLngToDMS (val) {
255 - return Math.abs(val) + "$deg " + ( val < 0 ? "$w" : "$e" );
256 -}
257 -EOT
258 - );
259 - }
260 -
261263 $adressField = SMFormInput::getDynamicInput(
262264 'geocode',
263265 wfMsg( 'semanticmaps_enteraddresshere' ),

Status & tagging log