Whitespace corrections.
[philipp/winterrodeln/mediawiki_extensions/wrreport.git] / wrreport_body.php
index 7492b258016248cee8d8bbf158c28ca88de271d9..0e44cc041c2cb7b8827a6b5f20d5d48ed5af4f33 100644 (file)
@@ -748,20 +748,31 @@ class WrReport {
        private static function createBahnentabelle($page_titles) {
                $dbr = wfGetDB(DB_REPLICA);
 
-               // SELECT p.page_id,p.page_title, c.length, c.walkup_time, c.top_elevation, c.bottom_elevation, c.walkup_separate, c.lift, c.night_light, c.public_transport, c.sled_rental, c.information_phone FROM `page` p, wrsledruncache c WHERE (p.page_title in ('Birgitzer_Alm_(vom_Adelshof)', 'Kemater_Alm', 'Axamer_Lizum') and p.page_id=c.page_id) ORDER BY page_title
-               $where_array = array('page.page_id = wrsledruncache.page_id');
+               // SELECT p.page_id, p.page_title, c.length, c.walkup_time, c.top_elevation, c.bottom_elevation, c.walkup_separate, c.lift, c.night_light, c.public_transport,
+               // c.sled_rental, c.information_phone, s.show_status, r.status, r.last_check, r.last_update
+               // FROM (`page` p JOIN  wrsledruncache c ON p.page_id=c.page_id) LEFT OUTER JOIN (wrintermapssledrun s JOIN wrintermapsreport r ON s.intermaps_sledrun_id=r.intermaps_sledrun_id) ON p.page_id=s.wr_page_id
+               // WHERE p.page_title in ('Birgitzer_Alm_(vom_Adelshof)', 'Mutterer_Alm_-_Sportrodelbahn', 'Axamer_Lizum') ORDER BY page_title;
+               $where_array = array();
                if (count($page_titles) > 0) {
                        $mysql_page_ids = array();
                        foreach ($page_titles as $page_title) $mysql_page_ids[] = $page_title->getArticleID();
-                       $where_array[] = 'page.page_id in (' . implode(', ', $mysql_page_ids) . ')';
+                       $where_array[] = 'p.page_id in (' . implode(', ', $mysql_page_ids) . ')';
                } else $where_array[] = 'false';
-               $res = $dbr->select(array('page', 'wrsledruncache'), array('page.page_id', 'page.page_title', 'page_namespace', 'length', 'walkup_time', 'top_elevation', 'bottom_elevation', 'walkup_possible', 'walkup_separate', 'lift', 'night_light', 'public_transport', 'sled_rental', 'information_phone', 'information_web'), $where_array, 'bahnentabelleParserHook', array('ORDER BY' => 'page.page_title'));
+               $res = $dbr->select(['AA' => ['p' => 'page', 'c' => 'wrsledruncache'], 'BB' => ['r' => 'wrintermapsreport', 's' => 'wrintermapssledrun']],
+                                                       ['p.page_id', 'p.page_title', 'p.page_namespace',
+                                                        'c.length', 'c.walkup_time', 'c.top_elevation', 'c.bottom_elevation', 'c.walkup_possible', 'c.walkup_separate',
+                                                        'c.lift', 'c.night_light', 'c.public_transport', 'c.sled_rental', 'c.information_phone', 'c.information_web',
+                                                        's.show_status', 'r.status', 'r.last_check', 'r.last_update'],
+                                                       $where_array,
+                                                       'bahnentabelleParserHook',
+                                                       ['ORDER BY' => 'p.page_title'],
+                                                       ['p' => ['JOIN', 'p.page_id=c.page_id'], 'r' => ['JOIN', 's.intermaps_sledrun_id=r.intermaps_sledrun_id'], 'AA' => ['LEFT OUTER JOIN', 'p.page_id=s.wr_page_id']]
+                                               );
 
                global $wgUser;
                global $wgWrReportMode; // e.g. 'summer'
                global $wgWrReportBlackListAll;
                global $wgWrReportBlackListStrangers;
-               global $wgDBtype;
 
                // Determine, whether the user is allowed to make a new report
                $userMayReport = ($wgWrReportMode == 'allow' || ($wgWrReportMode == 'loggedin' && $wgUser->isLoggedIn()));
@@ -777,6 +788,7 @@ class WrReport {
                $tr->appendElement('th')->appendElement('img', array('src' => '/vorlagen/s_lift.png', 'alt' => wfMessage('wrreport-icon-lift')->text(), 'title' => wfMessage('wrreport-icon-lift')->text()));
                $tr->appendElement('th')->appendElement('img', array('src' => '/vorlagen/s_walk.png', 'alt' => wfMessage('wrreport-icon-walkupseparate')->text(), 'title' => wfMessage('wrreport-icon-walkupseparate')->text()));
                $tr->appendElement('th')->appendElement('img', array('src' => '/vorlagen/s_bus.png', 'alt' => wfMessage('wrreport-icon-publictransport')->text(), 'title' => wfMessage('wrreport-icon-publictransport')->text()));
+               if ($wgWrReportMode != 'summer') $tr->appendElement('th')->appendElement('img', array('src' => '/vorlagen/s_opened.png', 'alt' => wfMessage('wrreport-icon-intermaps-status')->text(), 'title' => wfMessage('wrreport-icon-intermaps-status')->text()));
                $tr->appendElement('th')->appendText(wfMessage('wrreport-sledrun')->text());
                if ($wgWrReportMode != 'summer') $tr->appendElement('th')->appendText(wfMessage('wrreport-newreport-condition')->text());
                $tr->appendElement('th')->appendText(wfMessage('wrreport-sledrun-information')->text());
@@ -808,6 +820,22 @@ class WrReport {
                        $td = $tr->appendElement('td');
                        if ($row->public_transport and $row->public_transport != 5) $td->appendElement('img', array('src' => '/vorlagen/s_bus.png', 'alt' => wfMessage('wrreport-icon-publictransport')->text(), 'title' => wfMessage('wrreport-icon-publictransport')->text()));
 
+                       if ($wgWrReportMode != 'summer') {
+                               $td = $tr->appendElement('td');
+                               if ($row->show_status) {
+                                       if ($row->status == 'open') {
+                                               $td->appendElement('img', array('src' => '/vorlagen/s_opened.png', 'alt' => wfMessage('wrreport-icon-intermaps-opened')->text(), 'title' => wfMessage('wrreport-icon-intermaps-opened')->text()));
+                                       } elseif ($row->status == 'closed') {
+                                               $td->appendElement('img', array('src' => '/vorlagen/s_closed.png', 'alt' => wfMessage('wrreport-icon-intermaps-closed')->text(), 'title' => wfMessage('wrreport-icon-intermaps-closed')->text()));
+                                       } else {
+                                               $td->appendText($row->status);
+                                       }
+                               }
+                               // s_closed
+                               // no info
+                               // check whether info should be shown at all
+                       }
+
                        $tr->appendElement('td')->appendElement('a', array('href' => $title->getLocalURL()))->appendText($title->getPrefixedText());
 
                        if ($wgWrReportMode != 'summer') {