Index: trunk/extensions/SlippyMap/SlippyMap.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | # the OpenLayers javascript, to show a slippy map. |
9 | 9 | # |
10 | 10 | # 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> |
12 | 12 | # |
13 | 13 | # Tile images are not cached local to the wiki. |
14 | 14 | # To acheive this (remove the OSM dependency) you might set up a squid proxy, |
— | — | @@ -15,14 +15,13 @@ |
16 | 16 | # |
17 | 17 | # This file should be placed in the mediawiki 'extensions' directory |
18 | 18 | # ...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 |
20 | 19 | |
21 | 20 | if( defined( 'MEDIAWIKI' ) ) { |
22 | 21 | $wgExtensionFunctions[] = 'wfslippymap'; |
23 | 22 | |
24 | 23 | $wgExtensionCredits['parserhook'][] = array( |
25 | 24 | 'name' => 'OpenStreetMap Slippy Map', |
26 | | - 'author' => '[http://harrywood.co.uk Harry Wood]', |
| 25 | + 'author' => '[http://harrywood.co.uk Harry Wood], Jens Frank', |
27 | 26 | 'svn-date' => '$LastChangedDate$', |
28 | 27 | 'svn-revision' => '$LastChangedRevision$', |
29 | 28 | 'url' => 'http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension', |
Index: trunk/extensions/SlippyMap/SlippyMap.class.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | # the OpenLayers javascript, to show a slippy map. |
9 | 9 | # |
10 | 10 | # 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> |
12 | 12 | # |
13 | 13 | # Tile images are not cached local to the wiki. |
14 | 14 | # To acheive this (remove the OSM dependency) you might set up a squid proxy, |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | # |
17 | 17 | # This file should be placed in the mediawiki 'extensions' directory |
18 | 18 | # ...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 |
20 | 19 | |
21 | 20 | class SlippyMap { |
22 | 21 | |
— | — | @@ -23,31 +22,19 @@ |
24 | 23 | } |
25 | 24 | |
26 | 25 | # The callback function for converting the input text to HTML output |
27 | | - function parse( $input ) { |
| 26 | + function parse( $input, $argv ) { |
28 | 27 | global $wgMapOfServiceUrl, $wgSlippyMapVersion; |
29 | 28 | |
30 | 29 | wfLoadExtensionMessages( 'SlippyMap' ); |
31 | 30 | |
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']; |
43 | 38 | |
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 | | - |
52 | 39 | $error=""; |
53 | 40 | |
54 | 41 | //default values (meaning these parameters can be missed out) |
— | — | @@ -55,7 +42,7 @@ |
56 | 43 | if ($height=='') $height='320'; |
57 | 44 | if ($layer=='') $layer='mapnik'; |
58 | 45 | |
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) |
60 | 47 | |
61 | 48 | $marker = ( $marker != '' && $marker != '0' ); |
62 | 49 | |
— | — | @@ -67,7 +54,7 @@ |
68 | 55 | if ( $lat=='' ) $error .= wfMsg( 'slippymap_latmissing' ); |
69 | 56 | if ( $lon=='' ) $error .= wfMsg( 'slippymap_lonmissing' ); |
70 | 57 | if ( $zoom=='' ) $error .= wfMsg( 'slippymap_zoommissing' ); |
71 | | - if ( isset( $params['long'] ) ) $error .= wfMsg( 'slippymap_longdepreciated' ); |
| 58 | + if ( isset( $argv['long'] ) ) $error .= wfMsg( 'slippymap_longdepreciated' ); |
72 | 59 | |
73 | 60 | if ($error=='') { |
74 | 61 | //no errors so far. Now check the values |
— | — | @@ -209,7 +196,7 @@ |
210 | 197 | $output .= ' LL = MercatorToLonLat(map.getCenter()); Z = map.getZoom();'; |
211 | 198 | $output .= ' size = map.getSize();'; |
212 | 199 | |
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>" ); '; |
214 | 201 | $output .= '}'; |
215 | 202 | |
216 | 203 | $output .= "</script> "; |