Revision: 43480
Author: siebrand
Date: 2008-11-14 09:21:25 +0000 (Fri, 14 Nov 2008)
Log Message:
-----------
stylize.php for SlippyMap
Modified Paths:
--------------
trunk/extensions/SlippyMap/SlippyMap.class.php
trunk/extensions/SlippyMap/SlippyMap.php
Modified: trunk/extensions/SlippyMap/SlippyMap.class.php
===================================================================
--- trunk/extensions/SlippyMap/SlippyMap.class.php 2008-11-14 09:01:10 UTC
(rev 43479)
+++ trunk/extensions/SlippyMap/SlippyMap.class.php 2008-11-14 09:21:25 UTC
(rev 43480)
@@ -16,7 +16,7 @@
# This file should be placed in the mediawiki 'extensions' directory
# ...and then it needs to be 'included' within LocalSettings.php
#
-##################################################################################
+#
#################################################################################
#
# Copyright 2008 Harry Wood, Jens Frank, Grant Slater, Raymond Spekking and
others
#
@@ -47,21 +47,21 @@
wfLoadExtensionMessages( 'SlippyMap' );
- //Support old style parameters from $input
- //Parse the pipe separated name value pairs (e.g.
'aaa=bbb|ccc=ddd')
- //With the new syntax we expect nothing in the $input, so this
will result in '' values
- $oldStyleParamStrings=explode('|',$input);
- foreach ($oldStyleParamStrings as $oldStyleParamString) {
- $oldStyleParamString = trim($oldStyleParamString);
- $eqPos = strpos($oldStyleParamString,"=");
- if ($eqPos===false) {
+ // Support old style parameters from $input
+ // Parse the pipe separated name value pairs (e.g.
'aaa=bbb|ccc=ddd')
+ // With the new syntax we expect nothing in the $input, so this
will result in '' values
+ $oldStyleParamStrings = explode( '|', $input );
+ foreach ( $oldStyleParamStrings as $oldStyleParamString ) {
+ $oldStyleParamString = trim( $oldStyleParamString );
+ $eqPos = strpos( $oldStyleParamString, "=" );
+ if ( $eqPos === false ) {
$oldStyleParams[$oldStyleParamString] = "true";
} else {
-
$oldStyleParams[substr($oldStyleParamString,0,$eqPos)] =
trim(htmlspecialchars(substr($oldStyleParamString,$eqPos+1)));
+ $oldStyleParams[substr( $oldStyleParamString,
0, $eqPos )] = trim( htmlspecialchars( substr( $oldStyleParamString, $eqPos + 1
) ) );
}
}
- //Receive new style args: <slippymap aaa=bbb
ccc=ddd></slippymap>
+ // Receive new style args: <slippymap aaa=bbb
ccc=ddd></slippymap>
if ( isset( $argv['lat'] ) ) {
$lat = $argv['lat'];
} else {
@@ -98,106 +98,106 @@
$marker = '';
}
- $error='';
+ $error = '';
- //default values (meaning these parameters can be missed out)
- if ($width=='') $width ='450';
- if ($height=='') $height='320';
- if ($layer=='') $layer='mapnik';
+ // default values (meaning these parameters can be missed out)
+ if ( $width == '' ) $width = '450';
+ if ( $height == '' ) $height = '320';
+ if ( $layer == '' ) $layer = 'mapnik';
- if ($zoom=='' && isset( $argv['zoom'] ) ) {
- $zoom = $argv['zoom']; //see if they used 'zoom' rather
than 'z' (and allow it)
+ if ( $zoom == '' && isset( $argv['zoom'] ) ) {
+ $zoom = $argv['zoom']; // see if they used 'zoom'
rather than 'z' (and allow it)
}
$marker = ( $marker != '' && $marker != '0' );
- //trim off the 'px' on the end of pixel measurement numbers
(ignore if present)
- if (substr($width,-2)=='px') $width = (int)
substr($width,0,-2);
- if (substr($height,-2)=='px') $height = (int)
substr($height,0,-2);
+ // trim off the 'px' on the end of pixel measurement numbers
(ignore if present)
+ if ( substr( $width, -2 ) == 'px' ) $width = (int) substr(
$width, 0, -2 );
+ if ( substr( $height, -2 ) == 'px' ) $height = (int) substr(
$height, 0, -2 );
- if (trim($input)!='' && sizeof($oldStyleParamStrings)<3) {
- $error = 'slippymap tag contents. Were you trying to
input KML? KML support '.
+ if ( trim( $input ) != '' && sizeof( $oldStyleParamStrings ) <
3 ) {
+ $error = 'slippymap tag contents. Were you trying to
input KML? KML support ' .
'is disactivated on the OSM wiki pending
discussions about wiki syntax';
$showkml = false;
} else {
$showkml = false;
}
- if ($marker) $error = 'marker support is disactivated on the
OSM wiki pending discussions about wiki syntax';
+ if ( $marker ) $error = 'marker support is disactivated on the
OSM wiki pending discussions about wiki syntax';
- //Check required parameters values are provided
- if ( $lat=='' ) $error .= wfMsg( 'slippymap_latmissing' );
- if ( $lon=='' ) $error .= wfMsg( 'slippymap_lonmissing' );
- if ( $zoom=='' ) $error .= wfMsg( 'slippymap_zoommissing' );
+ // Check required parameters values are provided
+ if ( $lat == '' ) $error .= wfMsg( 'slippymap_latmissing' );
+ if ( $lon == '' ) $error .= wfMsg( 'slippymap_lonmissing' );
+ if ( $zoom == '' ) $error .= wfMsg( 'slippymap_zoommissing' );
- if ($error=='') {
- //no errors so far. Now check the values
- if (!is_numeric($width)) {
+ if ( $error == '' ) {
+ // no errors so far. Now check the values
+ if ( !is_numeric( $width ) ) {
$error = wfMsg( 'slippymap_widthnan', $width );
- } else if (!is_numeric($height)) {
+ } else if ( !is_numeric( $height ) ) {
$error = wfMsg( 'slippymap_heightnan', $height
);
- } else if (!is_numeric($zoom)) {
+ } else if ( !is_numeric( $zoom ) ) {
$error = wfMsg( 'slippymap_zoomnan', $zoom );
- } else if (!is_numeric($lat)) {
+ } else if ( !is_numeric( $lat ) ) {
$error = wfMsg( 'slippymap_latnan', $lat );
- } else if (!is_numeric($lon)) {
+ } else if ( !is_numeric( $lon ) ) {
$error = wfMsg( 'slippymap_lonnan', $lon );
- } else if ($width>1000) {
+ } else if ( $width > 1000 ) {
$error = wfMsg( 'slippymap_widthbig' );
- } else if ($width<100) {
+ } else if ( $width < 100 ) {
$error = wfMsg( 'slippymap_widthsmall' );
- } else if ($height>1000) {
+ } else if ( $height > 1000 ) {
$error = wfMsg( 'slippymap_heightbig' );
- } else if ($height<100) {
+ } else if ( $height < 100 ) {
$error = wfMsg( 'slippymap_heightsmall' );
- } else if ($lat>90) {
+ } else if ( $lat > 90 ) {
$error = wfMsg( 'slippymap_latbig' );
- } else if ($lat<-90) {
+ } else if ( $lat < -90 ) {
$error = wfMsg( 'slippymap_latsmall' );
- } else if ($lon>180) {
+ } else if ( $lon > 180 ) {
$error = wfMsg( 'slippymap_lonbig' );
- } else if ($lon<-180) {
+ } else if ( $lon < -180 ) {
$error = wfMsg( 'slippymap_lonsmall' );
- } else if ($zoom<0) {
+ } else if ( $zoom < 0 ) {
$error = wfMsg( 'slippymap_zoomsmall' );
- } else if ($zoom==18) {
+ } else if ( $zoom == 18 ) {
$error = wfMsg( 'slippymap_zoom18' );
- } else if ($zoom>17) {
+ } else if ( $zoom > 17 ) {
$error = wfMsg( 'slippymap_zoombig' );
}
}
- //Find the tile server URL to use. Note that we could allow
the user to override that with
- //*any* tile server URL for more flexibility, but that might be
a security concern.
+ // Find the tile server URL to use. Note that we could allow
the user to override that with
+ // *any* tile server URL for more flexibility, but that might
be a security concern.
- $layer = strtolower($layer);
+ $layer = strtolower( $layer );
$layerObjectDef = '';
- if ($layer=='osmarender') {
+ if ( $layer == 'osmarender' ) {
$layerObjectDef =
'OpenLayers.Layer.OSM.Osmarender("Osmarender"); ';
- } elseif ($layer=='mapnik') {
+ } elseif ( $layer == 'mapnik' ) {
$layerObjectDef =
'OpenLayers.Layer.OSM.Mapnik("Mapnik"); ';
- } elseif ($layer=='maplint') {
+ } elseif ( $layer == 'maplint' ) {
$layerObjectDef =
'OpenLayers.Layer.OSM.Maplint("Maplint"); ';
} else {
- $error = wfMsg( 'slippymap_invalidlayer',
htmlspecialchars($layer) );
+ $error = wfMsg( 'slippymap_invalidlayer',
htmlspecialchars( $layer ) );
}
- if ($error!="") {
- //Something was wrong. Spew the error message and input
text.
+ if ( $error != "" ) {
+ // Something was wrong. Spew the error message and
input text.
$output = '';
- $output .= "<span class=\"error\">". wfMsg(
'slippymap_maperror' ) . ' ' . $error . "</span><br />";
- $output .= htmlspecialchars($input);
+ $output .= "<span class=\"error\">" . wfMsg(
'slippymap_maperror' ) . ' ' . $error . "</span><br />";
+ $output .= htmlspecialchars( $input );
} else {
- //HTML output for the slippy map.
- //Note that this must all be output on one line (no
linefeeds)
- //otherwise MediaWiki adds <BR> tags, which is bad in
the middle of a block of javascript.
- //There are other ways of fixing this, but not for
MediaWiki v4
- //(See
http://www.mediawiki.org/wiki/Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension.27s_HTML_output.3F)
+ // HTML output for the slippy map.
+ // Note that this must all be output on one line (no
linefeeds)
+ // otherwise MediaWiki adds <BR> tags, which is bad in
the middle of a block of javascript.
+ // There are other ways of fixing this, but not for
MediaWiki v4
+ // (See
http://www.mediawiki.org/wiki/Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension.27s_HTML_output.3F)
$output = '<!-- slippy map -->';
- //This inline stylesheet defines how the two extra
buttons look, and where they are positioned.
+ // This inline stylesheet defines how the two extra
buttons look, and where they are positioned.
$output .= "<style> .buttonsPanel div { float:left;
display:block; position:relative; left:50px; margin-left:3px; margin-top:7px;
width:36px; height:19px; }</style>\n";
$output .= "<style> .buttonsPanel
.getWikiCodeButtonItemInactive { width:36px; height:19px;
background-image:url('" . $wgScriptPath .
"/extensions/SlippyMap/wikicode-button.png'); }</style>\n";
$output .= "<style> .buttonsPanel
.resetButtonItemInactive { width:36px; height:19px;
background-image:url('" . $wgScriptPath .
"/extensions/SlippyMap/reset-button.png'); }</style>\n";
@@ -229,7 +229,7 @@
$output .= ' Z = map.getZoom(); ';
$output .= ' size = map.getSize();';
- $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>" ); ';
+ $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>" ); ';
$output .= '}';
$output .= 'function slippymap_init() { ';
@@ -237,8 +237,8 @@
$output .= ' controls:[ ';
$output .= ' new
OpenLayers.Control.Navigation(), ';
- if ($height>320) {
- //Add the zoom bar control, except if the map
is only little
+ if ( $height > 320 ) {
+ // Add the zoom bar control, except if the map
is only little
$output .= ' new
OpenLayers.Control.PanZoomBar(),';
} else if ( $height > 140 ) {
$output .= ' new
OpenLayers.Control.PanZoom(),';
@@ -278,8 +278,8 @@
}
$output .= ' map.setCenter (lonLat, zoom); ';
- $output .= ' var getWikiCodeButton = new
OpenLayers.Control.Button({title: "' . wfMsg('slippymap_button_code') . '",
displayClass: "getWikiCodeButton", trigger: slippymap_getWikicode}); ';
- $output .= ' var resetButton = new
OpenLayers.Control.Button({title: "' . wfMsg('slippymap_resetview') . '",
displayClass: "resetButton", trigger: slippymap_resetPosition}); ';
+ $output .= ' var getWikiCodeButton = new
OpenLayers.Control.Button({title: "' . wfMsg( 'slippymap_button_code' ) . '",
displayClass: "getWikiCodeButton", trigger: slippymap_getWikicode}); ';
+ $output .= ' var resetButton = new
OpenLayers.Control.Button({title: "' . wfMsg( 'slippymap_resetview' ) . '",
displayClass: "resetButton", trigger: slippymap_resetPosition}); ';
$output .= ' var panel = new
OpenLayers.Control.Panel( { displayClass: "buttonsPanel"}); ';
$output .= ' panel.addControls([getWikiCodeButton,
resetButton]); ';
$output .= ' map.addControl(panel); ';
@@ -290,11 +290,11 @@
$output .= "<div style=\"width: {$width}px;
height:{$height}px; border-style:solid; border-width:1px;
border-color:lightgrey;\" id=\"map\">";
$output .= "<noscript><a
href=\"http://www.openstreetmap.org/?lat=$lat&lon=$lon&zoom=$zoom\" title=\"See
this map on OpenStreetMap.org\" style=\"text-decoration:none\">";
- $output .= "<img
src=\"".$wgMapOfServiceUrl."lat=${lat}&long=${lon}&z=${zoom}&w=${width}&h=${height}&format=jpeg\"
width=\"${width}\" height=\"${height}\" border=\"0\"><br/>";
+ $output .= "<img src=\"" . $wgMapOfServiceUrl .
"lat=${lat}&long=${lon}&z=${zoom}&w=${width}&h=${height}&format=jpeg\"
width=\"${width}\" height=\"${height}\" border=\"0\"><br/>";
$output .= '</a></noscript>';
$output .= '</div>';
- if (sizeof($oldStyleParamStrings) >2 ) $output .=
'<div style="font-size:0.8em;"><i>please change to <a
href="http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension">new
syntax</a></i></div>';
+ if ( sizeof( $oldStyleParamStrings ) > 2 ) $output .=
'<div style="font-size:0.8em;"><i>please change to <a
href="http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension">new
syntax</a></i></div>';
}
return $output;
}
Modified: trunk/extensions/SlippyMap/SlippyMap.php
===================================================================
--- trunk/extensions/SlippyMap/SlippyMap.php 2008-11-14 09:01:10 UTC (rev
43479)
+++ trunk/extensions/SlippyMap/SlippyMap.php 2008-11-14 09:21:25 UTC (rev
43480)
@@ -16,7 +16,7 @@
# This file should be placed in the mediawiki 'extensions' directory
# ...and then it needs to be 'included' within LocalSettings.php
#
-##################################################################################
+#
#################################################################################
#
# Copyright 2008 Harry Wood, Jens Frank, Grant Slater, Raymond Spekking and
others
#
@@ -38,7 +38,7 @@
#
-if (!defined('MEDIAWIKI'))
+if ( !defined( 'MEDIAWIKI' ) )
die();
$wgExtensionFunctions[] = 'wfslippymap';
@@ -53,7 +53,7 @@
'descriptionmsg' => 'slippymap_desc',
);
-$dir = dirname(__FILE__) . '/';
+$dir = dirname( __FILE__ ) . '/';
$wgAutoloadClasses['SlippyMap'] = $dir . 'SlippyMap.class.php';
$wgExtensionMessagesFiles['SlippyMap'] = $dir . 'SlippyMap.i18n.php';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs