Revision: 43459
Author:   siebrand
Date:     2008-11-13 17:41:41 +0000 (Thu, 13 Nov 2008)

Log Message:
-----------
* remove indent level
* remove need for an additional dirname()
* some formatting fixes
* put authors in an array

No functional changes

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-13 17:19:44 UTC 
(rev 43458)
+++ trunk/extensions/SlippyMap/SlippyMap.class.php      2008-11-13 17:41:41 UTC 
(rev 43459)
@@ -1,18 +1,18 @@
 <?php
 # OpenStreetMap SlippyMap - MediaWiki extension
-# 
+#
 # This defines what happens when <slippymap> tag is placed in the wikitext
-# 
+#
 # We show a map based on the lat/lon/zoom data passed in. This extension 
brings in
-# the OpenLayers javascript, to show a slippy map.  
+# the OpenLayers javascript, to show a slippy map.
 #
 # Usage example:
-# <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender 
marker=0></slippymap> 
+# <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender 
marker=0></slippymap>
 #
 # Tile images are not cached local to the wiki.
 # To acheive this (remove the OSM dependency) you might set up a squid proxy,
 # and modify the requests URLs here accordingly.
-# 
+#
 # This file should be placed in the mediawiki 'extensions' directory
 # ...and then it needs to be 'included' within LocalSettings.php
 #
@@ -37,9 +37,7 @@
 # @addtogroup Extensions
 #
 
-
 class SlippyMap {
-
        function SlippyMap() {
        }
 
@@ -49,37 +47,37 @@
 
                wfLoadExtensionMessages( 'SlippyMap' );
 
-               if ( isset( $argv['lat'] ) ) { 
+               if ( isset( $argv['lat'] ) ) {
                        $lat            = $argv['lat'];
                } else {
                        $lat            = '';
                }
-               if ( isset( $argv['lon'] ) ) { 
+               if ( isset( $argv['lon'] ) ) {
                        $lon            = $argv['lon'];
                } else {
                        $lon            = '';
                }
-               if ( isset( $argv['z'] ) ) { 
+               if ( isset( $argv['z'] ) ) {
                        $zoom           = $argv['z'];
                } else {
                        $zoom           = '';
                }
-               if ( isset( $argv['w'] ) ) { 
+               if ( isset( $argv['w'] ) ) {
                        $width          = $argv['w'];
                } else {
                        $width          = '';
                }
-               if ( isset( $argv['h'] ) ) { 
+               if ( isset( $argv['h'] ) ) {
                        $height         = $argv['h'];
                } else {
                        $height         = '';
                }
-               if ( isset( $argv['layer'] ) ) { 
+               if ( isset( $argv['layer'] ) ) {
                        $layer          = $argv['layer'];
                } else {
                        $layer          = '';
                }
-               if ( isset( $argv['marker'] ) ) { 
+               if ( isset( $argv['marker'] ) ) {
                        $marker         = $argv['marker'];
                } else {
                        $marker         = '';
@@ -88,9 +86,9 @@
                $error='';
 
                //default values (meaning these parameters can be missed out)
-               if ($width=='')         $width ='450'; 
-               if ($height=='')        $height='320'; 
-               if ($layer=='')         $layer='mapnik'; 
+               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)
@@ -114,7 +112,7 @@
                if ( $zoom=='' ) $error .= wfMsg( 'slippymap_zoommissing' );
 
                if ($error=='') {
-                       //no errors so far. Now check the values        
+                       //no errors so far. Now check the values
                        if (!is_numeric($width)) {
                                $error = wfMsg( 'slippymap_widthnan', $width );
                        } else if (!is_numeric($height)) {
@@ -155,7 +153,7 @@
 
                $layer = strtolower($layer);
                $layerObjectDef = '';
-               if ($layer=='osmarender') {        
+               if ($layer=='osmarender') {
                        $layerObjectDef = 
'OpenLayers.Layer.OSM.Osmarender("Osmarender"); ';
                } elseif ($layer=='mapnik') {
                        $layerObjectDef = 
'OpenLayers.Layer.OSM.Mapnik("Mapnik"); ';
@@ -182,13 +180,13 @@
                        // defer loading of the javascript. Since the script is 
quite bit, it would delay
                        // page loading and rendering dramatically
                        $output .= 'addOnloadHook( function() { ' .
-                               '       var sc = 
document.createElement("script");' .
+                               '       var sc = 
document.createElement("script");' .
                                '       sc.src = 
"http://www.openlayers.org/api/OpenLayers.js";;' .
-                               '       document.body.appendChild( sc );' .
-                               '       var sc = 
document.createElement("script");' .
-                               '       sc.src = 
"http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SlippyMap/OpenStreetMap.js?view=co&;'
 . $wgSlippyMapVersion . '";'.
-                               '       document.body.appendChild( sc );' .
-                               '} );';
+                               '       document.body.appendChild( sc );' .
+                               '       var sc = 
document.createElement("script");' .
+                               '       sc.src = 
"http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SlippyMap/OpenStreetMap.js?view=co&;'
 . $wgSlippyMapVersion . '";'.
+                               '       document.body.appendChild( sc );' .
+                               '} );';
 
                        $output .= "var lon= ${lon}; var lat= ${lat}; var zoom= 
${zoom}; var lonLat;";
 
@@ -205,7 +203,7 @@
 
                        if ($height>320) {
                                //Add the zoom bar control, except if the map 
is only little
-                               $output .= '            new 
OpenLayers.Control.PanZoomBar(),';   
+                               $output .= '            new 
OpenLayers.Control.PanZoomBar(),';
                        } else if ( $height > 140 ) {
                                $output .= '            new 
OpenLayers.Control.PanZoom(),';
                        }
@@ -223,16 +221,19 @@
 
                        if ( $marker ) {
                                $output .= 'var markers = new 
OpenLayers.Layer.Markers( "Markers" ); ' .
-                                       '   map.addLayer(markers); ' .
-                                       '   var size = new 
OpenLayers.Size(20,34); ' .
-                                       '   var offset = new 
OpenLayers.Pixel(-(size.w/2), -size.h); ' .
-                                       "   var icon = new 
OpenLayers.Icon('http://boston.openguides.org/markers/YELLOW.png',size,offset);"
 .
-                                       '   markers.addMarker(new 
OpenLayers.Marker( lonLat,icon)); ';
+                                       '   map.addLayer(markers); ' .
+                                       '   var size = new 
OpenLayers.Size(20,34); ' .
+                                       '   var offset = new 
OpenLayers.Pixel(-(size.w/2), -size.h); ' .
+                                       "   var icon = new 
OpenLayers.Icon('http://boston.openguides.org/markers/YELLOW.png',size,offset);"
 .
+                                       '   markers.addMarker(new 
OpenLayers.Marker( lonLat,icon)); ';
                        }
 
                        if ( $showkml ) {
-                               $input = str_replace( array( '%',   "\n" , "'"  
, '"'  , '<'  , '>'  , ' '   ), 
-                                                     array( '%25', '%0A', 
'%27', '%22', '%3C', '%3E', '%20' ), $input );
+                               $input = str_replace(
+                                       array( '%',   "\n" , "'"  , '"'  , '<'  
, '>'  , ' '   ),
+                                       array( '%25', '%0A', '%27', '%22', 
'%3C', '%3E', '%20' ),
+                                       $input
+                               );
                                $output .= 'var vector = new 
OpenLayers.Layer.Vector("Vector Layer"); ' .
                                        '   map.addLayer(vector); ' .
                                        '   kml = new OpenLayers.Format.KML( { 
"internalProjection": map.baseLayer.projection, ' .
@@ -247,7 +248,7 @@
                        $output .= '} ';
 
                        $output .= 'function slippymap_getWikicode() {';
-                       $output .= '    LL = 
map.getCenter().transform(map.getProjectionObject(), new 
OpenLayers.Projection("EPSG:4326"));';
+                       $output .= '    LL = 
map.getCenter().transform(map.getProjectionObject(), new 
OpenLayers.Projection("EPSG:4326"));';
                        $output .= '    Z = map.getZoom(); ';
                        $output .= '    size = map.getSize();';
 

Modified: trunk/extensions/SlippyMap/SlippyMap.php
===================================================================
--- trunk/extensions/SlippyMap/SlippyMap.php    2008-11-13 17:19:44 UTC (rev 
43458)
+++ trunk/extensions/SlippyMap/SlippyMap.php    2008-11-13 17:41:41 UTC (rev 
43459)
@@ -1,18 +1,18 @@
 <?php
 # OpenStreetMap SlippyMap - MediaWiki extension
-# 
+#
 # This defines what happens when <slippymap> tag is placed in the wikitext
-# 
+#
 # We show a map based on the lat/lon/zoom data passed in. This extension 
brings in
-# the OpenLayers javascript, to show a slippy map.  
+# the OpenLayers javascript, to show a slippy map.
 #
 # Usage example:
-# <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 
layer=osmarender></slippymap> 
+# <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 
layer=osmarender></slippymap>
 #
 # Tile images are not cached local to the wiki.
 # To acheive this (remove the OSM dependency) you might set up a squid proxy,
 # and modify the requests URLs here accordingly.
-# 
+#
 # This file should be placed in the mediawiki 'extensions' directory
 # ...and then it needs to be 'included' within LocalSettings.php
 #
@@ -38,34 +38,35 @@
 #
 
 
-if( defined( 'MEDIAWIKI' ) ) {
-       $wgExtensionFunctions[] = 'wfslippymap';
+if (!defined('MEDIAWIKI'))
+       die();
 
-       $wgExtensionCredits['parserhook'][] = array(
-               'name'           => 'OpenStreetMap Slippy Map',
-               'author'         => '[http://harrywood.co.uk Harry Wood], Jens 
Frank',
-               'svn-date'       => '$LastChangedDate$',
-               'svn-revision'   => '$LastChangedRevision$',
-               'url'            => 
'http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension',
-               'description'    => 'Allows the use of the &lt;slippymap&gt; 
tag to display an OpenLayers slippy map. Maps are from 
[http://openstreetmap.org openstreetmap.org]',
-               'descriptionmsg' => 'slippymap_desc',
-       );
+$wgExtensionFunctions[] = 'wfslippymap';
 
-       $wgAutoloadClasses['SlippyMap'] = dirname( __FILE__ ) . 
'/SlippyMap.class.php';
-       $wgExtensionMessagesFiles['SlippyMap'] = dirname( __FILE__ ) . 
"/SlippyMap.i18n.php";
+$wgExtensionCredits['parserhook'][] = array(
+       'name'           => 'OpenStreetMap Slippy Map',
+       'author'         => array( '[http://harrywood.co.uk Harry Wood]', 'Jens 
Frank' ),
+       'svn-date'       => '$LastChangedDate$',
+       'svn-revision'   => '$LastChangedRevision$',
+       'url'            => 
'http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension',
+       'description'    => 'Allows the use of the &lt;slippymap&gt; tag to 
display an OpenLayers slippy map. Maps are from [http://openstreetmap.org 
openstreetmap.org]',
+       'descriptionmsg' => 'slippymap_desc',
+);
 
-       # Bump this when updating OpenStreetMap.js to help update caches
-       $wgSlippyMapVersion = 1;
+$dir = dirname(__FILE__) . '/';
+$wgAutoloadClasses['SlippyMap'] = $dir . 'SlippyMap.class.php';
+$wgExtensionMessagesFiles['SlippyMap'] = $dir . 'SlippyMap.i18n.php';
 
-       function wfslippymap() {
-               global $wgParser, $wgMapOfServiceUrl;
-               # register the extension with the WikiText parser
-               # the first parameter is the name of the new tag.
-               # In this case it defines the tag <slippymap> ... </slippymap>
-               # the second parameter is the callback function for
-               # processing the text between the tags
-               $wgParser->setHook( 'slippymap', array( 'SlippyMap', 'parse' ) 
);
-               $wgMapOfServiceUrl = 
"http://osm-tah-cache.firefishy.com/~ojw/MapOf/?";;
-       }
+# Bump this when updating OpenStreetMap.js to help update caches
+$wgSlippyMapVersion = 1;
 
+function wfslippymap() {
+       global $wgParser, $wgMapOfServiceUrl;
+       # register the extension with the WikiText parser
+       # the first parameter is the name of the new tag.
+       # In this case it defines the tag <slippymap> ... </slippymap>
+       # the second parameter is the callback function for
+       # processing the text between the tags
+       $wgParser->setHook( 'slippymap', array( 'SlippyMap', 'parse' ) );
+       $wgMapOfServiceUrl = "http://osm-tah-cache.firefishy.com/~ojw/MapOf/?";;
 }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to