";
if (!is_null($page_id)) $out .= '' . $page_id . ' | ';
if (!is_null($page_title)) $out .= '' . wrReportSandboxParse('[[' . $page_title . ']]') . ' | ';
$out .= '' . $date_report . ' | ';
if (!is_null($date_entry)) $out .= '' . date('Y-m-d, H:i', strtotime($date_entry)) . ' | ';
if (!is_null($date_invalid)) $out .= '' . date('Y-m-d, H:i', strtotime($date_invalid)) . ' | ';
$out .= '' . $condition . ' | ';
$out .= '' . htmlspecialchars($description) . ' | ';
$out .= '' . htmlspecialchars($author_name) . ' | ';
$out .= "
\n";
return $out;
}
/// \brief It returns a table (string containing HTML) showing the results.
///
/// Is called when the tag Es wurden keine Bahnberichte in der Datenbank gefunden.
\n";
}
$dbr->freeResult($res);
return $out;
}
/// \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, array(NULL, NULL) is returned
function wrReportConditionRender($page_title) {
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('wrreport', array('max(wrreport.id) as max'), array('page_title' => $page_title, 'condition is not null', 'date_invalid > now()'));
// 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 array(NULL, NULL);
$row = $dbr->fetchObject($res);
$res = $dbr->select('wrreport', array('condition', 'date_report'), array('id' => $row->max));
if ($res->numRows() <= 0) return array(NULL, NULL);
$row = $dbr->fetchObject($res);
return array($row->condition, $row->date_report);
}
// Parser Hook Functions
// ---------------------
/// \brief Is called when the tag ') . $errorMsg . utf8_encode("
\n"));
}
// Action view
if ($action == 'view') {
$wgOut->addHTML(wrRenderReportTable());
}
// Action preview or store
elseif ($action == 'preview' || $action == 'store') {
$page_title = $wgRequest->getText('page_title');
$date_report = $wgRequest->getText('date_report');
$condition = $wgRequest->getText('condition');
$description = $wgRequest->getText('description');
$author_name = $wgRequest->getText('author_name');
if ($action == 'store') {
// page_id
$title = Title::newFromText($page_title);
$page_id = $title->getArticleId();
if ($page_id == 0) $page_id = NULL;
// user_id
global $wgUser;
$author_userid = $wgUser->getId();
if ($author_userid == 0) $author_userid = NULL; // to store a NULL value in the database if no user is logged in instead of 0.
$author_username = $wgUser->getName();
// condition
$condition_int = (int) $condition;
if ($condition_int >= 1 and $condition_int <= 5) $condition = $condition_int;
else $condition = NULL;
// check conditions/permissions
$errorMsg = NULL;
global $wgWrReportMode;
global $wgWrReportBlackListAll;
global $wgWrReportBlackListStrangers;
if ($wgWrReportMode == 'summer') $errorMsg = utf8_encode('Rodelbahnberichte sind in der schneefreien Zeit nicht erlaubt.');
elseif ($wgWrReportMode == 'deny') $errorMsg = utf8_encode('Rodelbahnberichte sind derzeit leider nicht erlaubt.');
elseif ($wgWrReportMode == 'loggedin' && !$wgUser->isLoggedIn()) $errorMsg = utf8_encode('Derzeit sind Rodelbahnberichte nur für angemeldete Benutzer erlaubt.');
elseif (!$page_id) $errorMsg = utf8_encode('Die angegebene Seite wurde nicht gefunden.');
elseif (in_array($page_title, $wgWrReportBlackListAll)) $errorMsg = utf8_encode('Bei der angegebenen Rodelbahn dürfen derzeit keine Rodelbahnberichte abgegeben werden.');
elseif (!$wgUser->isLoggedIn() && in_array($page_title, $wgWrReportBlackListStrangers)) $errorMsg = utf8_encode('Bei der angegebenen Rodelbahn dürfen derzeit nur angemeldete Benutzer Rodelbahnberichte abgebe.');
elseif (!$condition && !$description) $errorMsg = utf8_encode('Es sind sowohl die Beschreibung als auch die Bewertung leer/nicht vergeben.');
elseif (!$wgUser->isLoggedIn()) {
if (!$description) $errorMsg = utf8_encode('Bitte bei der Beschreibung eine kurze Begründung für die Bewertung abgeben.');
elseif (!(stripos($description, 'http') === FALSE)) $errorMsg = utf8_encode('Der Text "http" ist leider für nicht-angemeldete Benutzer nicht erlaubt, weil wir in der Vergangenheit Fälle hatten, bei denen externe Werbelinks automatisiert eingetragen wurden.');
}
if ($errorMsg) {
$this->execute($par, 'preview', $errorMsg);
return;
}
// Save entry
$dbr = wfGetDB(DB_MASTER);
$dbr->insert(
'wrreport',
array(
'page_id' => $page_id,
'page_title' => $page_title,
'date_report' => $date_report,
// 'date_entry' => '', // use database default
// 'date_invalid' => '', // use database default
'condition' => $condition,
'description' => $description,
'author_name' => $author_name,
'author_ip' => $_SERVER['REMOTE_ADDR'],
'author_userid' => $author_userid,
'author_username' => $author_username
)
);
// Purge cache
$title->invalidateCache();
// Show success message
$wgOut->addWikiText(utf8_encode('Der Bahnbericht für [[') . $page_title . utf8_encode('#Einträge|') . $page_title . utf8_encode("]] wurde erfolgreich gespeichert.
\n"));
// We could redirect to result with the following line but we don't want to.
// $wgOut->redirect($title->getFullURL() . '#Eintr.C3.A4ge');
}
if ($action == 'preview') {
$wgOut->addWikiText(utf8_encode("== Vorschau (noch nicht gespeichert) ==\n"));
$wgOut->addHTML("