Extension:IncludeBikemap
|
|
The author of this extension is no longer maintaining it! Meaning any reports for additional features and/or bugfixes will more than likely be ignored. Volunteers are encouraged to take on the task of developing and maintaining it. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{extensions}} infobox. Please see the following alternatives that you may wish to install instead of this extension: |
|
|
This extension has been newly created as a widget for the widgets extension because of its code simplicity. Therefore this extension is not longer updated. See EmbedBikemap on mediawikiwidgets.org for more. |
|
IncludeBikemap Release status: experimental |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Embeds a bicycle tour map from bikemap.net | ||
| Author(s) | Uwe Hoppe (SinglespeedfahrerTalk) | ||
| Last version | 0.1.4.1 (2011/03/07) | ||
| MediaWiki | tested on 1.15.5-3, 1.16.2, 1.17.0 (should also work with some older versions) | ||
| PHP | tested on 5.3.3-7 and 5.3.5-1 | ||
| License | No license specified | ||
| Download | see Download instructions Changelog |
||
| Example | [1] | ||
|
|||
|
Check usage (experimental) |
|||
The IncludeBikemap extension is a simple tag extension to embed a bicycle tour map from bikemap.net in a mediawiki page. Bikemap.net offers to embed maps in an iframe in personal homepages (note: this extension is not offered by bikemap.net but written by a user).
For a German-speaking documentation see on / Für eine deutschssprachige Dokumentation siehe im Fahrrad-[Projekt]-Wiki.
Contents |
[edit] Usage
<includebikemap>ID</includebikemap>
ID is the number of the bike route in the url. For example ID for www.bikemap.net/route/817755 is 817755.
- Optionally
- Change the size of the embeded map (default: medium):
<includebikemap size="small">ID</includebikemap>
size can be "small", "medium" or "big".
- Change the type of the embeded map (default: openstreetmap (osm)):
<includebikemap maptype="osm">ID</includebikemap>
maptype can be "card" (googlemaps), "hybrid" (googlemaps), "terrain" (googlemaps), "osm" (openstreetmap), "ocm" (opencyclemap) or "sat" (googlemaps).
- Change if the altitude diagram shall be shown (default: true):
<includebikemap ev="false">ID</includebikemap>
ev can be "true" (default) or "false".
[edit] ToDo
Not yet performed:
- change heigth and width manually as needed (currently only three fixed sizes are supported)
Code:
- cleaner code design
- better code commenting
Future:
- Extension shall perform also gpsies and the other Toursprung maps (similar to bikemap.net) like ITrackViewer plugin for dokuwiki (maybe the extension name should then changed)
[edit] Download instructions
Please cut and paste the code found below and place it in $IP/extensions/IncludeBikemap/IncludeBikemap.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php. The folder IncludeBikemap must be created first.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/IncludeBikemap/IncludeBikemap.php");
[edit] Changelog
0.1.4.1: (2011-03-07) Test that $input has only numbers
0.1.4: (2001-03-06) Bug fix: $wgExtensionCredits; bug fix: default iframe size bad if $ev is set to false; fix code layout; added comments
0.1.3: (2011-03-05) This version fixes the problems with the map size from former versions and now we are able to change between an extended view version which shows an altitude diagram or simply switch it of; fix not showing route id in footer
0.1.2: (2011-03-05) Now it is possible to change the maptypes (default openstreetmap); fix iframe source; fix header documentation
0.1.1: (2011-03-05) Fixed some bad code issues (see Extension talk:IncludeBikemap#Code review 2781): changed fundamental variables design, unneccessary escaping, bad wfMsgForContent use
0.1: (2011-03-05) Introduce the extension on mediawiki.org
[edit] Code
<?php /* IncludeBikemap.php * Version 0.1.4.1 (2011-03-07) * * This extension embeds a map from bikemap.net in a mediawiki page. * * Usage and installation: Please see http://mediawiki.org/wiki/Extension:IncludeBikemap * */ // check that this script runs on mediawiki if( !defined( 'MEDIAWIKI' ) ) { echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); die( -1 ); } // extension credits to show up the extension in Special:Version $wgExtensionCredits['other'][] = array( 'path' => __FILE__, 'name' => 'IncludeBikemap', 'version' => '0.1.4.1', 'author' => 'Uwe Hoppe', 'url' => 'http://www.mediawiki.org/wiki/Extension:IncludeBikemap', 'description' => 'This extension embeds a map from bikemap.net' ); $wgHooks['ParserFirstCallInit'][] = 'efIncludeBikemapSetup'; function efIncludeBikemapSetup( &$parser ) { $parser->setHook( 'includebikemap', 'efIncludeBikemapRender' ); return true; } function efIncludeBikemapRender( $input, $args ) { // check input of extended view argument (altitude diagram) if ( @$args['ev'] ) { switch( $args['ev'] ) { case 'true': $ev = 'true'; break; case 'false': $ev = 'false'; break; default: return '<div class="errorbox">Bad parameter for extended view! It must be "true" or "false".</div>'; } } else { $ev = 'true'; //default } // change between three different map sizes: "small", "medium", "big" if ( @$args['size'] ) { switch( $args['size'] ) { case 'small': $width = 300; $height_widget = 300; if ( $ev == 'false' ) { $height = 310; } else { $height = 525; } break; case 'medium': $width = 425; $height_widget = 350; if ( $ev == 'false' ) { $height = 360; } else { $height = 575; } break; case 'big': $width = 640; $height_widget = 480; if ( $ev == 'false' ) { $height = 490; } else { $height = 640; } break; default: return '<div class="errorbox">Bad size! Size must be "small", "medium" or "big".</div>'; } } else { // default: $width = 425; $height_widget = 350; if ( $ev == 'false' ) { $height = 360; } else { $height = 575; } } // five different map types 0=card 1=hybrid, 2=terrain, 3=osm, 4=ocm, 5=sat if ( @$args['maptype'] ) { switch( $args['maptype'] ) { case 'card': $maptype = 0; break; case 'hybrid': $maptype = 1; break; case 'terrain': $maptype = 2; break; case 'osm': $maptype = 3; break; case 'ocm': $maptype = 4; break; case 'sat': $maptype = 5; break; default: return '<div class="errorbox">Bad maptype! Maptype must be "card" "hybrid", "terrain", "osm", "ocm" or "sat".</div>'; } } else { $maptype = 3; // default openstreetmap } // check input ID $mapid = htmlspecialchars( $input ); if ( $mapid == null || !ereg('^[0-9]{1,10}$', $mapid) ) { return '<div class="errorbox">Bad ID! ID must be the number at the the end of the tour url.</div>'; } // build the iframe $output = '<div style="margin-top: 2px; margin-bottom: 2px; width: ' . $width . 'px; font-family: Arial,Helvetica,sans-serif; font-size: 9px;color: #535353; background-color: #ffffff; border: 2px solid #2a88ac; font-style: normal; text-align: right; padding: 0px; padding-bottom: 3px !important;"><iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="no" width="' . $width . '" height="' . $height . '" border="0" src="http://www.bikemap.net/route/' . $mapid . '/widget?width=' . $width . '&height=' . $height_widget . '&maptype=' . $maptype . '&extended=' . $ev . '&unit=km&redirect=no"></iframe><br />Route <a style="color: #2a88ac; text-decoration: underline;" href="http://www.bikemap.net/route/' . $mapid . '">' . $mapid . '</a> - powered by <a style="color: #2a88ac; text-decoration: underline;" href="http://www.bikemap.net">Bikemap</a> </div>'; return $output; }
