-/// Format inside <wrmap>...</wrmap> has to be like this:
-///
-/// <wrmap>
-/// Rodelbahn|47.143241 N 11.208959 E|Birgitzer Alm
-/// ...
-/// </wrmap>
-///
-/// The extension produces a format like this:
-/// <googlemap version="0.9" lat="47.241016" lon="11.56517" zoom="11">
-/// 47.241731, 11.358994, Birgitzer Alm
-/// Die Birgitzer Alm ist nett
-/// 47.17607, 11.542763, Naviser Hütte
-/// Die Naviser Hütte
-/// </googlemap>
-function wrmapParserHook($input, $args, $parser) {
- $output = '<googlemap version="0.9" lat="47.452237" lon="11.208801" type="terrain" zoom="9">'; // TODO: Varable coordinates
- $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, %s\n", $latitude, $longitude, htmlspecialchars($name));
- } catch (Exception $e) {
- return sprintf(utf8_encode('Ungültige Zeile in der Koordinatenliste: <em>%s</em>. %s'), htmlspecialchars($line), htmlspecialchars($e->getMessage()));
+ // Query database
+ $dbr = wfGetDB(DB_SLAVE);
+ $res = $dbr->select('wrsledruncache', array('page_title', 'position_latitude', 'position_longitude'), array('show_in_overview', 'not under_construction'));
+ $sledruns = array();
+ while ($sledrun = $dbr->fetchRow($res)) $sledruns[] = $sledrun;
+ $dbr->freeResult($res);
+
+ $parserOutput = $parser->getOutput();
+ $parserOutput->addHeadItem('<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.8&sensor=false"></script>', 'googlemaps');
+ $parserOutput->addModules('ext.wrmap');
+
+ // Create <div/> element where the map is placed in
+ $output = "<div class=\"wrmap\" style=\"width: 100%; height: 450px; border-style:none;\" data-center-lon=\"$longitude_s\" data-center-lat=\"$latitude_s\" data-zoom=\"$zoom\">\n";
+ foreach ($sledruns as $sledrun) {
+ $lat = $sledrun['position_latitude'];
+ $lon = $sledrun['position_longitude'];
+ if (!$lat || !$lon) continue;
+ $output .= "<p data-lon=\"$lon\" data-lat=\"$lat\" data-title=\"{$sledrun['page_title']}\" />\n";