<?php
-require_once dirname(__FILE__) . '/../wrgeo/wrgeo.body.php'; # for the function wrGeoGeoStringToGeo
function wrMapParserFirstCallInit() {
global $wgParser;
- // global $wrGoogleMaps; // is this necessary?
global $wgGoogleMapsKey;
$wrGoogleMaps = new WrGoogleMaps($wgGoogleMapsKey);
$wgParser->setHook('wrmap', 'wrmapParserHook');
}
-// Tool functions
-// --------------
-
-/// List of markers - used by the functions wrMapReplaceByMarker and wrMapAfterTidy
-$wrMapMarkerList = array();
-
-
-/// Returns a marker for a text and back-replaces the text in wrReportAfterTidy
-function wrMapReplaceByMarker($text, $marker = 'wrMapMarker') {
- $marker = $marker . mt_rand(1e5, 1e7);
- global $wrMapMarkerList;
- $wrMapMarkerList[$marker] = $text;
- return $marker;
-}
-
-
-/// Replaces the markers by its contents
-function wrMapParserAfterTidy(&$parser, &$text) {
- // find markers in $text
- // replace markers with actual output
- global $wrMapMarkerList;
- foreach ($wrMapMarkerList as $marker => $html) $text = str_replace($marker, $html, $text);
- return true;
-}
-
-
// Java script
// -----------
$output .= "}\n//]]>\n</script>\n";
$output .= '<noscript><img alt="Landkarte mit Rodelbahnen" src="' . htmlspecialchars($staticLink) . "\" width=\"$staticSizeX\" height=\"$staticSizeY\" /></noscript>\n";
- return wrMapReplaceByMarker($output);
+ return wrCommonReplaceByMarker($output, 'wrmap');
}
// returns a string that creates a map object called 'map'
<?php
+// This extension depends on
+// - wrcommon
+// - wrgeo (for wrGeoStringToGeo)
+
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Winterrodeln Map',
- 'version' => '1.2.0',
+ 'version' => '1.3.0',
'author' =>'Philipp Spitzer',
'url' => 'http://www.winterrodeln.org',
'description' => 'This extension creates a map from coordinates and uses the GoogleMaps extension to do so.'
$wgHooks['ParserFirstCallInit'][] = 'wrMapParserFirstCallInit';
-$wgHooks['ParserAfterTidy'][] = 'wrMapParserAfterTidy';
+$wgHooks['ParserAfterTidy'][] = 'wrCommonMarkerAfterTidy';
require_once dirname(__FILE__) . '/wrmap.body.php';