--- /dev/null
+<?php
+require_once dirname(__FILE__) . '/../wrgeo/wrgeo.body.php'; # for the function wrGeoGeoStringToGeo
+
+function wrMapParserFirstCallInit() {
+ global $wgParser;
+ $wgParser->setHook('wrmap', 'wrmapParserHook');
+ return true;
+}
+
+
+/// Format inside <wrmap>...</wrmap> has to be like this:
+///
+/// <wrmap>
+/// Rodelbahn|47.143241,11.208959|Birgitzer Alm
+/// ...
+/// </wrmap>
+function wrmapParserHook($input, $args, $parser) {
+ $output = '<googlemap>';
+ $lines = explode("\n", $input);
+ foreach ($lines as $line) {
+ try {
+ $l = trim($line);
+ if (strlen($l) == 0) continue;
+ $columns = explode('|', $line);
+ if (count($columns) != 3) throw new Exception(sprintf(utf8_encode('Die Anzahl der Spalten ist nicht 3 sondern %d'), count($columns)));
+ $columns = list($type, $geo, $name) = $columns;
+ list($latitude, $longitude) = wrGeoStringToGeo($geo);
+ $output .= sprintf("%F,%F\n", $latitude, $longitude);
+ } catch (Exception $e) {
+ return sprintf(utf8_encode('Ungültige Zeile in der Koordinatenliste: <em>%s</em>. %s'), htmlspecialchars($line), htmlspecialchars($e->getMessage()));
+ }
+ }
+ $output = $output .= "</googlemap>\n";
+ /*
+ global $wgTitle, $wgUser;
+ $parser = new Parser();
+ $parserOptions = new ParserOptions();
+ $parserOptions->initialiseFromUser($wgUser);
+ $result = $parser->parse($output, $wgTitle, $parserOptions); // TODO: Make this call less complicated
+ */
+ $result = $parser->recursiveTagParse($output); // TODO: Maybe this is already the solution?
+
+ return $result->getText();
+}
+
+
+?>
--- /dev/null
+<?php
+$wgExtensionCredits['parserhook'][] = array(
+ 'name' => 'Winterrodeln Map',
+ 'version' => '1.2.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';
+
+
+require_once dirname(__FILE__) . '/wrmap.body.php';
+
+?>