setHook('bahnberichtformular', 'bahnberichtformularParserHook'); $wgParser->setHook('bahnberichte', 'bahnberichteParserHook'); $wgParser->setHook('bahnbewertung', 'bahnbewertungParserHook'); return true; } // Tool functions // -------------- /// \brief This function is used to translate WikiText to HTML. Normally it should be avoided to do this /// but I found situations where I did not find an other possibility. function wrReportSandboxParse($wikiText) { global $wgTitle, $wgUser; $myParser = new Parser(); $myParserOptions = new ParserOptions(); $myParserOptions->initialiseFromUser($wgUser); $result = $myParser->parse($wikiText, $wgTitle, $myParserOptions); return $result->getText(); } /// List of markers - used by the functions replaceByMarker and wrReportAfterTidy $wrReportMarkerList = array(); /// Returns a marker for a text and back-replaces the text in wrReportAfterTidy function replaceByMarker($text, $marker = 'marker') { $marker = $marker . mt_rand(1e5, 1e7); global $wrReportMarkerList; $wrReportMarkerList[$marker] = $text; return $marker; } /// Replaces the markers by its contents function wrReportAfterTidy(&$parser, &$text) { // find markers in $text // replace markers with actual output global $wrReportMarkerList; foreach ($wrReportMarkerList as $marker => $html) $text = str_replace($marker, $html, $text); return true; } // Render Functions // ---------------- /// \brief Returns a form to enter a report (string containing HTML). /// /// All parameters have to be UTF-8 encoded. /// \param $page_title Name of the sledding run. /// \return UTF-8 encoded HTML form function wrReportFormRender($hide_save_button = TRUE, $page_title = NULL, $date_report = NULL, $condition = NULL, $description = NULL, $author_name = NULL, $page_title_list = NULL) { if ($page_title) $page_title = htmlspecialchars($page_title); // Date options $tagnamen = array('Heute', 'Gestern', 'Vorgestern', 'Vor 3 Tagen', 'Vor 4 Tagen'); $date_options = ''; $date_selected = FALSE; for ($tag=0; $tag!=5; ++$tag) { $datum = time() - $tag*24*60*60; $datum_f = strftime("%Y-%m-%d", $datum); $date_options .= '\n" . $date_options; } // Condition options $condition_options = ''; global $wrConditions; // $wrConditions = array(1 => 'Sehr gut', 2 => 'Gut', 3 => utf8_encode('Mittelmäßig'), 4 => 'Schlecht', 5 => 'Geht nicht'); $condition_options .= utf8_encode('') . "\n"; foreach ($wrConditions as $condition_num => $condition_text) { $condition_options .= "