}
+/// \brief It returns an array of the "condition" (as number) and the date of the "most recent" report of the specified page (to decode as list($condition, $date);
+///
+/// If no condition is present, NULL is returned
+function wrReportConditionRender($page_title) {
+ $dbr = wfGetDB(DB_SLAVE);
+ $res = $dbr->select('wrreport', array('max(wrreport.id) as max'), array("page_title='Birgitzer Alm (vom Adelshof)'"));
+ // select condition, date_report from wrreport where id = (select max(wrreport.id) as max from wrreport where page_title='Birgitzer Alm (vom Adelshof)' and date_invalid > now() and condition is not null);
+ if ($res->numRows() <= 0) return NULL;
+ $row = $dbr->fetchObject($res);
+ $res = $dbr->select('wrreport', array('condition', 'date_report'), array('id' => $row->max));
+ if ($res->numRows() <= 0) return NULL;
+ $row = $dbr->fetchObject($res);
+ return array($row->condition, $row->date_report);
+}
+
+
// Parser Hook Functions
// ---------------------
/// * <bahnbewertung>page_name</bahnbewertung>: The given page name is taken.
function bahnbewertungParserHook($input, $args, &$parser) {
if (!$input) $input = $parser->getTitle()->getText();
- return wrReportConditionRender($input);
+ list($condition, $date) = wrReportConditionRender($input);
+ return "$condition ($date)";
}
+
// Special page
// ------------