2 require_once dirname(__FILE__) . '/../wrgeo/wrgeo.body.php'; # for the function wrGeoGeoStringToGeo
4 function wrMapParserFirstCallInit() {
6 $wgParser->setHook('wrmap', 'wrmapParserHook');
11 /// Format inside <wrmap>...</wrmap> has to be like this:
14 /// Rodelbahn|47.143241,11.208959|Birgitzer Alm
17 function wrmapParserHook($input, $args, $parser) {
18 $output = '<googlemap>';
19 $lines = explode("\n", $input);
20 foreach ($lines as $line) {
23 if (strlen($l) == 0) continue;
24 $columns = explode('|', $line);
25 if (count($columns) != 3) throw new Exception(sprintf(utf8_encode('Die Anzahl der Spalten ist nicht 3 sondern %d'), count($columns)));
26 $columns = list($type, $geo, $name) = $columns;
27 list($latitude, $longitude) = wrGeoStringToGeo($geo);
28 $output .= sprintf("%F,%F\n", $latitude, $longitude);
29 } catch (Exception $e) {
30 return sprintf(utf8_encode('Ungültige Zeile in der Koordinatenliste: <em>%s</em>. %s'), htmlspecialchars($line), htmlspecialchars($e->getMessage()));
33 $output = $output .= "</googlemap>\n";
35 global $wgTitle, $wgUser;
36 $parser = new Parser();
37 $parserOptions = new ParserOptions();
38 $parserOptions->initialiseFromUser($wgUser);
39 $result = $parser->parse($output, $wgTitle, $parserOptions); // TODO: Make this call less complicated
41 $result = $parser->recursiveTagParse($output); // TODO: Maybe this is already the solution?
43 return $result->getText();