// 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;
-}
-
-
/// Forces a regeneration of region overview pages
function wrRecacheRegions() {
// TODO: Better implementation - it's a "quick fix" now.
// $id
if ($format == WRREPORT_DETAIL) $out .= '<td>' . $id . '</td>';
// $page_title
- if ($format != WRREPORT_COMPACT) $out .= '<td>' . wrReportSandboxParse('[[' . $page_title . ']]') . '</td>';
+ if ($format != WRREPORT_COMPACT) $out .= '<td>' . wrCommonSandboxParse('[[' . $page_title . ']]') . '</td>';
// $date_report
$dayOfWeek = array('Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So');
$date_report = strtotime($date_report);
// $description
$out .= '<td class="wrreportdescription">';
if ($delete_date) $out .= utf8_encode('<em>Gelöscht</em>');
- else $out .= wrReportSandboxParse($description);
+ else $out .= wrCommonSandboxParse($description);
$out .= '</td>';
// $author_name
$out .= '<td>';
global $wgWrReportMode;
global $wgWrReportBlackListAll;
global $wgWrReportBlackListStrangers;
- if ($wgWrReportMode == 'summer') return wrReportSandboxParse(utf8_encode("''An dieser Stelle kann während des Winters die Schneelage von Rodelbahnen eingetragen werden.''\n\n"));
- if ($wgWrReportMode == 'deny') return wrReportSandboxParse(utf8_encode("''Rodelbahnberichte sind derzeit leider nicht erlaubt.''\n\n"));
+ if ($wgWrReportMode == 'summer') return wrCommonSandboxParse(utf8_encode("''An dieser Stelle kann während des Winters die Schneelage von Rodelbahnen eingetragen werden.''\n\n"));
+ if ($wgWrReportMode == 'deny') return wrCommonSandboxParse(utf8_encode("''Rodelbahnberichte sind derzeit leider nicht erlaubt.''\n\n"));
- if ($wgWrReportMode == 'loggedin' && !$wgUser->isLoggedIn()) return wrReportSandboxParse(utf8_encode("''Derzeit sind Rodelbahnberichte nur für angemeldete Benutzer erlaubt.''\n\n"));
+ if ($wgWrReportMode == 'loggedin' && !$wgUser->isLoggedIn()) return wrCommonSandboxParse(utf8_encode("''Derzeit sind Rodelbahnberichte nur für angemeldete Benutzer erlaubt.''\n\n"));
- if (in_array($parser->getTitle()->getText(), $wgWrReportBlackListAll)) return wrReportSandboxParse(utf8_encode("''Bei dieser Rodelbahn dürfen derzeit leider keine Rodelbahnberichte abgegeben werden.''\n"));
- if (!$wgUser->isLoggedIn() && in_array($parser->getTitle()->getText(), $wgWrReportBlackListStrangers)) return wrReportSandboxParse(utf8_encode("''Bei der angegebenen Rodelbahn dürfen derzeit nur angemeldete Benutzer Rodelbahnberichte abgebe.''\n\n"));
+ if (in_array($parser->getTitle()->getText(), $wgWrReportBlackListAll)) return wrCommonSandboxParse(utf8_encode("''Bei dieser Rodelbahn dürfen derzeit leider keine Rodelbahnberichte abgegeben werden.''\n"));
+ if (!$wgUser->isLoggedIn() && in_array($parser->getTitle()->getText(), $wgWrReportBlackListStrangers)) return wrCommonSandboxParse(utf8_encode("''Bei der angegebenen Rodelbahn dürfen derzeit nur angemeldete Benutzer Rodelbahnberichte abgebe.''\n\n"));
// Calling "$title = $parser->getTitle(); $title->invalidateCache();" doesn't help here to force regeneration
// However, this would not be the best solution because the page has to be re-rendered only at midnight
// In the following line, $author_name was replaced by NULL to prevent a bug, where the wrong author_name
// is shown (see ticket #35). TODO: Find reason.
- // return replaceByMarker(wrReportFormRender(TRUE, $parser->getTitle()->getText(), NULL, NULL, NULL, $author_name));
- return replaceByMarker(wrReportFormRender(TRUE, $parser->getTitle()->getText(), NULL, NULL, NULL, NULL));
+ // return wrCommonReplaceByMarker(wrReportFormRender(TRUE, $parser->getTitle()->getText(), NULL, NULL, NULL, $author_name), 'wrform');
+ return wrCommonReplaceByMarker(wrReportFormRender(TRUE, $parser->getTitle()->getText(), NULL, NULL, NULL, NULL), 'wrform');
}
$conditions = array('page_title' => $page_title, 'date_invalid > now()');
$order = 'date_report desc, date_entry desc';
$rows = wrReportGetReports($conditions, $order);
- if (count($rows) == 0) return wrReportSandboxParse("''Es wurden keine Bahnberichte in der Datenbank gefunden.''\n\n");
+ if (count($rows) == 0) return wrCommonSandboxParse("''Es wurden keine Bahnberichte in der Datenbank gefunden.''\n\n");
return wrReportTableRender2($rows, WRREPORT_COMPACT, wrReportUserMayDelete());
}
if ($userMayReport) $wikiText = "<small>''[[" . $titleText . '#' . $wrNewReportSection . "|Bitte eintragen]]''</small>";
else $wikiText = '--';
}
- return wrReportSandboxParse($wikiText);
+ return wrCommonSandboxParse($wikiText);
}