Implemented showing region dependent feed on region pages.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 27 Oct 2013 22:02:41 +0000 (22:02 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 27 Oct 2013 22:02:41 +0000 (22:02 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@1766 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport.body.php

index 3711ede2ce2494ff48c4ab90a0dc03a136684c44..83a7e6f8eb0062f508dbd16512c310e2fd062d79 100644 (file)
@@ -628,6 +628,25 @@ class WrReport {
        /// </bahnentabelle>
        public static function bahnentabelleParserHook($input, $args, $parser) {
                $parser->getOutput()->addModules('ext.wrreport');
+
+               // Add feed
+               $dbr = wfGetDB(DB_SLAVE);
+               $title = $parser->getTitle();
+               $categories = $title->getParentCategories(); // e.g. 'Kategorie:Region' => 'Osttirol'
+               if (array_key_exists('Kategorie:Region', $categories)) { // TODO: As this is the German name, I don't think it's working generally.
+                       // Do we have a feed entry of the region?
+                       // Example: select name from wrregion where page_id = 882;
+                       $res = $dbr->select('wrregion', 'name', array('page_id' => $title->getArticleID()));
+                       while ($row = $dbr->fetchObject($res)) {
+                               // If yes, create the feed.
+                               // Note: As (of MediaWiki 1.19), only one feed can be added and each feed added replaces the previous one, the following is possible without risk of having duplicated feed entries.
+                               global $wgWrReportFeedRoot;
+                               global $wgOut; // class OutputPage
+                               $wgOut->addFeedLink('atom', $wgWrReportFeedRoot . '/berichte/region/' . $row->name);
+                       }
+               }
+
+               // Add each page title that has been found
                $page_titles = array(); // array of Title objects
                foreach (explode("\n", $input) as $page_title) {
                        $page_title = Title::newFromText(trim($page_title));
@@ -635,7 +654,6 @@ class WrReport {
                        $page_titles[] = $page_title;
                }
 
-               $dbr = wfGetDB(DB_SLAVE);
                // 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');
                if (count($page_titles) > 0) {