The sledrun condition is now shown in the sledrun popup.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 16 Dec 2012 13:28:02 +0000 (13:28 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 16 Dec 2012 13:28:02 +0000 (13:28 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1239 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.body.php
wrmap.js
wrmap.php

index e0f7d2ca380319678b93ff77873f3fe69afd9966..60fbf18295f739d3bbaa5ae0adc7a4e70b549370 100644 (file)
@@ -17,7 +17,7 @@ class WrMap {
 
                // Query database
                $dbr = wfGetDB(DB_SLAVE);
 
                // 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);
                $sledruns = array();
                while ($sledrun = $dbr->fetchRow($res)) $sledruns[] = $sledrun;
                $dbr->freeResult($res);
@@ -34,7 +34,12 @@ class WrMap {
                        $lon = $sledrun['position_longitude'];
                        if (!$lat || !$lon) continue;
                        $title = Title::newFromText($sledrun['page_title']);
                        $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";
                
                }
                $output .= "</div>\n";
                
index f2e7fa171a5de3d7c29896a0ae2b1e467603df2b..fc9d7891fcf296024cb091be02364c9e2babf5b3 100644 (file)
--- a/wrmap.js
+++ b/wrmap.js
@@ -63,7 +63,9 @@ function init_wrmap(i, jq_map) {
                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'),
                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, {
                })]);
        });
        map.addControl(new OpenLayers.Control.SelectFeature(layer_sledruns, {
@@ -77,14 +79,25 @@ function init_wrmap(i, jq_map) {
                toggle: true,
                onSelect: function(feature) {
                        // Open popup
                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&auml;&szlig;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 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,
                        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();
                        null, true, function(event) {
                                // onPopupClose
                                selectFeatureControl.unselectAll();
index 7beee198135dd8213de73a3f74fdb800488ee9df..a804a6151a4cc1db0f19e713589fd179cbc3e1ed 100644 (file)
--- a/wrmap.php
+++ b/wrmap.php
@@ -3,7 +3,7 @@
 
 $wgExtensionCredits['parserhook'][] = array(
        'name' => 'Winterrodeln Map',
 
 $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.'
        'author' =>'Philipp Spitzer', 
        'url' => 'http://www.winterrodeln.org/trac/wiki/WrMap', 
        'description' => 'This extension creates a map using OpenLayers to show sledruns.'