/** * Special page allowing users with the appropriate permissions to view * and hide revisions. Log items can also be hidden. * * @file * @ingroup SpecialPage */ function wfSpecialRevisiondelete($par = null) { global $wgOut, $wgRequest, $wgUser; # Handle our many different possible input types $target = $wgRequest->getText('target'); $oldid = $wgRequest->getArray('oldid'); $artimestamp = $wgRequest->getArray('artimestamp'); $logid = $wgRequest->getArray('logid'); $img = $wgRequest->getArray('oldimage'); $fileid = $wgRequest->getArray('fileid'); # For reviewing deleted files... $file = $wgRequest->getVal('file'); # If this is a revision, then we need a target page $page = Title::newFromUrl($target); if (is_null($page)) { $wgOut->addWikiMsg('undelete-header'); return; } # Only one target set at a time please! $i = (bool) $file + (bool) $oldid + (bool) $logid + (bool) $artimestamp + (bool) $fileid + (bool) $img; if ($i !== 1) { $wgOut->showErrorPage('revdelete-nooldid-title', 'revdelete-nooldid-text'); return; } # Logs must have a type given if ($logid && !strpos($page->getDBKey(), '/')) { $wgOut->showErrorPage('revdelete-nooldid-title', 'revdelete-nooldid-text'); return; } # Either submit or create our form $form = new RevisionDeleteForm($page, $oldid, $logid, $artimestamp, $fileid, $img, $file); if ($wgRequest->wasPosted()) { $form->submit($wgRequest); } else { if ($oldid || $artimestamp) { $form->showRevs(); } else { if ($fileid || $img) { $form->showImages(); } else { if ($logid) { $form->showLogItems(); } } } } # Show relevant lines from the deletion log. This will show even if said ID # does not exist...might be helpful $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'delete', $page->getPrefixedText()); if ($wgUser->isAllowed('suppressionlog')) { $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('suppress')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'suppress', $page->getPrefixedText()); } }
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; }
/** * Enhanced RC ungrouped line. * * @param $rcObj RecentChange * @return String: a HTML formatted line (generated using $r) */ protected function recentChangesBlockLine($rcObj) { global $wgRCShowChangedSize; wfProfileIn(__METHOD__); $query['curid'] = $rcObj->mAttribs['rc_cur_id']; $type = $rcObj->mAttribs['rc_type']; $logType = $rcObj->mAttribs['rc_log_type']; if ($logType) { # Log entry $classes = Sanitizer::escapeClass('mw-changeslist-log-' . $logType); } else { $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title']); } $r = Html::openElement('table', array('class' => $classes)) . Html::openElement('tr'); $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow(); # Flag and Timestamp if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) { $r .= '    '; // 4 flags -> 4 spaces } else { $r .= $this->recentChangesFlags(array('newpage' => $type == RC_NEW, 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'])); } $r .= ' ' . $rcObj->timestamp . ' </td><td>'; # Article or log link if ($logType) { $logtitle = SpecialPage::getTitleFor('Log', $logType); $logname = LogPage::logName($logType); $r .= '(' . Linker::linkKnown($logtitle, htmlspecialchars($logname)) . ')'; } else { $this->insertArticleLink($r, $rcObj, $rcObj->unpatrolled, $rcObj->watched); } # Diff and hist links if ($type != RC_LOG) { $r .= ' (' . $rcObj->difflink . $this->message['pipe-separator']; $query['action'] = 'history'; $r .= Linker::linkKnown($rcObj->getTitle(), $this->message['hist'], array(), $query) . ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference())) { $r .= "{$cd} . . "; } if ($type == RC_LOG) { $r .= $this->insertLogEntry($rcObj); } else { $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; $r .= $this->insertComment($rcObj); $r .= $this->insertRollback($r, $rcObj); } # Tags $classes = explode(' ', $classes); $this->insertTags($r, $rcObj, $classes); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); $r .= "</td></tr></table>\n"; wfProfileOut(__METHOD__); return $r; }
/** * Show a rights log fragment for the specified user * * @param $user User to show log for * @param $output OutputPage to use */ protected function showLogFragment($user, $output) { $output->addHTML(Xml::element('h2', null, LogPage::logName('rights') . "\n")); LogEventsList::showLogExtract($output, 'rights', $user->getUserPage()->getPrefixedText()); }
/** * Enhanced RC ungrouped line. * @return string a HTML formated line (generated using $r) */ protected function recentChangesBlockLine($rcObj) { global $wgContLang, $wgRCShowChangedSize; wfProfileIn(__METHOD__); # Extract fields from DB into the function scope (rc_xxxx variables) // FIXME: Would be good to replace this extract() call with something // that explicitly initializes variables. $classes = array(); // TODO implement extract($rcObj->mAttribs); $curIdEq = "curid={$rc_cur_id}"; $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>'; $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' '; # Flag and Timestamp if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $r .= ' '; // 4 flags -> 4 spaces } else { $r .= $this->recentChangesFlags($rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot); } $r .= ' ' . $rcObj->timestamp . ' </tt></td><td>'; # Article or log link if ($rc_log_type) { $logtitle = Title::newFromText("Log/{$rc_log_type}", NS_SPECIAL); $logname = LogPage::logName($rc_log_type); $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname) . ')'; } else { $this->insertArticleLink($r, $rcObj, $rcObj->unpatrolled, $rcObj->watched); } # Diff and hist links if ($rc_type != RC_LOG) { $r .= ' (' . $rcObj->difflink . $this->message['semicolon-separator']; $r .= $this->skin->makeKnownLinkObj($rcObj->getTitle(), $this->message['hist'], $curIdEq . '&action=history') . ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference())) { $r .= "{$cd} . . "; } # User/talk $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; # Log action (if any) if ($rc_log_type) { if ($this->isDeleted($rcObj, LogPage::DELETED_ACTION)) { $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $r .= ' ' . LogPage::actionText($rc_log_type, $rc_log_action, $rcObj->getTitle(), $this->skin, LogPage::extractParams($rc_params), true, true); } } $this->insertComment($r, $rcObj); $this->insertRollback($r, $rcObj); # Tags $this->insertTags($r, $rcObj, $classes); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); $r .= "</td></tr></table>\n"; wfProfileOut(__METHOD__); return $r; }
/** * Format a line for enhanced recentchange (aka with javascript and block of lines). */ function recentChangesLine(&$baseRC, $watched = false) { global $wgLang, $wgContLang; # Create a specialised object $rc = RCCacheEntry::newFromParent($baseRC); # Extract fields from DB into the function scope (rc_xxxx variables) // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables. extract($rc->mAttribs); $curIdEq = 'curid=' . $rc_cur_id; # If it's a new day, add the headline and flush the cache $date = $wgLang->date($rc_timestamp, true); $ret = ''; if ($date != $this->lastdate) { # Process current cache $ret = $this->recentChangesBlock(); $this->rc_cache = array(); $ret .= "<h4>{$date}</h4>\n"; $this->lastdate = $date; } // BizzWiki begin {{ $ns = $rc->getTitle()->getNamespace(); # Should patrol-related stuff be shown? if ($this->usePatrol($ns)) { $rc->unpatrolled = !$rc_patrolled; } else { $rc->unpatrolled = false; } // BizzWiki end }} # Make article link if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir"; $clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), '')); } elseif ($rc_namespace == NS_SPECIAL) { list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($rc_title); if ($specialName == 'Log') { # Log updates, etc $logname = LogPage::logName($logtype); $clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')'; } else { wfDebug("Unexpected special page in recentchanges\n"); $clink = ''; } } elseif ($rc->unpatrolled && $rc_type == RC_NEW) { # Unpatrolled new page, give rc_id in query $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}"); } else { $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), ''); } $time = $wgContLang->time($rc_timestamp, true, true); $rc->watched = $watched; $rc->link = $clink; $rc->timestamp = $time; $rc->numberofWatchingusers = $baseRC->numberofWatchingusers; # Make "cur" and "diff" links if ($rc->unpatrolled) { $rcIdQuery = "&rcid={$rc_id}"; } else { $rcIdQuery = ''; } $querycur = $curIdEq . "&diff=0&oldid={$rc_this_oldid}"; $querydiff = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcIdQuery}"; $aprops = ' tabindex="' . $baseRC->counter . '"'; $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['cur'], $querycur, '', '', $aprops); if ($rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { if ($rc_type != RC_NEW) { $curLink = $this->message['cur']; } $diffLink = $this->message['diff']; } else { $diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['diff'], $querydiff, '', '', $aprops); } # Make "last" link if ($rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $lastLink = $this->message['last']; } else { $lastLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['last'], $curIdEq . '&diff=' . $rc_this_oldid . '&oldid=' . $rc_last_oldid . $rcIdQuery); } $rc->userlink = $this->skin->userLink($rc_user, $rc_user_text); $rc->lastlink = $lastLink; $rc->curlink = $curLink; $rc->difflink = $diffLink; $rc->usertalklink = $this->skin->userToolLinks($rc_user, $rc_user_text); # Put accumulated information into the cache, for later display # Page moves go on their own line $title = $rc->getTitle(); $secureName = $title->getPrefixedDBkey(); if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { # Use an @ character to prevent collision with page names $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc); } else { if (!isset($this->rc_cache[$secureName])) { $this->rc_cache[$secureName] = array(); } array_push($this->rc_cache[$secureName], $rc); } return $ret; }
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; }
public function execute($par) { global $wgOut, $wgUser, $wgRequest; if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if (!$wgUser->isAllowed('deleterevision')) { $wgOut->permissionRequired('deleterevision'); return; } $this->skin =& $wgUser->getSkin(); # Set title and such $this->setHeaders(); $this->outputHeader(); $this->wasPosted = $wgRequest->wasPosted(); # Handle our many different possible input types $this->target = $wgRequest->getText('target'); $this->oldids = $wgRequest->getArray('oldid'); $this->artimestamps = $wgRequest->getArray('artimestamp'); $this->logids = $wgRequest->getArray('logid'); $this->oldimgs = $wgRequest->getArray('oldimage'); $this->fileids = $wgRequest->getArray('fileid'); # For reviewing deleted files... $this->file = $wgRequest->getVal('file'); # Only one target set at a time please! $i = (bool) $this->file + (bool) $this->oldids + (bool) $this->logids + (bool) $this->artimestamps + (bool) $this->fileids + (bool) $this->oldimgs; # No targets? if ($i == 0) { $wgOut->showErrorPage('notargettitle', 'notargettext'); return; } # Too many targets? if ($i !== 1) { $wgOut->showErrorPage('revdelete-toomanytargets-title', 'revdelete-toomanytargets-text'); return; } $this->page = Title::newFromUrl($this->target); # If we have revisions, get the title from the first one # since they should all be from the same page. This allows # for more flexibility with page moves... if (count($this->oldids) > 0) { $rev = Revision::newFromId($this->oldids[0]); $this->page = $rev ? $rev->getTitle() : $this->page; } # We need a target page! if (is_null($this->page)) { $wgOut->addWikiMsg('undelete-header'); return; } # Logs must have a type given if ($this->logids && !strpos($this->page->getDBKey(), '/')) { $wgOut->showErrorPage('revdelete-nologtype-title', 'revdelete-nologtype-text'); return; } # For reviewing deleted files...show it now if allowed if ($this->file) { $oimage = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName($this->page, $this->file); $oimage->load(); // Check if user is allowed to see this file if (!$oimage->userCan(File::DELETED_FILE)) { $wgOut->permissionRequired('suppressrevision'); } else { $this->showFile($this->file); } return; } # Give a link to the logs/hist for this page if (!is_null($this->page) && $this->page->getNamespace() > -1) { $links = array(); $logtitle = SpecialPage::getTitleFor('Log'); $links[] = $this->skin->makeKnownLinkObj($logtitle, wfMsgHtml('viewpagelogs'), wfArrayToCGI(array('page' => $this->page->getPrefixedUrl()))); # Give a link to the page history $links[] = $this->skin->makeKnownLinkObj($this->page, wfMsgHtml('pagehist'), wfArrayToCGI(array('action' => 'history'))); # Link to deleted edits if ($wgUser->isAllowed('undelete')) { $undelete = SpecialPage::getTitleFor('Undelete'); $links[] = $this->skin->makeKnownLinkObj($undelete, wfMsgHtml('deletedhist'), wfArrayToCGI(array('target' => $this->page->getPrefixedDBkey()))); } # Logs themselves don't have histories or archived revisions $wgOut->setSubtitle('<p>' . implode($links, ' / ') . '</p>'); } # Lock the operation and the form context $this->secureOperation(); # Either submit or create our form if ($this->wasPosted) { $this->submit($wgRequest); } else { if ($this->deleteKey == 'oldid' || $this->deleteKey == 'artimestamp') { $this->showRevs(); } else { if ($this->deleteKey == 'fileid' || $this->deleteKey == 'oldimage') { $this->showImages(); } else { if ($this->deleteKey == 'logid') { $this->showLogItems(); } } } } # Show relevant lines from the deletion log. This will show even if said ID # does not exist...might be helpful $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'delete', $this->page->getPrefixedText()); if ($wgUser->isAllowed('suppressionlog')) { $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('suppress')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'suppress', $this->page->getPrefixedText()); } }
function recentChangesLineNew(&$baseRC, $watched = false) { global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans; static $message; if (!isset($message)) { foreach (explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink undo diff-to-lvr ' . 'diff-to-lvr_tooltiptext cur_tooltiptext diff_tooltiptext last_tooltiptext updatedmarker updatedmarker_tooltiptext ') as $msg) { $message[$msg] = wfMsg($msg); } } # Create a specialised object $rc = RCCacheEntry::newFromParent($baseRC); # Extract fields from DB into the function scope (rc_xxxx variables) extract($rc->mAttribs); $curIdEq = 'curid=' . $rc_cur_id; # If it's a new day, add the headline and flush the cache $date = $wgLang->date($rc_timestamp, true); $ret = ''; if ($date != $this->lastdate) { # Process current cache $ret = $this->recentChangesBlock(); $this->rc_cache = array(); $ret .= "<h4>{$date}</h4>\n"; $this->lastdate = $date; } # Should patrol-related stuff be shown? if ($wgUseRCPatrol && $wgUser->isLoggedIn() && (!$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol'))) { $rc->unpatrolled = !$rc_patrolled; } else { $rc->unpatrolled = false; } # Make article link if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir"; $clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), '')); } elseif ($rc_namespace == NS_SPECIAL && preg_match('!^Log/(.*)$!', $rc_title, $matches)) { # Log updates, etc $logtype = $matches[1]; $logname = LogPage::logName($logtype); $clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')'; } elseif ($rc->unpatrolled && $rc_type == RC_NEW) { # Unpatrolled new page, give rc_id in query $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}"); } else { $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), ''); } $time = $wgContLang->time($rc_timestamp, true, true); $rc->watched = $watched; $rc->link = $clink; $rc->timestamp = $time; $rc->numberofWatchingusers = $baseRC->numberofWatchingusers; $rc->lastvisitedrevision = $baseRC->lastvisitedrevision; $rc->notificationtimestamp = $baseRC->notificationtimestamp; # Make "cur" and "diff" links $titleObj = $rc->getTitle(); if ($rc->unpatrolled) { $rcIdQuery = "&rcid={$rc_id}"; } else { $rcIdQuery = ''; } $query = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}"; $aprops = ' tabindex="' . $baseRC->counter . '"'; $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['cur'], $query, '', '', $aprops); if ($rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { if ($rc_type != RC_NEW) { $curLink = $message['cur']; } $diffLink = $message['diff']; } else { # $query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid; $query = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}"; $aprops = ' tabindex="' . $baseRC->counter . '"'; $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['cur'], $query, '', '', $aprops, $message['cur_tooltiptext']); $diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['diff'], $query . $rcIdQuery, '', '', $aprops, $message['diff_tooltiptext']); } # Make "last" link if ($rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $lastLink = $message['last']; } else { $lastLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['last'], $curIdEq . '&diff=' . $rc_this_oldid . '&oldid=' . $rc_last_oldid . $rcIdQuery, '', '', '', $message['last_tooltiptext']); } # Make user link (or user contributions for unregistered users) if ($rc_user == 0) { $contribsPage =& Title::makeTitle(NS_SPECIAL, 'Contributions'); $userLink = $this->skin->makeKnownLinkObj($contribsPage, $rc_user_text, 'target=' . $rc_user_text); } else { $userPage =& Title::makeTitle(NS_USER, $rc_user_text); $userLink = $this->skin->makeLinkObj($userPage, $rc_user_text); } if ($watched && $baseRC->lastvisitedrevision) { $lvrLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['diff-to-lvr'], "{$curIdEq}&diff=0&oldid={$baseRC->lastvisitedrevision}", '', '', '', $message['diff-to-lvr_tooltiptext']); } else { $lvrLink = ''; } $rc->lvrlink = $lvrLink; $rc->userlink = $userLink; $rc->lastlink = $lastLink; $rc->curlink = $curLink; $rc->difflink = $diffLink; # Make user talk link $talkname = $wgContLang->getNsText(NS_TALK); # use the shorter name $userTalkPage =& Title::makeTitle(NS_USER_TALK, $rc_user_text); $userTalkLink = $this->skin->makeLinkObj($userTalkPage, $talkname); global $wgDisableAnonTalk; if (($wgSysopUserBans || 0 == $rc_user) && $wgUser->isAllowed('block')) { $blockPage =& Title::makeTitle(NS_SPECIAL, 'Blockip'); $blockLink = $this->skin->makeKnownLinkObj($blockPage, $message['blocklink'], 'ip=' . $rc_user_text); if ($wgDisableAnonTalk) { $rc->usertalklink = ' (' . $blockLink . ')'; } else { $rc->usertalklink = ' (' . $userTalkLink . ' | ' . $blockLink . ')'; } } else { if ($wgDisableAnonTalk && $rc_user == 0) { $rc->usertalklink = ''; } else { $rc->usertalklink = ' (' . $userTalkLink . ')'; } } # Put accumulated information into the cache, for later display # Page moves go on their own line $title = $rc->getTitle(); $secureName = $title->getPrefixedDBkey(); if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { # Use an @ character to prevent collision with page names $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc); } else { if (!isset($this->rc_cache[$secureName])) { $this->rc_cache[$secureName] = array(); } array_push($this->rc_cache[$secureName], $rc); } return $ret; }
/** * @return string Formatted HTML * @private */ function getTypeMenu() { $out = "<select name='type'>\n"; $validTypes = LogPage::validTypes(); $m = array(); // Temporary array // First pass to load the log names foreach ($validTypes as $type) { $text = LogPage::logName($type); $m[$text] = $type; } // Second pass to sort by name ksort($m); // Third pass generates sorted XHTML content foreach ($m as $text => $type) { $selected = $type == $this->reader->queryType(); $out .= Xml::option($text, $type, $selected) . "\n"; } $out .= '</select>'; return $out; }
function showLogFragment($title) { $out = $this->getOutput(); $out->addHTML(Xml::element('h2', null, LogPage::logName('move'))); LogEventsList::showLogExtract($out, 'move', $title); }
/** * Show deletion log fragments pertaining to the current file */ private function showLogEntries() { global $wgOut; $wgOut->addHTML('<h2>' . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'delete', $this->title->getPrefixedText()); }
private function showHistory() { global $wgUser, $wgOut; $this->sk = $this->getSkin(); $wgOut->setPageTitle(wfMsg('mergehistory')); $this->showMergeForm(); # List all stored revisions $revisions = new MergeHistoryPager($this, array(), $this->mTargetObj, $this->mDestObj); $haveRevisions = $revisions && $revisions->getNumRows() > 0; $titleObj = $this->getTitle(); $action = $titleObj->getLocalURL(array('action' => 'submit')); # Start the form here $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'merge')); $wgOut->addHTML($top); if ($haveRevisions) { # Format the user-visible controls (comment field, submission button) # in a nice little table $table = Xml::openElement('fieldset') . wfMsgExt('mergehistory-merge', array('parseinline'), $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText()) . Xml::openElement('table', array('id' => 'mw-mergehistory-table')) . '<tr> <td class="mw-label">' . Xml::label(wfMsg('mergehistory-reason'), 'wpComment') . '</td> <td class="mw-input">' . Xml::input('wpComment', 50, $this->mComment, array('id' => 'wpComment')) . '</td> </tr> <tr> <td> </td> <td class="mw-submit">' . Xml::submitButton(wfMsg('mergehistory-submit'), array('name' => 'merge', 'id' => 'mw-merge-submit')) . '</td> </tr>' . Xml::closeElement('table') . Xml::closeElement('fieldset'); $wgOut->addHTML($table); } $wgOut->addHTML('<h2 id="mw-mergehistory">' . wfMsgHtml('mergehistory-list') . "</h2>\n"); if ($haveRevisions) { $wgOut->addHTML($revisions->getNavigationBar()); $wgOut->addHTML('<ul>'); $wgOut->addHTML($revisions->getBody()); $wgOut->addHTML('</ul>'); $wgOut->addHTML($revisions->getNavigationBar()); } else { $wgOut->addWikiMsg('mergehistory-empty'); } # Show relevant lines from the deletion log: $wgOut->addHTML('<h2>' . htmlspecialchars(LogPage::logName('merge')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'merge', $this->mTargetObj->getPrefixedText()); # When we submit, go by page ID to avoid some nasty but unlikely collisions. # Such would happen if a page was renamed after the form loaded, but before submit $misc = Html::hidden('targetID', $this->mTargetObj->getArticleID()); $misc .= Html::hidden('destID', $this->mDestObj->getArticleID()); $misc .= Html::hidden('target', $this->mTarget); $misc .= Html::hidden('dest', $this->mDest); $misc .= Html::hidden('wpEditToken', $wgUser->editToken()); $misc .= Xml::closeElement('form'); $wgOut->addHTML($misc); return true; }
/** * @param OutputPage $out * @access private */ function showLogExtract(&$out) { # Show relevant lines from the protection log: $out->addHTML(Xml::element('h2', null, LogPage::logName('protect'))); LogEventsList::showLogExtract($out, 'protect', $this->mTitle->getPrefixedText()); }
/** * Perform a deletion and output success or failure messages * @param $reason * @param $suppress bool */ public function doDelete($reason, $suppress = false) { global $wgOut; $error = ''; if ($this->mPage->doDeleteArticle($reason, $suppress, 0, true, $error)) { $deleted = $this->getTitle()->getPrefixedText(); $wgOut->setPageTitle(wfMessage('actioncomplete')); $wgOut->setRobotPolicy('noindex,nofollow'); $loglink = '[[Special:Log/delete|' . wfMsgNoTrans('deletionlog') . ']]'; $wgOut->addWikiMsg('deletedtext', wfEscapeWikiText($deleted), $loglink); $wgOut->returnToMain(false); } else { $wgOut->setPageTitle(wfMessage('cannotdelete-title', $this->getTitle()->getPrefixedText())); if ($error == '') { $wgOut->wrapWikiMsg("<div class=\"error mw-error-cannotdelete\">\n\$1\n</div>", array('cannotdelete', wfEscapeWikiText($this->getTitle()->getPrefixedText()))); $wgOut->addHTML(Xml::element('h2', null, LogPage::logName('delete'))); LogEventsList::showLogExtract($wgOut, 'delete', $this->getTitle()->getPrefixedText()); } else { $wgOut->addHTML($error); } } }
function showLogFragment($title, &$out) { $out->addHTML(Xml::element('h2', null, LogPage::logName('move'))); LogEventsList::showLogExtract($out, 'move', $title->getPrefixedText()); }
protected static function getTitleLink($type, $skin, $title, &$params) { global $wgLang, $wgContLang; if (!$skin) { return $title->getPrefixedText(); } switch ($type) { case 'move': $titleLink = $skin->makeLinkObj($title, htmlspecialchars($title->getPrefixedText()), 'redirect=no'); $targetTitle = Title::newFromText($params[0]); if (!$targetTitle) { # Workaround for broken database $params[0] = htmlspecialchars($params[0]); } else { $params[0] = $skin->makeLinkObj($targetTitle, htmlspecialchars($params[0])); } break; case 'block': if (substr($title->getText(), 0, 1) == '#') { $titleLink = $title->getText(); } else { // TODO: Store the user identifier in the parameters // to make this faster for future log entries $id = User::idFromName($title->getText()); $titleLink = $skin->userLink($id, $title->getText()) . $skin->userToolLinks($id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK); } break; case 'rights': $text = $wgContLang->ucfirst($title->getText()); $titleLink = $skin->makeLinkObj(Title::makeTitle(NS_USER, $text)); break; case 'merge': $titleLink = $skin->makeLinkObj($title, $title->getPrefixedText(), 'redirect=no'); $params[0] = $skin->makeLinkObj(Title::newFromText($params[0]), htmlspecialchars($params[0])); $params[1] = $wgLang->timeanddate($params[1]); break; default: if ($title->getNamespace() == NS_SPECIAL) { list($name, $par) = SpecialPage::resolveAliasWithSubpage($title->getDBKey()); # Use the language name for log titles, rather than Log/X if ($name == 'Log') { $titleLink = '(' . $skin->makeLinkObj($title, LogPage::logName($par)) . ')'; } else { $titleLink = $skin->makeLinkObj($title); } } else { $titleLink = $skin->makeLinkObj($title); } } return $titleLink; }
/** * @todo (In Wikilog 1.3.x) Replace GAID_FOR_UPDATE with * Title::GAID_FOR_UPDATE. */ protected function setCommentApproval( $comment, $approval ) { global $wgOut, $wgUser; # Check if comment is really awaiting moderation. if ( $comment->mStatus != WikilogComment::S_PENDING ) { $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); return; } $log = new LogPage( 'wikilog' ); $title = $comment->getCommentArticleTitle(); if ( $approval == 'approve' ) { $comment->mStatus = WikilogComment::S_OK; $comment->saveComment(); $log->addEntry( 'c-approv', $title, '' ); $wgOut->redirect( $this->mTalkTitle->getFullUrl() ); } elseif ( $approval == 'reject' ) { $reason = wfMsgExt( 'wikilog-log-cmt-rejdel', array( 'content', 'parsemag' ), $comment->mUserText ); $id = $title->getArticleID( Title::GAID_FOR_UPDATE ); if ( $this->doDeleteArticle( $reason, false, $id ) ) { $comment->deleteComment(); $log->addEntry( 'c-reject', $title, '' ); $wgOut->redirect( $this->mTalkTitle->getFullUrl() ); } else { $wgOut->showFatalError( wfMsgExt( 'cannotdelete', array( 'parse' ) ) ); $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) ); LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() ); } } else { $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); } }
/** * Perform a deletion and output success or failure messages */ public function doDelete($reason, $suppress = false) { global $wgOut, $wgUser; $id = $this->mTitle->getArticleID(Title::GAID_FOR_UPDATE); $error = ''; if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error))) { if ($this->doDeleteArticle($reason, $suppress, $id)) { $deleted = $this->mTitle->getPrefixedText(); $wgOut->setPagetitle(wfMsg('actioncomplete')); $wgOut->setRobotPolicy('noindex,nofollow'); $loglink = '[[Special:Log/delete|' . wfMsgNoTrans('deletionlog') . ']]'; $wgOut->addWikiMsg('deletedtext', $deleted, $loglink); $wgOut->returnToMain(false); wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id)); } } else { if ($error == '') { $wgOut->showFatalError(Html::rawElement('div', array('class' => 'error mw-error-cannotdelete'), wfMsgExt('cannotdelete', array('parse'), $this->mTitle->getPrefixedText()))); $wgOut->addHTML(Xml::element('h2', null, LogPage::logName('delete'))); LogEventsList::showLogExtract($wgOut, 'delete', $this->mTitle->getPrefixedText()); } else { $wgOut->showFatalError($error); } } }
private function showHistory() { $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', $this->mTargetObj->getPrefixedText())); $archive = new PageArchive($this->mTargetObj); wfRunHooks('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->getTitle()->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: $out->addHTML(Xml::element('h2', null, LogPage::logName('delete')) . "\n"); LogEventsList::showLogExtract($out, 'delete', $this->mTargetObj); # Show relevant lines from the suppression log: if ($this->getUser()->isAllowed('suppressionlog')) { $out->addHTML(Xml::element('h2', null, LogPage::logName('suppress')) . "\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\t<td colspan='2' class='mw-undelete-extrahelp'>" . $this->msg('undeleteextrahelp')->parseAsBlock() . "</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($this->msg('undeletecomment')->text(), '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($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\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; }
private function showHistory() { global $wgLang, $wgContLang, $wgUser, $wgOut; $this->sk = $wgUser->getSkin(); $wgOut->setPagetitle(wfMsg("mergehistory")); $this->showMergeForm(); # List all stored revisions $revisions = new MergeHistoryPager($this, array(), $this->mTargetObj, $this->mDestObj); $haveRevisions = $revisions && $revisions->getNumRows() > 0; $titleObj = SpecialPage::getTitleFor("Mergehistory"); $action = $titleObj->getLocalURL("action=submit"); # Start the form here $top = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'merge')); $wgOut->addHTML($top); if ($haveRevisions) { # 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'>" . wfMsgExt('mergehistory-merge', array('parseinline'), $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText()) . "</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('mergehistory-submit'), array('name' => 'merge', 'id' => 'mw-merge-submit')) . "</td>\n\t\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('fieldset'); $wgOut->addHTML($table); } $wgOut->addHTML("<h2 id=\"mw-mergehistory\">" . wfMsgHtml("mergehistory-list") . "</h2>\n"); if ($haveRevisions) { $wgOut->addHTML($revisions->getNavigationBar()); $wgOut->addHTML("<ul>"); $wgOut->addHTML($revisions->getBody()); $wgOut->addHTML("</ul>"); $wgOut->addHTML($revisions->getNavigationBar()); } else { $wgOut->addWikiMsg("mergehistory-empty"); } # Show relevant lines from the deletion log: $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('merge')) . "</h2>\n"); LogEventsList::showLogExtract($wgOut, 'merge', $this->mTargetObj->getPrefixedText()); # When we submit, go by page ID to avoid some nasty but unlikely collisions. # Such would happen if a page was renamed after the form loaded, but before submit $misc = Xml::hidden('targetID', $this->mTargetObj->getArticleID()); $misc .= Xml::hidden('destID', $this->mDestObj->getArticleID()); $misc .= Xml::hidden('target', $this->mTarget); $misc .= Xml::hidden('dest', $this->mDest); $misc .= Xml::hidden('wpEditToken', $wgUser->editToken()); $misc .= Xml::closeElement('form'); $wgOut->addHTML($misc); return true; }
/** * Show protection long extracts for this page * * @param $out OutputPage * @access private */ function showLogExtract(&$out) { # Show relevant lines from the protection log: $out->addHTML(Xml::element('h2', null, LogPage::logName('protect'))); LogEventsList::showLogExtract($out, 'protect', $this->mTitle->getPrefixedText()); # Let extensions add other relevant log extracts wfRunHooks('ProtectionForm::showLogExtract', array($this->mArticle, $out)); }
/** * @param OutputPage $out * @access private */ function showLogExtract(&$out) { # Show relevant lines from the deletion log: $out->addHTML("<h2>" . htmlspecialchars(LogPage::logName('protect')) . "</h2>\n"); require_once 'SpecialLog.php'; $logViewer = new LogViewer(new LogReader(new FauxRequest(array('page' => $this->mTitle->getPrefixedText(), 'type' => 'protect')))); $logViewer->showList($out); }
/** * @param $queryTypes Array * @return String: Formatted HTML */ private function getTypeMenu($queryTypes) { global $wgLogRestrictions, $wgUser; $html = "<select name='type'>\n"; $validTypes = LogPage::validTypes(); $typesByName = array(); // Temporary array // First pass to load the log names foreach ($validTypes as $type) { $text = LogPage::logName($type); $typesByName[$type] = $text; } // Second pass to sort by name asort($typesByName); // Note the query type $queryType = count($queryTypes) == 1 ? $queryTypes[0] : ''; // Always put "All public logs" on top if (isset($typesByName[''])) { $all = $typesByName['']; unset($typesByName['']); $typesByName = array('' => $all) + $typesByName; } // Third pass generates sorted XHTML content foreach ($typesByName as $type => $text) { $selected = $type == $queryType; // Restricted types if (isset($wgLogRestrictions[$type])) { if ($wgUser->isAllowed($wgLogRestrictions[$type])) { $html .= Xml::option($text, $type, $selected) . "\n"; } } else { $html .= Xml::option($text, $type, $selected) . "\n"; } } $html .= '</select>'; return $html; }
/** * TODO document * @param $type String * @param $lang Language or null * @param $title Title * @param $params Array * @return String */ protected static function getTitleLink($type, $lang, $title, &$params) { global $wgContLang, $wgUserrightsInterwikiDelimiter; if (!$lang) { return $title->getPrefixedText(); } switch ($type) { case 'move': $titleLink = Linker::link($title, htmlspecialchars($title->getPrefixedText()), array(), array('redirect' => 'no')); $targetTitle = Title::newFromText($params[0]); if (!$targetTitle) { # Workaround for broken database $params[0] = htmlspecialchars($params[0]); } else { $params[0] = Linker::link($targetTitle, htmlspecialchars($params[0])); } break; case 'block': if (substr($title->getText(), 0, 1) == '#') { $titleLink = $title->getText(); } else { // TODO: Store the user identifier in the parameters // to make this faster for future log entries $id = User::idFromName($title->getText()); $titleLink = Linker::userLink($id, $title->getText()) . Linker::userToolLinks($id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK); } break; case 'rights': $text = $wgContLang->ucfirst($title->getText()); $parts = explode($wgUserrightsInterwikiDelimiter, $text, 2); if (count($parts) == 2) { $titleLink = WikiMap::foreignUserLink($parts[1], $parts[0], htmlspecialchars($title->getPrefixedText())); if ($titleLink !== false) { break; } } $titleLink = Linker::link(Title::makeTitle(NS_USER, $text)); break; case 'merge': $titleLink = Linker::link($title, $title->getPrefixedText(), array(), array('redirect' => 'no')); $params[0] = Linker::link(Title::newFromText($params[0]), htmlspecialchars($params[0])); $params[1] = $lang->timeanddate($params[1]); break; default: if ($title->getNamespace() == NS_SPECIAL) { list($name, $par) = SpecialPageFactory::resolveAlias($title->getDBkey()); # Use the language name for log titles, rather than Log/X if ($name == 'Log') { $titleLink = '(' . Linker::link($title, LogPage::logName($par)) . ')'; } else { $titleLink = Linker::link($title); } } else { $titleLink = Linker::link($title); } } return $titleLink; }
/** * @param $row * @create diff/hist/page link */ protected function getLinksFromRow($row) { // Log items (old format) and events to logs if ($row->cuc_type == RC_LOG && $row->cuc_namespace == NS_SPECIAL) { list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($row->cuc_title); $logname = LogPage::logName($logtype); $title = Title::makeTitle($row->cuc_namespace, $row->cuc_title); $links = '(' . $this->sk->makeKnownLinkObj($title, $logname) . ')'; // Log items (newer format) } elseif ($row->cuc_type == RC_LOG) { $title = Title::makeTitle($row->cuc_namespace, $row->cuc_title); $links = '(' . $this->sk->makeKnownLinkObj(SpecialPage::getTitleFor('Log'), $this->message['log'], wfArrayToCGI(array('page' => $title->getPrefixedText()))) . ')'; } else { $title = Title::makeTitle($row->cuc_namespace, $row->cuc_title); # New pages if ($row->cuc_type == RC_NEW) { $links = '(' . $this->message['diff'] . ') '; } else { # Diff link $links = ' (' . $this->sk->makeKnownLinkObj($title, $this->message['diff'], wfArrayToCGI(array('curid' => $row->cuc_page_id, 'diff' => $row->cuc_this_oldid, 'oldid' => $row->cuc_last_oldid))) . ') '; } # History link $links .= ' (' . $this->sk->makeKnownLinkObj($title, $this->message['hist'], wfArrayToCGI(array('curid' => $row->cuc_page_id, 'action' => 'history'))) . ') . . '; # Some basic flags if ($row->cuc_type == RC_NEW) { $links .= '<span class="newpage">' . $this->message['newpageletter'] . '</span>'; } if ($row->cuc_minor) { $links .= '<span class="minor">' . $this->message['minoreditletter'] . '</span>'; } # Page link $links .= ' ' . $this->sk->makeLinkObj($title); } return $links; }
function showLogFragment(&$out, &$title) { $out->addHtml(wfElement('h2', NULL, LogPage::logName('block'))); $request = new FauxRequest(array('page' => $title->getPrefixedText(), 'type' => 'block')); $viewer = new LogViewer(new LogReader($request)); $viewer->showList($out); }
/** * @param $user User * @param $output OutputPage */ protected function showLogFragment($user, $output) { $pageTitle = Title::makeTitleSafe(NS_USER, $user->getName()); $output->addHTML(Xml::element('h2', null, LogPage::logName('gblrights') . "\n")); LogEventsList::showLogExtract($output, 'gblrights', $pageTitle->getPrefixedText()); }
function showLogExtract($username, $type, &$out) { global $wgOut; # Show relevant lines from the logs: $wgOut->addHtml(Xml::element('h2', null, LogPage::logName($type)) . "\n"); $logViewer = new LogViewer(new LogReader(new FauxRequest(array('page' => $username->getPrefixedText(), 'type' => $type)))); $logViewer->showList($out); }
/** * @param $username Title * @param $type * @param $out OutputPage */ function showLogExtract($username, $type, &$out) { # Show relevant lines from the logs: $out->addHTML(Xml::element('h2', null, LogPage::logName($type)) . "\n"); LogEventsList::showLogExtract($out, $type, $username->getPrefixedText()); }