The sledrun icon is now dependent on the sledrun condition.
[philipp/winterrodeln/mediawiki_extensions/wrmap.git] / wrmap.body.php
index e71b1eacaf81d8ba34c97565e0d714546339733c..60fbf18295f739d3bbaa5ae0adc7a4e70b549370 100644 (file)
@@ -17,7 +17,7 @@ class WrMap {
 
                // 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);
@@ -27,12 +27,19 @@ class WrMap {
                $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";
+               global $wgExtensionAssetsPath;
+               $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\" data-img-path=\"$wgExtensionAssetsPath/wrmap/openlayers/img/\">\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";
+                       $title = Title::newFromText($sledrun['page_title']);
+                       $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";