Basic functionality of <bahnenregiontabelle> implemented.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 16 Nov 2013 22:54:53 +0000 (22:54 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 16 Nov 2013 22:54:53 +0000 (22:54 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@1820 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport.body.php

index 4bc2cc9c154bc9aa04fa908b86f5a7b03c333211..95f008c123ca83848b021f84f959cfeb790c7664 100644 (file)
@@ -812,9 +812,22 @@ class WrReport {
        /// <bahnenregiontabelle region="Innsbruck" />
        public static function bahnenregiontabelleParserHook($input, $args, $parser) {
                $parser->getOutput()->addModules('ext.wrreport');
-               $sql = 'SELECT page_title, position_longitude, position_latitude, under_construction FROM wrsledruncache WHERE MBRCONTAINS((SELECT border FROM wrregion WHERE page_id = %s), POINT(position_longitude, position_latitude))';
 
+               // get border for region
+               list($region_name, $region_border_wkb) = WrReport::getPageRegion($parser->getTitle());
+               if (is_null($region_name)) return; // no region page
+
+               // get titles that are in the region
                $page_titles = array();
+               $dbr = wfGetDB(DB_SLAVE);
+               $res = $dbr->select('wrsledruncache', 'page_id', array('CONTAINS(GEOMFROMWKB(' . $dbr->addQuotes($region_border_wkb) . '), POINT(position_longitude, position_latitude))', 'under_construction' => false), __METHOD__, 'page_title');
+               foreach ($res as $row) {
+                       $page_titles[] = Title::newFromId($row->page_id);
+               }
+               $dbr->freeResult($res);
+
+               // note that MySQL returns too many data compared to real "CONTAINS".
+
                $html = WrReport::createBahnentabelle($page_titles);
                return array($html, 'noparse' => true, 'isHTML' => true);
        }