function validate_form($article_title = "") { global $wgOut, $wgLang, $wgUser, $wgArticle, $wgRequest; if ($wgUser->getID() == 0) { # Anon $wgOut->addHTML(htmlspecialchars(wfMsg('val_no_anon_validation')) . $this->getPageStatistics($article_title)); return; } $validationtypes = $wgLang->getValidationTypes(); if ($article_title == "") { $article_title = $wgRequest->getVal('article_title'); $heading = "<h1>" . htmlspecialchars($article_title) . "</h1>\n"; } else { $heading = ""; } $article_time = ""; $article_time = $wgRequest->getVal('timestamp'); $article = Title::newFromText($article_title); if (is_null($article)) { $wgOut->errorpage("badtitle", "badtitletext"); return; } # Now we get all the "votes" for the different versions of this article for this user $val = $this->get_prev_data($wgUser->getID(), $article_title); # No votes for this version, initial data if (!isset($val[$article_time])) { if ($article_time == "") { $res = wfQuery("select cur_timestamp FROM cur WHERE cur_title='" . wfStrencode($article_title) . "' AND cur_namespace=" . NS_MAIN, DB_READ); if ($s = wfFetchObject($res)) { $article_time = $s->cur_timestamp; } } $val[$article_time] = array(); } # Newest versions first krsort($val); # User has clicked "Doit" before, so evaluate form if ($wgRequest->wasPosted()) { $oldtime = StrVal($wgRequest->getVal('oldtime')); if (!isset($val[$oldtime])) { $val[$oldtime] = array(); } # Reading postdata $postrad = array(); $poscomment = array(); for ($idx = 0; $idx < count($validationtypes); $idx++) { $postrad[$idx] = $wgRequest->getVal("rad{$idx}"); $postcomment[$idx] = $wgRequest->getText("comment{$idx}"); } # Merge others into this one if ($wgRequest->getCheck('merge_other')) { foreach ($val as $time => $stuff) { if ($time != $article_time) { for ($idx = 0; $idx < count($validationtypes); $idx++) { $rad = $postrad[$idx]; if (isset($stuff[$idx]) && $stuff[$idx]->val_value != -1 && $rad == -1) { $postrad[$idx] = $stuff[$idx]->val_value; $postcomment[$idx] = $stuff[$idx]->val_comment; } } } } } # Clear all others if ($wgRequest->getCheck('clear_other')) { $sql = "DELETE FROM validate WHERE val_title='" . wfStrencode($article_title) . "' AND val_timestamp<>'" . wfStrencode($oldtime) . "' AND val_user='******'"; wfQuery($sql, DB_WRITE); $val2 = $val[$oldtime]; # Only version left $val = array(); # So clear others $val[$oldtime] = $val2; } # Delete old "votes" for this version $sql = "DELETE FROM validate WHERE val_title='" . wfStrencode($article_title) . "' AND val_timestamp='" . wfStrencode($oldtime) . "' AND val_user='******'"; wfQuery($sql, DB_WRITE); # Incorporate changes for ($idx = 0; $idx < count($validationtypes); $idx++) { $comment = $postcomment[$idx]; $rad = $postrad[$idx]; if (!isset($val[$oldtime][$idx])) { $val[$oldtime][$idx] = ""; } $val[$oldtime][$idx]->val_value = $rad; $val[$oldtime][$idx]->val_comment = $comment; if ($rad != -1) { # Store it in the database $sql = "INSERT INTO validate (val_user,val_title,val_timestamp,val_type,val_value,val_comment) " . "VALUES ( '" . wfStrencode($wgUser->getID()) . "','" . wfStrencode($article_title) . "','" . wfStrencode($oldtime) . "','" . wfStrencode($idx) . "','" . wfStrencode($rad) . "','" . wfStrencode($comment) . "')"; wfQuery($sql, DB_WRITE); } } $wgArticle->showArticle("Juhuu", wfMsg('val_validated')); return; # Show article instead of validation page } # Generating HTML $html = ""; $skin = $wgUser->getSkin(); $staturl = $skin->makeSpecialURL("validate", "mode=stat_page&article_title=" . urlencode($article_title)); $listurl = $skin->makeSpecialURL("validate", "mode=list_page"); $html .= "<a href=\"" . htmlspecialchars($staturl) . "\">" . wfMsg('val_stat_link_text') . "</a> \n"; $html .= "<a href=\"" . htmlspecialchars($listurl) . "\">" . wfMsg('val_article_lists') . "</a><br />\n"; $html .= "<small>" . wfMsg('val_form_note') . "</small><br />\n"; # Generating data tables $tabsep = "<td width='0' style='border-left:2px solid black;'></td>"; $topstyle = "style='border-top:2px solid black'"; foreach ($val as $time => $stuff) { $tablestyle = "cellspacing='0' cellpadding='2'"; if ($article_time == $time) { $tablestyle .= " style='border: 2px solid red'"; } $html .= "<h2>" . wfMsg('val_version_of', gmdate("F d, Y H:i:s", wfTimestamp(TW_UNIX, $time))); $this->find_this_version($article_title, $time, $table_id, $table_name); if ($table_name == "cur") { $html .= " (" . wfMsg('val_this_is_current_version') . ")"; } $html .= "</h2>\n"; $html .= "<form method='post'>\n"; $html .= "<input type='hidden' name='oldtime' value=\"" . htmlspecialchars($time) . "\" />"; $html .= "<table {$tablestyle}>\n"; $html .= wfMsg('val_table_header', $tabsep); for ($idx = 0; $idx < count($validationtypes); $idx++) { $x = explode("|", $validationtypes[$idx], 4); if (isset($stuff[$idx])) { $choice = $stuff[$idx]->val_value; } else { $choice = -1; } if (isset($stuff[$idx])) { $comment = $stuff[$idx]->val_comment; } else { $comment = ""; } $html .= "<tr><th align='left'>{$x[0]}</th>{$tabsep}<td align='right'>{$x[1]}</td>" . "<td align='center'><span style='white-space: nowrap;'>"; for ($cnt = 0; $cnt < $x[3]; $cnt++) { $html .= "<input type='radio' name='rad{$idx}' value='{$cnt}'"; if ($choice == $cnt) { $html .= " checked='checked'"; } $html .= " /> "; } $html .= "</span></td><td>{$x[2]}</td>"; $html .= "<td><input type='radio' name='rad{$idx}' value='-1'"; if ($choice == -1) { $html .= " checked='checked'"; } $html .= " /> " . wfMsg("val_noop") . "</td>{$tabsep}"; $html .= "<td><input type='text' name='comment{$idx}' value=\"" . htmlspecialchars($comment) . "\" /></td>"; $html .= "</tr>\n"; } $html .= "<tr><td {$topstyle} colspan='2'>"; # link to version $title = Title::newFromDBkey($article_title); if ($table_name == "cur") { $link_version = $title->getLocalURL(""); } else { $link_version = $title->getLocalURL("oldid={$table_id}"); } $link_version = "<a href=\"" . htmlspecialchars($link_version) . "\">" . wfMsg('val_view_version') . "</a>"; $html .= $link_version; $html .= "</td><td {$topstyle} colspan='5'>"; $html .= "<input type='checkbox' name='merge_other' value='1' checked='checked' />"; $html .= wfMsg('val_merge_old'); $html .= "<br /><input type='checkbox' name='clear_other' value='1' checked='checked' />"; $html .= wfMsg('val_clear_old', $skin->makeKnownLinkObj($article)); $html .= "</td><td {$topstyle} align='right' valign='center'><input type='submit' name='doit' value=\"" . htmlspecialchars(wfMsg("ok")) . "\" /></td>"; $html .= "</tr></table></form>\n"; } $html .= "<h2>" . wfMsg('preview') . "</h2>"; $wgOut->addHTML($html); $wgOut->addWikiText($wgArticle->getContent(true)); }
function GetConfigString(&$cfg_elem, $key) { if (isset($cfg_elem[$key][0])) { return StrVal($cfg_elem[$key][0]); } else { return FALSE; } }
/** * @param object $row * @access private */ function Revision($row) { if (is_object($row)) { $this->mId = IntVal($row->rev_id); $this->mPage = IntVal($row->rev_page); $this->mTextId = IntVal($row->rev_text_id); $this->mComment = $row->rev_comment; $this->mUserText = $row->rev_user_text; $this->mUser = IntVal($row->rev_user); $this->mMinorEdit = IntVal($row->rev_minor_edit); $this->mTimestamp = $row->rev_timestamp; $this->mDeleted = IntVal($row->rev_deleted); $this->mCurrent = $row->rev_id == $row->page_latest; $this->mTitle = Title::makeTitle($row->page_namespace, $row->page_title); if (isset($row->old_text)) { $this->mText = $this->getRevisionText($row); } else { $this->mText = null; } } elseif (is_array($row)) { // Build a new revision to be saved... global $wgUser; $this->mId = isset($row['id']) ? IntVal($row['id']) : null; $this->mPage = isset($row['page']) ? IntVal($row['page']) : null; $this->mTextId = isset($row['text_id']) ? IntVal($row['text_id']) : null; $this->mUserText = isset($row['user_text']) ? StrVal($row['user_text']) : $wgUser->getName(); $this->mUser = isset($row['user']) ? IntVal($row['user']) : $wgUser->getId(); $this->mMinorEdit = isset($row['minor_edit']) ? IntVal($row['minor_edit']) : 0; $this->mTimestamp = isset($row['timestamp']) ? StrVal($row['timestamp']) : wfTimestamp(TS_MW); $this->mDeleted = isset($row['deleted']) ? IntVal($row['deleted']) : 0; // Enforce spacing trimming on supplied text $this->mComment = isset($row['comment']) ? trim(StrVal($row['comment'])) : null; $this->mText = isset($row['text']) ? rtrim(StrVal($row['text'])) : null; $this->mTitle = null; # Load on demand if needed $this->mCurrent = false; } else { wfDebugDieBacktrace('Revision constructor passed invalid row format.'); } }