r37003 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37002‎ | r37003 | r37004 >
Date:20:13, 3 July 2008
Author:jeluf
Status:old
Tags:
Comment:
Changed the extension syntax.
This change is not backwards comaptible.
New syntax:
<slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender marker=0></slippymap>
Modified paths:
  • /trunk/extensions/SlippyMap/SlippyMap.class.php (modified) (history)
  • /trunk/extensions/SlippyMap/SlippyMap.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SlippyMap/SlippyMap.php
@@ -7,7 +7,7 @@
88 # the OpenLayers javascript, to show a slippy map.
99 #
1010 # Usage example:
11 -# <slippymap>lat=51.485|lon=-0.15|z=11|w=300|h=200|layer=osmarender</slippymap>
 11+# <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender></slippymap>
1212 #
1313 # Tile images are not cached local to the wiki.
1414 # To acheive this (remove the OSM dependency) you might set up a squid proxy,
@@ -15,14 +15,13 @@
1616 #
1717 # This file should be placed in the mediawiki 'extensions' directory
1818 # ...and then it needs to be 'included' within LocalSettings.php
19 -# OpenLayers.js and get_osm_url.js must also be placed in the extensions directory
2019
2120 if( defined( 'MEDIAWIKI' ) ) {
2221 $wgExtensionFunctions[] = 'wfslippymap';
2322
2423 $wgExtensionCredits['parserhook'][] = array(
2524 'name' => 'OpenStreetMap Slippy Map',
26 - 'author' => '[http://harrywood.co.uk Harry Wood]',
 25+ 'author' => '[http://harrywood.co.uk Harry Wood], Jens Frank',
2726 'svn-date' => '$LastChangedDate$',
2827 'svn-revision' => '$LastChangedRevision$',
2928 'url' => 'http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension',
Index: trunk/extensions/SlippyMap/SlippyMap.class.php
@@ -7,7 +7,7 @@
88 # the OpenLayers javascript, to show a slippy map.
99 #
1010 # Usage example:
11 -# <slippymap>lat=51.485|lon=-0.15|z=11|w=300|h=200|layer=osmarender|marker=0</slippymap>
 11+# <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender marker=0></slippymap>
1212 #
1313 # Tile images are not cached local to the wiki.
1414 # To acheive this (remove the OSM dependency) you might set up a squid proxy,
@@ -15,7 +15,6 @@
1616 #
1717 # This file should be placed in the mediawiki 'extensions' directory
1818 # ...and then it needs to be 'included' within LocalSettings.php
19 -# OpenLayers.js and get_osm_url.js must also be placed in the extensions directory
2019
2120 class SlippyMap {
2221
@@ -23,31 +22,19 @@
2423 }
2524
2625 # The callback function for converting the input text to HTML output
27 - function parse( $input ) {
 26+ function parse( $input, $argv ) {
2827 global $wgMapOfServiceUrl, $wgSlippyMapVersion;
2928
3029 wfLoadExtensionMessages( 'SlippyMap' );
3130
32 - //Parse pipe separated name value pairs (e.g. 'aaa=bbb|ccc=ddd')
33 - $paramStrings=explode('|',$input);
34 - foreach ($paramStrings as $paramString) {
35 - $paramString = trim($paramString);
36 - $eqPos = strpos($paramString,"=");
37 - if ($eqPos===false) {
38 - $params[$paramString] = "true";
39 - } else {
40 - $params[substr($paramString,0,$eqPos)] = trim(htmlspecialchars(substr($paramString,$eqPos+1)));
41 - }
42 - }
 31+ $lat = $argv['lat'];
 32+ $lon = $argv['lon'];
 33+ $zoom = $argv['z'];
 34+ $width = $argv['w'];
 35+ $height = $argv['h'];
 36+ $layer = $argv['layer'];
 37+ $marker = $argv['marker'];
4338
44 - $lat = $params['lat'];
45 - $lon = $params['lon'];
46 - $zoom = $params['z'];
47 - $width = $params['w'];
48 - $height = $params['h'];
49 - $layer = $params['layer'];
50 - $marker = $params['marker'];
51 -
5239 $error="";
5340
5441 //default values (meaning these parameters can be missed out)
@@ -55,7 +42,7 @@
5643 if ($height=='') $height='320';
5744 if ($layer=='') $layer='mapnik';
5845
59 - if ($zoom=='') $zoom = $params['zoom']; //see if they used 'zoom' rather than 'z' (and allow it)
 46+ if ($zoom=='') $zoom = $argv['zoom']; //see if they used 'zoom' rather than 'z' (and allow it)
6047
6148 $marker = ( $marker != '' && $marker != '0' );
6249
@@ -67,7 +54,7 @@
6855 if ( $lat=='' ) $error .= wfMsg( 'slippymap_latmissing' );
6956 if ( $lon=='' ) $error .= wfMsg( 'slippymap_lonmissing' );
7057 if ( $zoom=='' ) $error .= wfMsg( 'slippymap_zoommissing' );
71 - if ( isset( $params['long'] ) ) $error .= wfMsg( 'slippymap_longdepreciated' );
 58+ if ( isset( $argv['long'] ) ) $error .= wfMsg( 'slippymap_longdepreciated' );
7259
7360 if ($error=='') {
7461 //no errors so far. Now check the values
@@ -209,7 +196,7 @@
210197 $output .= ' LL = MercatorToLonLat(map.getCenter()); Z = map.getZoom();';
211198 $output .= ' size = map.getSize();';
212199
213 - $output .= ' prompt( "' . wfMsg('slippymap_code') .'", "<slippymap>h="+size.h+"|w="+size.w+"|z="+Z+"|lat="+LL.lat+"|lon="+LL.lon+"|layer=mapnik|marker=1</slippymap>" ); ';
 200+ $output .= ' prompt( "' . wfMsg('slippymap_code') .'", "<slippymap h="+size.h+" w="+size.w+" z="+Z+" lat="+LL.lat+" lon="+LL.lon+" layer=mapnik marker=1></slippymap>" ); ';
214201 $output .= '}';
215202
216203 $output .= "</script> ";

Status & tagging log