// Query database
$dbr = wfGetDB(DB_SLAVE);
- $res = $dbr->select('wrsledruncache', array('page_title', 'position_latitude', 'position_longitude'), array('show_in_overview', 'not under_construction'));
+ $res = $dbr->select(array('wrsledruncache', 'wrreportcache'), array('wrsledruncache.page_title', 'position_latitude', 'position_longitude', 'date_report', '`condition`'), array('show_in_overview', 'not under_construction'), __METHOD__, array(), array('wrreportcache' => array('left outer join', 'wrsledruncache.page_id=wrreportcache.page_id')));
$sledruns = array();
while ($sledrun = $dbr->fetchRow($res)) $sledruns[] = $sledrun;
$dbr->freeResult($res);
$lon = $sledrun['position_longitude'];
if (!$lat || !$lon) continue;
$title = Title::newFromText($sledrun['page_title']);
- $output .= "<p data-lon=\"$lon\" data-lat=\"$lat\" data-title=\"{$title->getText()}\" data-url=\"{$title->getLocalUrl()}\" />\n";
+ $title_text = htmlspecialchars($title->getText());
+ $title_url = htmlspecialchars($title->getLocalUrl());
+ $output .= "<p data-lon=\"$lon\" data-lat=\"$lat\" data-title=\"$title_text\" data-url=\"$title_url\" ";
+ if (!is_null($sledrun['date_report'])) $output .= "data-date_report=\"{$sledrun['date_report']}\" ";
+ if (!is_null($sledrun['condition'])) $output .= "data-condition=\"{$sledrun['condition']}\" ";
+ $output .= "/>\n";
}
$output .= "</div>\n";
var point = new OpenLayers.Geometry.Point(lon, lat).transform(EPSG4326, EPSG3857);
layer_sledruns.addFeatures([new OpenLayers.Feature.Vector(point, {
label: jq_sledrun.attr('data-title'),
- url: jq_sledrun.attr('data-url')
+ url: jq_sledrun.attr('data-url'),
+ date_report: jq_sledrun.attr('data-date_report'),
+ condition: jq_sledrun.attr('data-condition')
})]);
});
map.addControl(new OpenLayers.Control.SelectFeature(layer_sledruns, {
toggle: true,
onSelect: function(feature) {
// Open popup
+ var popup_text = "<h2>" + feature.attributes['label'] + '</h2>\n' +
+ '<ul>\n' +
+ '<li><a href="' + feature.attributes['url'] + '">Details zur Rodelbahn</a></li>\n' +
+ '<li>Rodelbahnzustand<br/>';
+ if ('date_report' in feature.attributes && 'condition' in feature.attributes) {
+ var condition_text = {1: 'Sehr gut', 2: 'Gut', 3: 'Mittelmäßig', 4: 'Schlecht', 5: 'Geht nicht'};
+ var year_month_day = feature.attributes['date_report'].split('-');
+ popup_text += '<a href="' + feature.attributes['url'] + '#Eintr.C3.A4ge">' + condition_text[feature.attributes['condition']] + '</a> ' +
+ '<small>' + year_month_day[2] + '.' + year_month_day[1] + '.</small> ' +
+ '<em><a href="' + feature.attributes['url'] + '#Eintragen">Neu</a></em>';
+ } else {
+ popup_text += '<em><a href="' + feature.attributes['url'] + '#Eintragen">Bitte eintragen</a></em>';
+ }
+ popup_text += '</li>\n</ul>\n';
var selectFeatureControl = this;
- var popup = new OpenLayers.Popup.FramedCloud("sledruninfopopup_" + feature.attributes['label'],
+ var popup = new OpenLayers.Popup.FramedCloud('sledruninfopopup_' + feature.attributes['label'],
feature.geometry.getBounds().getCenterLonLat(),
null,
- "<h2>" + feature.attributes['label'] + "</h2>\n" +
- "<ul>\n" +
- "<li><a href=\"" + feature.attributes['url'] + "\">Details</a></li>\n" +
- "</ul>\n",
+ popup_text,
null, true, function(event) {
// onPopupClose
selectFeatureControl.unselectAll();
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Winterrodeln Map',
- 'version' => '2.0.0',
+ 'version' => '2.1.0',
'author' =>'Philipp Spitzer',
'url' => 'http://www.winterrodeln.org/trac/wiki/WrMap',
'description' => 'This extension creates a map using OpenLayers to show sledruns.'