}
+ /// \brief Is called when the tag <rodelbahntabelle/> is encountered.
+ ///
+ /// Description: See description of wrreport.php
+ public static function rodelbahntabelleParserHook($input, $args, $parser) {
+ $parser->getOutput()->addModules('ext.wrreport');
+ $dbr = wfGetDB(DB_SLAVE);
+
+ try {
+ libxml_use_internal_errors(true); // without that, we get PHP Warnings if the $input is not well-formed
+ $xml = new SimpleXMLElement('<rodelbahntabelle>' . $input . '</rodelbahntabelle>'); // input
+ $whitespace = (string) $xml; // everything between <rodelbahntabelle> and </rodelbahntabelle> that's not a sub-element
+ if (strlen($whitespace) > 0 && !ctype_space($whitespace)) // there must not be anythin except sub-elements or whitespace
+ throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-textbetweenelements', trim($xml))->text());
+
+ // page_ids of sledrun titles that that are going to be returned
+ $page_ids = array();
+ foreach ($xml as $entry) { // entry is <rodelbahn>, <region> or <rodelbahnen>
+ $tagname = $entry->getName();
+ $attributes = array();
+ foreach ($entry->attributes() as $key => $value) $attributes[] = $key;
+
+ // is the element known?
+ if (!in_array($tagname, array('rodelbahn', 'region', 'rodelbahnen')))
+ throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-invalid-element', $tagname)->text());
+
+ // parse operation attribute
+ $operation = '+'; // '+' (append) or '-' (subtract)
+ if (array_key_exists('operation', $attributes)) {
+ $operation = $attributes['operation'];
+ if (!in_array($operation, array('+', '-')))
+ throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-invalid-attribute-value', $tagname, 'operation', $operation)->text());
+ unset($attributes['operation']);
+ }
+
+ // parse in_arbeit attribute
+ $unter_construction = false;
+ if (array_key_exists('in_arbeit', $attributes)) {
+ if (!in_array($attributes['in_arbeit'], array('ja', 'nein', '*')))
+ throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-invalid-attribute-value', $tagname, 'operation', $operation)->text());
+ if (in_array($attributes['in_arbeit'] === 'nein')) $under_construction = false;
+ elseif (in_array($attributes['*'] === '*')) $under_construction = null;
+ unset($attributes['in_arbeit']);
+ }
+
+ // any attributes left that are not handled yet?
+ if (count($attributes) > 0)
+ throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-invalid-attribute-name', $tagname, array_keys($attributes)[0])->text());
+
+ // <rodelbahn>
+ if ($tagname == 'rodelbahn') {
+ }
+
+ // <region>
+ elseif ($tagname == 'region') {
+ // get titles that are in the region
+ // the following line would work if MySQL 5.5 would implement a real geospatial version of CONTAINS.
+ // $res = $dbr->select('wrsledruncache', 'page_id', array('CONTAINS(GEOMFROMWKB(' . $dbr->addQuotes($region_border_wkb) . '), POINT(position_longitude, position_latitude))', 'NOT under_construction'), __METHOD__, 'page_title');
+ $res = $dbr->select(array('wrsledruncache', 'wrregioncache'), array('page_id' => 'wrregioncache.page_id'), array('wrregioncache.region_id' => $region_id, 'wrregioncache.page_id=wrsledruncache.page_id', 'NOT under_construction'), __METHOD__, 'page_title');
+ foreach ($res as $row) {
+ $page_titles[] = Title::newFromId($row->page_id);
+ }
+ $dbr->freeResult($res);
+ }
+
+ // <rodelbahnen>
+ elseif ($tagname == 'rodelbahnen') {
+ }
+
+ else throw new WrReportException(wfMessage('wrreport-rodelbahntabelle-invalid-element', $tagname)->text());
+
+ }
+
+ // page_titles that are going to be returned
+ $page_titles = array();
+ foreach ($page_id as $page_ids) {
+ $page_titles[] = Title::newFromId($page_id);
+ }
+ $html = WrReport::createBahnentabelle($page_titles);
+
+ } catch (WrReportException $e) {
+ $doc = new WrDOMDocument();
+ $doc->appendElement('span', array('class' => 'error'))->appendText(wfMessage('wrreport-rodelbahntabelle-error', $e->getMessage())->text());
+ $html = $doc->saveHTML($doc->firstChild);
+ }
+
+ return array($html, 'noparse' => true, 'isHTML' => true);
+ }
+
+
/// \brief Is called when the tag <avatar>username</avatar> is encountered.
public static function avatarParserHook($input, $args, $parser, $frame) {
$doc = new WrDOMDocument();
'wrreport-bahnenregiontabelle-noregionname' => 'Text. Error message saying that the specified region name was not found in the database (table wrregion)',
'wrreport-bahnenregiontabelle-invalidargument' => 'Text. Error message saying that the argument (given by $1) of <bahnenregiontabelle> is invalid',
'wrreport-bahnenregiontabelle-error' => 'Text. Text describing that an error in paring/using the <bahnenregiontabelle> tag occurred. $1 gives details.',
+ 'wrreport-rodelbahntabelle-textbetweenelements' => 'Text. Error message describing that invalid text is found between elements. $1 gives the complete XML.',
+ 'wrreport-rodelbahntabelle-invalid-element' => 'Text. Error message describing that the element given as $1 is not known.',
+ 'wrreport-rodelbahntabelle-invalid-attribute-name' => 'Text. Error message describing that the attribute given as $2 of the elment given as $1 is not known.',
+ 'wrreport-rodelbahntabelle-invalid-attribute-value' => 'Text. Error message describing that the value $3 of the attribut given as $2 of the element given as $1 is not known.',
'wrreport-icon-sledrental' => 'Text',
'wrreport-icon-nightlight' => 'Text',
'wrreport-icon-lift' => 'Text',
'wrreport-bahnenregiontabelle-noregionname' => 'The specified region name was not found in the region table of the database.',
'wrreport-bahnenregiontabelle-invalidargument' => 'The argument $1 is not allowed.',
'wrreport-bahnenregiontabelle-error' => 'The following error occurred at the <bahnenregiontabelle> tag: $1',
+ 'wrreport-rodelbahntabelle-textbetweenelements' => 'Unknown text was found between the subelements: $1',
+ 'wrreport-rodelbahntabelle-invalid-element' => 'The element $1 is not known.',
+ 'wrreport-rodelbahntabelle-invalid-attribute-name' => 'The attribute $2 of element $1 is not known.',
+ 'wrreport-rodelbahntabelle-invalid-attribute-value' => 'The value $3 of attribute $2 of element $1 is not known.',
'wrreport-icon-sledrental' => 'Sled Rental',
'wrreport-icon-nightlight' => 'Light at Night',
'wrreport-icon-lift' => 'Help me get up',