Created own function to add the feed link.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 16 Nov 2013 22:54:48 +0000 (22:54 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 16 Nov 2013 22:54:48 +0000 (22:54 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@1817 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport.body.php

index 0c1af5db9cf743fbaf25b3c1c6768fc093283e39..0c9811e19c80bf2446195afb0e4da365918f345a 100644 (file)
@@ -618,7 +618,31 @@ class WrReport {
        }
 
 
        }
 
 
-       public static function createBahnentabelle($page_titles) {
+       /// Adds a region feed to the current page
+       private static function addRegionFeedLink($parser) {
+               $dbr = wfGetDB(DB_SLAVE);
+               $title = $parser->getTitle();
+               $categories = $title->getParentCategories(); // e.g. array('Kategorie:Region' => 'Osttirol')
+               global $wgContLang;
+               $key_region = $wgContLang->getNSText(NS_CATEGORY) . ':Region';
+               if (array_key_exists($key_region, $categories)) {
+                       // 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/' . strtolower($row->name));
+                       }
+               }
+               $dbr->freeResult($res);
+       }
+
+
+       /// Creates the HTML of the <bahnentabelle> and <bahnenregiontabelle> tags.
+       private static function createBahnentabelle($page_titles) {
                $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
                $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
@@ -752,24 +776,7 @@ class WrReport {
                $parser->getOutput()->addModules('ext.wrreport');
 
                // Add feed
                $parser->getOutput()->addModules('ext.wrreport');
 
                // Add feed
-               $dbr = wfGetDB(DB_SLAVE);
-               $title = $parser->getTitle();
-               $categories = $title->getParentCategories(); // e.g. array('Kategorie:Region' => 'Osttirol')
-               global $wgContLang;
-               $key_region = $wgContLang->getNSText(NS_CATEGORY) . ':Region';
-               if (array_key_exists($key_region, $categories)) {
-                       // 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/' . strtolower($row->name));
-                       }
-               }
-               $dbr->freeResult($res);
+               WrReport::addRegionFeedLink($parser);
 
                // Add each page title that has been found
                $page_titles = array(); // array of Title objects
 
                // Add each page title that has been found
                $page_titles = array(); // array of Title objects