Index: trunk/extensions/SlippyMap/SlippyMap.php |
— | — | @@ -1,81 +1,67 @@ |
2 | | -<?php |
| 2 | +<?php |
| 3 | +if ( ! defined( 'MEDIAWIKI' ) ) |
| 4 | + die(); |
3 | 5 | /** |
4 | | -* @file |
5 | | -* |
6 | | -* @section DESCRIPTION |
7 | | -* |
8 | | -* OpenStreetMap SlippyMap - MediaWiki extension |
9 | | -* |
10 | | -* This defines what happens when <slippymap> tag is placed in the wikitext |
11 | | -* |
12 | | -* We show a map based on the lat/lon/zoom data passed in. This extension brings in |
13 | | -* the OpenLayers javascript, to show a slippy map. |
14 | | -* |
15 | | -* Usage example: |
16 | | -* <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender></slippymap> |
17 | | -* |
18 | | -* Tile images are not cached local to the wiki. |
19 | | -* To acheive this (remove the OSM dependency) you might set up a squid proxy, |
20 | | -* and modify the requests URLs here accordingly. |
21 | | -* |
22 | | -* This file should be placed in the mediawiki 'extensions' directory |
23 | | -* ...and then it needs to be 'included' within LocalSettings.php |
24 | | -* |
25 | | -* @section LICENSE |
26 | | -* |
27 | | -* Copyright 2008 Harry Wood, Jens Frank, Grant Slater, Raymond Spekking and others |
28 | | -* |
29 | | -* This program is free software; you can redistribute it and/or modify |
30 | | -* it under the terms of the GNU General Public License as published by |
31 | | -* the Free Software Foundation; either version 2 of the License, or |
32 | | -* (at your option) any later version. |
33 | | -* |
34 | | -* This program is distributed in the hope that it will be useful, |
35 | | -* but WITHOUT ANY WARRANTY; without even the implied warranty of |
36 | | -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
37 | | -* GNU General Public License for more details. |
38 | | -* |
39 | | -* You should have received a copy of the GNU General Public License |
40 | | -* along with this program; if not, write to the Free Software |
41 | | -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
42 | | -* |
| 6 | + * SlippyMap extension |
| 7 | + * |
| 8 | + * @file |
| 9 | + * @ingroup Extension |
| 10 | + * |
| 11 | + * This file contains the main include file for the SlippyMap |
| 12 | + * extension of MediaWiki. |
| 13 | + * |
| 14 | + * Usage: Add the following line in LocalSettings.php: |
| 15 | + * require_once( "$IP/extensions/SlippyMap/SlippyMap.php" ); |
| 16 | + * |
| 17 | + * See the SlippyMap documenation on mediawiki.org for further usage |
| 18 | + * information. |
| 19 | + * |
| 20 | + * @link http://www.mediawiki.org/wiki/Extension:SlippyMap Documentation |
| 21 | + * |
| 22 | + * Copyright 2008 Harry Wood, Jens Frank, Grant Slater, Raymond Spekking and others |
| 23 | + * |
| 24 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
43 | 25 | */ |
44 | 26 | |
45 | | -/** |
46 | | - * Checks if the file is being executed within MediaWiki |
47 | | - */ |
48 | | -if ( !defined( 'MEDIAWIKI' ) ) |
49 | | - die(); |
| 27 | +if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
| 28 | + $wgHooks['ParserFirstCallInit'][] = 'SlippyMapHooks::onParserFirstCallInit'; |
| 29 | +} else { |
| 30 | + $wgExtensionFunctions[] = 'SlippyMapHooks::onParserFirstCallInit'; |
| 31 | +} |
50 | 32 | |
51 | | - |
52 | | -/** |
53 | | -* Property: Extension credits |
54 | | -*/ |
55 | 33 | $wgExtensionCredits['parserhook'][] = array( |
56 | 34 | 'path' => __FILE__, |
57 | 35 | 'name' => 'Slippy Map', |
58 | | - 'author' => array( '[http://harrywood.co.uk Harry Wood]', 'Jens Frank', 'Aude', 'Ævar Arnfjörð Bjarmason'), |
| 36 | + 'author' => array('[http://harrywood.co.uk Harry Wood]', 'Jens Frank', 'Aude', 'Ævar Arnfjörð Bjarmason'), |
59 | 37 | 'url' => 'http://www.mediawiki.org/wiki/Extension:SlippyMap', |
60 | | - 'description' => 'Adds a <slippymap> which allows for embedding of static & dynamic maps. Supports multiple map services including [http://openstreetmap.org OpenStreetMap] and NASA Worldwind', |
| 38 | + 'description' => 'Adds a <slippymap> which allows for embedding of static & dynamic maps.Supports multiple map services including [http://openstreetmap.org OpenStreetMap] and NASA Worldwind', |
61 | 39 | 'descriptionmsg' => 'slippymap_desc', |
62 | 40 | ); |
63 | 41 | |
| 42 | +/* Shortcut to this extension directory */ |
64 | 43 | $dir = dirname( __FILE__ ) . '/'; |
65 | 44 | |
66 | | -$wgMapModes = array( 'osm', 'satellite' ); |
| 45 | +/* i18n messages */ |
| 46 | +$wgExtensionMessagesFiles['SlippyMap'] = $dir . 'SlippyMap.i18n.php'; |
67 | 47 | |
68 | | -$wgAutoLoadMaps = false; |
| 48 | +/* The classes which make up our extension*/ |
| 49 | +$wgAutoloadClasses['SlippyMapHooks'] = $dir . 'SlippyMap.hooks.php'; |
| 50 | +$wgAutoloadClasses['SlippyMap'] = $dir . 'SlippyMap.class.php'; |
| 51 | +$wgAutoloadClasses['WorldWind'] = $dir . 'SlippyMap.worldwind.php'; |
69 | 52 | |
70 | | -$wgExtensionMessagesFiles['SlippyMap'] = $dir . 'SlippyMap.i18n.php'; |
| 53 | +/* Parser tests */ |
| 54 | +$wgParserTestFiles[] = $dir . '/slippyMapParserTests.txt'; |
71 | 55 | |
72 | | -$wgAutoloadClasses['SlippyMapHooks'] = $dir . 'SlippyMap.hooks.php'; |
73 | | -$wgAutoloadClasses['SlippyMap'] = $dir . 'SlippyMap.class.php'; |
74 | | -$wgAutoloadClasses['WorldWind'] = $dir . 'SlippyMap.worldwind.php'; |
| 56 | +/* |
| 57 | + * Configuration variables |
| 58 | + */ |
75 | 59 | |
76 | | -if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
77 | | - $wgHooks['ParserFirstCallInit'][] = 'SlippyMapHooks::onParserFirstCallInit'; |
78 | | -} else { |
79 | | - $wgExtensionFunctions[] = 'SlippyMapHooks::onParserFirstCallInit'; |
80 | | -} |
| 60 | +/* Allowed mode= values on this server */ |
| 61 | +$wgMapModes = array( 'osm', 'satellite' ); |
81 | 62 | |
82 | | -$wgHooks['ParserAfterTidy'][] = 'SlippyMapHooks::wfSlippyMapParserAfterTidy'; |
| 63 | +/* |
| 64 | + * If true the a JS slippy map will be shown by default to supporting |
| 65 | + * clients, otherwise they'd have to click on the static image to |
| 66 | + * enable the slippy map. |
| 67 | + */ |
| 68 | +$wgAutoLoadMaps = false; |
Index: trunk/extensions/SlippyMap/SlippyMap.hooks.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | |
39 | 39 | public static function onParserFirstCallInit( ) { |
40 | 40 | global $wgArticle, $wgOut, $wgLang, $wgParser, $wgScriptPath, $wgJsMimeType, $wgStyleVersion, $wgAutoLoadMaps; |
| 41 | + global $wgHooks; |
41 | 42 | |
42 | 43 | $smh = new SlippyMapHooks(); |
43 | 44 | |
— | — | @@ -73,7 +74,7 @@ |
74 | 75 | $wgOut->addScript( "<script type='$wgJsMimeType' src='" . $wgScriptPath . "/extensions/SlippyMap/OpenLayers/public/OpenLayers.js?{$wgStyleVersion}'></script>" ); |
75 | 76 | $wgOut->addScript( "<script type='$wgJsMimeType' src='" . $wgScriptPath . "/extensions/SlippyMap/SlippyMap.js?{$wgStyleVersion}'></script>" ); |
76 | 77 | $wgOut->addLink( array( 'rel' => 'stylesheet','type' => 'text/css','href' => $wgScriptPath . '/extensions/SlippyMap/SlippyMap.css' ) ); |
77 | | - |
| 78 | + $wgHooks['ParserAfterTidy'][] = 'SlippyMapHooks::wfSlippyMapParserAfterTidy'; |
78 | 79 | $wgParser->setHook( 'slippymap', array( $smh, 'wfParseMapAttributes' ) ); |
79 | 80 | } |
80 | 81 | |
Index: trunk/extensions/SlippyMap/slippyMapParserTests.txt |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +# Force the test runner to ensure the extension is loaded |
| 3 | +!! hooks |
| 4 | +slippymap |
| 5 | +!! endhooks |
| 6 | + |
| 7 | +!! test |
| 8 | +SlippyMap FIXME: add tests |
| 9 | +!! input |
| 10 | +<p>FIXME: add tests</p> |
| 11 | +!! result |
| 12 | +<p>FIXME: add tests</p> |
| 13 | + |
| 14 | +!! end |
| 15 | + |
| 16 | + |
| 17 | +!! test |
| 18 | +SlippyMap: {{#tag:}} |
| 19 | +!! input |
| 20 | +{{#tag:slippymap |
| 21 | +|Blah blah |
| 22 | +|mode = osm |
| 23 | +|lat = 64.64 |
| 24 | +|lon = -21.21 |
| 25 | +|layer = mapnik |
| 26 | +}} |
| 27 | +!! result |
| 28 | + |
| 29 | +!! end |