protected function showHistory() { $this->checkReadOnly(); $out = $this->getOutput(); if ($this->mAllowed) { $out->addModules('mediawiki.special.undelete'); } $out->wrapWikiMsg("<div class='mw-undelete-pagetitle'>\n\$1\n</div>\n", array('undeletepagetitle', wfEscapeWikiText($this->mTargetObj->getPrefixedText()))); $archive = new PageArchive($this->mTargetObj, $this->getConfig()); Hooks::run('UndeleteForm::showHistory', array(&$archive, $this->mTargetObj)); /* $text = $archive->getLastRevisionText(); if( is_null( $text ) ) { $out->addWikiMsg( 'nohistory' ); return; } */ $out->addHTML('<div class="mw-undelete-history">'); if ($this->mAllowed) { $out->addWikiMsg('undeletehistory'); $out->addWikiMsg('undeleterevdel'); } else { $out->addWikiMsg('undeletehistorynoadmin'); } $out->addHTML('</div>'); # List all stored revisions $revisions = $archive->listRevisions(); $files = $archive->listFiles(); $haveRevisions = $revisions && $revisions->numRows() > 0; $haveFiles = $files && $files->numRows() > 0; # Batch existence check on user and talk pages if ($haveRevisions) { $batch = new LinkBatch(); foreach ($revisions as $row) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text)); } $batch->execute(); $revisions->seek(0); } if ($haveFiles) { $batch = new LinkBatch(); foreach ($files as $row) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text)); } $batch->execute(); $files->seek(0); } if ($this->mAllowed) { $action = $this->getPageTitle()->getLocalURL(array('action' => 'submit')); # Start the form here $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete')); $out->addHTML($top); } # Show relevant lines from the deletion log: $deleteLogPage = new LogPage('delete'); $out->addHTML(Xml::element('h2', null, $deleteLogPage->getName()->text()) . "\n"); LogEventsList::showLogExtract($out, 'delete', $this->mTargetObj); # Show relevant lines from the suppression log: $suppressLogPage = new LogPage('suppress'); if ($this->getUser()->isAllowed('suppressionlog')) { $out->addHTML(Xml::element('h2', null, $suppressLogPage->getName()->text()) . "\n"); LogEventsList::showLogExtract($out, 'suppress', $this->mTargetObj); } if ($this->mAllowed && ($haveRevisions || $haveFiles)) { # Format the user-visible controls (comment field, submission button) # in a nice little table if ($this->getUser()->isAllowed('suppressrevision')) { $unsuppressBox = "<tr>\n\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel($this->msg('revdelete-unsuppress')->text(), 'wpUnsuppress', 'mw-undelete-unsuppress', $this->mUnsuppress) . "</td>\n\t\t\t\t\t</tr>"; } else { $unsuppressBox = ''; } $table = Xml::fieldset($this->msg('undelete-fieldset-title')->text()) . Xml::openElement('table', array('id' => 'mw-undelete-table')) . "<tr>\n\t\t\t\t\t<td colspan='2' class='mw-undelete-extrahelp'>" . $this->msg('undeleteextrahelp')->parseAsBlock() . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('undeletecomment')->text(), 'wpComment') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('wpComment', 50, $this->mComment, array('id' => 'wpComment', 'autofocus' => '')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td> </td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton($this->msg('undeletebtn')->text(), array('name' => 'restore', 'id' => 'mw-undelete-submit')) . ' ' . Xml::submitButton($this->msg('undeleteinvert')->text(), array('name' => 'invert', 'id' => 'mw-undelete-invert')) . "</td>\n\t\t\t</tr>" . $unsuppressBox . Xml::closeElement('table') . Xml::closeElement('fieldset'); $out->addHTML($table); } $out->addHTML(Xml::element('h2', null, $this->msg('history')->text()) . "\n"); if ($haveRevisions) { # The page's stored (deleted) history: $out->addHTML('<ul>'); $remaining = $revisions->numRows(); $earliestLiveTime = $this->mTargetObj->getEarliestRevTime(); foreach ($revisions as $row) { $remaining--; $out->addHTML($this->formatRevisionRow($row, $earliestLiveTime, $remaining)); } $revisions->free(); $out->addHTML('</ul>'); } else { $out->addWikiMsg('nohistory'); } if ($haveFiles) { $out->addHTML(Xml::element('h2', null, $this->msg('filehist')->text()) . "\n"); $out->addHTML('<ul>'); foreach ($files as $row) { $out->addHTML($this->formatFileRow($row)); } $files->free(); $out->addHTML('</ul>'); } if ($this->mAllowed) { # Slip in the hidden controls here $misc = Html::hidden('target', $this->mTarget); $misc .= Html::hidden('wpEditToken', $this->getUser()->getEditToken()); $misc .= Xml::closeElement('form'); $out->addHTML($misc); } return true; }
function showHistory() { global $wgLang, $wgContLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); if ($this->mAllowed) { $wgOut->setPagetitle(wfMsg("undeletepage")); } else { $wgOut->setPagetitle(wfMsg('viewdeletedpage')); } $archive = new PageArchive($this->mTargetObj); /* $text = $archive->getLastRevisionText(); if( is_null( $text ) ) { $wgOut->addWikiMsg( "nohistory" ); return; } */ if ($this->mAllowed) { $wgOut->addWikiMsg("undeletehistory"); } else { $wgOut->addWikiMsg("undeletehistorynoadmin"); } # List all stored revisions $revisions = $archive->listRevisions(); $files = $archive->listFiles(); $haveRevisions = $revisions && $revisions->numRows() > 0; $haveFiles = $files && $files->numRows() > 0; # Batch existence check on user and talk pages if ($haveRevisions) { $batch = new LinkBatch(); while ($row = $revisions->fetchObject()) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text)); } $batch->execute(); $revisions->seek(0); } if ($haveFiles) { $batch = new LinkBatch(); while ($row = $files->fetchObject()) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text)); } $batch->execute(); $files->seek(0); } if ($this->mAllowed) { $titleObj = SpecialPage::getTitleFor("Undelete"); $action = $titleObj->getLocalURL("action=submit"); # Start the form here $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete')); $wgOut->addHtml($top); } # Show relevant lines from the deletion log: $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n"); $logViewer = new LogViewer(new LogReader(new FauxRequest(array('page' => $this->mTargetObj->getPrefixedText(), 'type' => 'delete'))), LogViewer::NO_ACTION_LINK); $logViewer->showList($wgOut); if ($this->mAllowed && ($haveRevisions || $haveFiles)) { # Format the user-visible controls (comment field, submission button) # in a nice little table $align = $wgContLang->isRtl() ? 'left' : 'right'; $table = Xml::openElement('fieldset') . Xml::openElement('table') . "<tr>\n\t\t\t\t\t\t<td colspan='2'>" . wfMsgWikiHtml('undeleteextrahelp') . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='{$align}'>" . Xml::label(wfMsg('undeletecomment'), 'wpComment') . "</td>\n\t\t\t\t\t\t<td>" . Xml::input('wpComment', 50, $this->mComment) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t<td>" . Xml::submitButton(wfMsg('undeletebtn'), array('name' => 'restore', 'id' => 'mw-undelete-submit')) . Xml::element('input', array('type' => 'reset', 'value' => wfMsg('undeletereset'), 'id' => 'mw-undelete-reset')) . "</td>\n\t\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('fieldset'); $wgOut->addHtml($table); } $wgOut->addHTML("<h2>" . htmlspecialchars(wfMsg("history")) . "</h2>\n"); if ($haveRevisions) { # The page's stored (deleted) history: $wgOut->addHTML("<ul>"); $target = urlencode($this->mTarget); $remaining = $revisions->numRows(); $earliestLiveTime = $this->getEarliestTime($this->mTargetObj); while ($row = $revisions->fetchObject()) { $remaining--; $ts = wfTimestamp(TS_MW, $row->ar_timestamp); if ($this->mAllowed) { $checkBox = Xml::check("ts{$ts}"); $pageLink = $sk->makeKnownLinkObj($titleObj, $wgLang->timeanddate($ts, true), "target={$target}×tamp={$ts}"); if ($remaining > 0 || $earliestLiveTime && $ts > $earliestLiveTime) { $diffLink = '(' . $sk->makeKnownLinkObj($titleObj, wfMsgHtml('diff'), "target={$target}×tamp={$ts}&diff=prev") . ')'; } else { // No older revision to diff against $diffLink = ''; } } else { $checkBox = ''; $pageLink = $wgLang->timeanddate($ts, true); $diffLink = ''; } $userLink = $sk->userLink($row->ar_user, $row->ar_user_text) . $sk->userToolLinks($row->ar_user, $row->ar_user_text); $stxt = ''; if (!is_null($size = $row->ar_len)) { if ($size == 0) { $stxt = wfMsgHtml('historyempty'); } else { $stxt = wfMsgHtml('historysize', $wgLang->formatNum($size)); } } $comment = $sk->commentBlock($row->ar_comment); $wgOut->addHTML("<li>{$checkBox} {$pageLink} {$diffLink} . . {$userLink} {$stxt} {$comment}</li>\n"); } $revisions->free(); $wgOut->addHTML("</ul>"); } else { $wgOut->addWikiMsg("nohistory"); } if ($haveFiles) { $wgOut->addHtml("<h2>" . wfMsgHtml('filehist') . "</h2>\n"); $wgOut->addHtml("<ul>"); while ($row = $files->fetchObject()) { $ts = wfTimestamp(TS_MW, $row->fa_timestamp); if ($this->mAllowed && $row->fa_storage_key) { $checkBox = Xml::check("fileid" . $row->fa_id); $key = urlencode($row->fa_storage_key); $target = urlencode($this->mTarget); $pageLink = $sk->makeKnownLinkObj($titleObj, $wgLang->timeanddate($ts, true), "target={$target}&file={$key}"); } else { $checkBox = ''; $pageLink = $wgLang->timeanddate($ts, true); } $userLink = $sk->userLink($row->fa_user, $row->fa_user_text) . $sk->userToolLinks($row->fa_user, $row->fa_user_text); $data = wfMsgHtml('widthheight', $wgLang->formatNum($row->fa_width), $wgLang->formatNum($row->fa_height)) . ' (' . wfMsgHtml('nbytes', $wgLang->formatNum($row->fa_size)) . ')'; $comment = $sk->commentBlock($row->fa_description); $wgOut->addHTML("<li>{$checkBox} {$pageLink} . . {$userLink} {$data} {$comment}</li>\n"); } $files->free(); $wgOut->addHTML("</ul>"); } if ($this->mAllowed) { # Slip in the hidden controls here $misc = Xml::hidden('target', $this->mTarget); $misc .= Xml::hidden('wpEditToken', $wgUser->editToken()); $misc .= Xml::closeElement('form'); $wgOut->addHtml($misc); } return true; }
function showHistory() { global $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); if ($this->mAllowed) { $wgOut->setPagetitle(wfMsg("undeletepage")); } else { $wgOut->setPagetitle(wfMsg('viewdeletedpage')); } $archive = new PageArchive($this->mTargetObj); $text = $archive->getLastRevisionText(); /* if( is_null( $text ) ) { $wgOut->addWikiText( wfMsg( "nohistory" ) ); return; } */ if ($this->mAllowed) { $wgOut->addWikiText(wfMsg("undeletehistory")); } else { $wgOut->addWikiText(wfMsg("undeletehistorynoadmin")); } # List all stored revisions $revisions = $archive->listRevisions(); $files = $archive->listFiles(); $haveRevisions = $revisions && $revisions->numRows() > 0; $haveFiles = $files && $files->numRows() > 0; # Batch existence check on user and talk pages if ($haveRevisions) { $batch = new LinkBatch(); while ($row = $revisions->fetchObject()) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text)); } $batch->execute(); $revisions->seek(0); } if ($haveFiles) { $batch = new LinkBatch(); while ($row = $files->fetchObject()) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text)); } $batch->execute(); $files->seek(0); } if ($this->mAllowed) { $titleObj = Title::makeTitle(NS_SPECIAL, "Undelete"); $action = $titleObj->getLocalURL("action=submit"); # Start the form here $top = wfOpenElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete')); $wgOut->addHtml($top); } # Show relevant lines from the deletion log: $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n"); $logViewer = new LogViewer(new LogReader(new FauxRequest(array('page' => $this->mTargetObj->getPrefixedText(), 'type' => 'delete')))); $logViewer->showList($wgOut); if ($this->mAllowed && ($haveRevisions || $haveFiles)) { # Format the user-visible controls (comment field, submission button) # in a nice little table $table = '<fieldset><table><tr>'; $table .= '<td colspan="2">' . wfMsgWikiHtml('undeleteextrahelp') . '</td></tr><tr>'; $table .= '<td align="right"><strong>' . wfMsgHtml('undeletecomment') . '</strong></td>'; $table .= '<td>' . wfInput('wpComment', 50, $this->mComment) . '</td>'; $table .= '</tr><tr><td> </td><td>'; $table .= wfSubmitButton(wfMsg('undeletebtn'), array('name' => 'restore')); $table .= wfElement('input', array('type' => 'reset', 'value' => wfMsg('undeletereset'))); $table .= '</td></tr></table></fieldset>'; $wgOut->addHtml($table); } $wgOut->addHTML("<h2>" . htmlspecialchars(wfMsg("history")) . "</h2>\n"); if ($haveRevisions) { # The page's stored (deleted) history: $wgOut->addHTML("<ul>"); $target = urlencode($this->mTarget); while ($row = $revisions->fetchObject()) { $ts = wfTimestamp(TS_MW, $row->ar_timestamp); if ($this->mAllowed) { $checkBox = wfCheck("ts{$ts}"); $pageLink = $sk->makeKnownLinkObj($titleObj, $wgLang->timeanddate($ts, true), "target={$target}×tamp={$ts}"); } else { $checkBox = ''; $pageLink = $wgLang->timeanddate($ts, true); } $userLink = $sk->userLink($row->ar_user, $row->ar_user_text) . $sk->userToolLinks($row->ar_user, $row->ar_user_text); $comment = $sk->commentBlock($row->ar_comment); $wgOut->addHTML("<li>{$checkBox} {$pageLink} . . {$userLink} {$comment}</li>\n"); } $revisions->free(); $wgOut->addHTML("</ul>"); } else { $wgOut->addWikiText(wfMsg("nohistory")); } if ($haveFiles) { $wgOut->addHtml("<h2>" . wfMsgHtml('imghistory') . "</h2>\n"); $wgOut->addHtml("<ul>"); while ($row = $files->fetchObject()) { $ts = wfTimestamp(TS_MW, $row->fa_timestamp); if ($this->mAllowed && $row->fa_storage_key) { $checkBox = wfCheck("fileid" . $row->fa_id); $key = urlencode($row->fa_storage_key); $target = urlencode($this->mTarget); $pageLink = $sk->makeKnownLinkObj($titleObj, $wgLang->timeanddate($ts, true), "target={$target}&file={$key}"); } else { $checkBox = ''; $pageLink = $wgLang->timeanddate($ts, true); } $userLink = $sk->userLink($row->fa_user, $row->fa_user_text) . $sk->userToolLinks($row->fa_user, $row->fa_user_text); $data = wfMsgHtml('widthheight', $wgLang->formatNum($row->fa_width), $wgLang->formatNum($row->fa_height)) . ' (' . wfMsgHtml('nbytes', $wgLang->formatNum($row->fa_size)) . ')'; $comment = $sk->commentBlock($row->fa_description); $wgOut->addHTML("<li>{$checkBox} {$pageLink} . . {$userLink} {$data} {$comment}</li>\n"); } $files->free(); $wgOut->addHTML("</ul>"); } if ($this->mAllowed) { # Slip in the hidden controls here $misc = wfHidden('target', $this->mTarget); $misc .= wfHidden('wpEditToken', $wgUser->editToken()); $wgOut->addHtml($misc . '</form>'); } return true; }
private function showHistory() { global $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); if ($this->mAllowed) { $wgOut->setPagetitle(wfMsg("undeletepage")); } else { $wgOut->setPagetitle(wfMsg('viewdeletedpage')); } $wgOut->wrapWikiMsg("<div class='mw-undelete-pagetitle'>\n\$1</div>\n", array('undeletepagetitle', $this->mTargetObj->getPrefixedText())); $archive = new PageArchive($this->mTargetObj); /* $text = $archive->getLastRevisionText(); if( is_null( $text ) ) { $wgOut->addWikiMsg( "nohistory" ); return; } */ $wgOut->addHTML('<div class="mw-undelete-history">'); if ($this->mAllowed) { $wgOut->addWikiMsg("undeletehistory"); $wgOut->addWikiMsg("undeleterevdel"); } else { $wgOut->addWikiMsg("undeletehistorynoadmin"); } $wgOut->addHTML('</div>'); # List all stored revisions $revisions = $archive->listRevisions(); $files = $archive->listFiles(); $haveRevisions = $revisions && $revisions->numRows() > 0; $haveFiles = $files && $files->numRows() > 0; # Batch existence check on user and talk pages if ($haveRevisions) { $batch = new LinkBatch(); while ($row = $revisions->fetchObject()) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text)); } $batch->execute(); $revisions->seek(0); } if ($haveFiles) { $batch = new LinkBatch(); while ($row = $files->fetchObject()) { $batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text)); $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text)); } $batch->execute(); $files->seek(0); } if ($this->mAllowed) { $titleObj = SpecialPage::getTitleFor("Undelete"); $action = $titleObj->getLocalURL(array('action' => 'submit')); # Start the form here $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete')); $wgOut->addHTML($top); } # Show relevant lines from the deletion log: $wgOut->addHTML(Xml::element('h2', null, LogPage::logName('delete')) . "\n"); LogEventsList::showLogExtract($wgOut, 'delete', $this->mTargetObj->getPrefixedText()); # Show relevant lines from the suppression log: if ($wgUser->isAllowed('suppressionlog')) { $wgOut->addHTML(Xml::element('h2', null, LogPage::logName('suppress')) . "\n"); LogEventsList::showLogExtract($wgOut, 'suppress', $this->mTargetObj->getPrefixedText()); } if ($this->mAllowed && ($haveRevisions || $haveFiles)) { # Format the user-visible controls (comment field, submission button) # in a nice little table if ($wgUser->isAllowed('suppressrevision')) { $unsuppressBox = "<tr>\n\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('revdelete-unsuppress'), 'wpUnsuppress', 'mw-undelete-unsuppress', $this->mUnsuppress) . "</td>\n\t\t\t\t\t</tr>"; } else { $unsuppressBox = ""; } $table = Xml::fieldset(wfMsg('undelete-fieldset-title')) . Xml::openElement('table', array('id' => 'mw-undelete-table')) . "<tr>\n\t\t\t\t\t\t<td colspan='2' class='mw-undelete-extrahelp'>" . wfMsgWikiHtml('undeleteextrahelp') . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('undeletecomment'), 'wpComment') . "</td>\n\t\t\t\t\t\t<td class='mw-input'>" . Xml::input('wpComment', 50, $this->mComment, array('id' => 'wpComment')) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('undeletebtn'), array('name' => 'restore', 'id' => 'mw-undelete-submit')) . ' ' . Xml::element('input', array('type' => 'reset', 'value' => wfMsg('undeletereset'), 'id' => 'mw-undelete-reset')) . ' ' . Xml::submitButton(wfMsg('undeleteinvert'), array('name' => 'invert', 'id' => 'mw-undelete-invert')) . "</td>\n\t\t\t\t\t</tr>" . $unsuppressBox . Xml::closeElement('table') . Xml::closeElement('fieldset'); $wgOut->addHTML($table); } $wgOut->addHTML(Xml::element('h2', null, wfMsg('history')) . "\n"); if ($haveRevisions) { # The page's stored (deleted) history: $wgOut->addHTML("<ul>"); $target = urlencode($this->mTarget); $remaining = $revisions->numRows(); $earliestLiveTime = $this->mTargetObj->getEarliestRevTime(); while ($row = $revisions->fetchObject()) { $remaining--; $wgOut->addHTML($this->formatRevisionRow($row, $earliestLiveTime, $remaining, $sk)); } $revisions->free(); $wgOut->addHTML("</ul>"); } else { $wgOut->addWikiMsg("nohistory"); } if ($haveFiles) { $wgOut->addHTML(Xml::element('h2', null, wfMsg('filehist')) . "\n"); $wgOut->addHTML("<ul>"); while ($row = $files->fetchObject()) { $wgOut->addHTML($this->formatFileRow($row, $sk)); } $files->free(); $wgOut->addHTML("</ul>"); } if ($this->mAllowed) { # Slip in the hidden controls here $misc = Xml::hidden('target', $this->mTarget); $misc .= Xml::hidden('wpEditToken', $wgUser->editToken()); $misc .= Xml::closeElement('form'); $wgOut->addHTML($misc); } return true; }