* UI entry point for page deletion
*/
public function delete() {
- global $wgOut, $wgRequest;
+ global $wgOut, $wgRequest, $wgLang;
# This code desperately needs to be totally rewritten
+ $title = $this->getTitle();
+ $user = $this->getContext()->getUser();
+
# Check permissions
- $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $this->getContext()->getUser() );
+ $permission_errors = $title->getUserPermissionsErrors( 'delete', $user );
if ( count( $permission_errors ) ) {
throw new PermissionsError( 'delete', $permission_errors );
}
throw new ReadOnlyError;
}
- $confirm = $wgRequest->wasPosted() &&
- $this->getContext()->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
-
- $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
- $this->DeleteReason = $wgRequest->getText( 'wpReason' );
-
- $reason = $this->DeleteReasonList;
-
- if ( $reason != 'other' && $this->DeleteReason != '' ) {
- // Entry from drop down menu + additional comment
- $reason .= wfMsgForContent( 'colon-separator' ) . $this->DeleteReason;
- } elseif ( $reason == 'other' ) {
- $reason = $this->DeleteReason;
- }
-
- # Flag to hide all contents of the archived revisions
- $suppress = $wgRequest->getVal( 'wpSuppress' ) && $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
-
- $wgOut->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
-
# Better double-check that it hasn't been deleted yet!
$dbw = wfGetDB( DB_MASTER );
- $conds = $this->getTitle()->pageCond();
+ $conds = $title->pageCond();
$latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
if ( $latest === false ) {
- $wgOut->showFatalError(
- Html::rawElement(
- 'div',
- array( 'class' => 'error mw-error-cannotdelete' ),
- wfMsgExt( 'cannotdelete', array( 'parse' ),
- wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
- )
- );
+ $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
+ $wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
+ array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
+ );
$wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
LogEventsList::showLogExtract(
$wgOut,
'delete',
- $this->getTitle()->getPrefixedText()
+ $title->getPrefixedText()
);
return;
# Hack for big sites
$bigHistory = $this->mPage->isBigDeletion();
- if ( $bigHistory && !$this->getTitle()->userCan( 'bigdelete' ) ) {
- global $wgLang, $wgDeleteRevisionsLimit;
+ if ( $bigHistory && !$title->userCan( 'bigdelete' ) ) {
+ global $wgDeleteRevisionsLimit;
+ $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
$wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
return;
}
- if ( $confirm ) {
+ $deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
+ $deleteReason = $wgRequest->getText( 'wpReason' );
+
+ if ( $deleteReasonList == 'other' ) {
+ $reason = $deleteReason;
+ } elseif ( $deleteReason != '' ) {
+ // Entry from drop down menu + additional comment
+ $reason = $deleteReasonList . wfMsgForContent( 'colon-separator' ) . $deleteReason;
+ } else {
+ $reason = $deleteReasonList;
+ }
+
+ if ( $wgRequest->wasPosted() && $user->matchEditToken( $wgRequest->getVal( 'wpEditToken' ),
+ array( 'delete', $this->getTitle()->getPrefixedText() ) ) )
+ {
+ # Flag to hide all contents of the archived revisions
+ $suppress = $wgRequest->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
+
$this->doDelete( $reason, $suppress );
- if ( $wgRequest->getCheck( 'wpWatch' ) && $this->getContext()->getUser()->isLoggedIn() ) {
+ if ( $wgRequest->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
$this->doWatch();
- } elseif ( $this->getTitle()->userIsWatching() ) {
+ } elseif ( $title->userIsWatching() ) {
$this->doUnwatch();
}
}
// If the page has a history, insert a warning
- if ( $hasHistory && !$confirm ) {
- global $wgLang;
-
+ if ( $hasHistory ) {
$revisions = $this->mPage->estimateRevisionCount();
// @todo FIXME: i18n issue/patchwork message
$wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
- wfMsgHtml( 'word-separator' ) . Linker::link( $this->getTitle(),
+ wfMsgHtml( 'word-separator' ) . Linker::link( $title,
wfMsgHtml( 'history' ),
array( 'rel' => 'archives' ),
array( 'action' => 'history' ) ) .
wfDebug( "Article::confirmDelete\n" );
+ $wgOut->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
$deleteBackLink = Linker::linkKnown( $this->getTitle() );
$wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
- if ( $this->getContext()->getUser()->isAllowed( 'suppressrevision' ) ) {
+ $user = $this->getContext()->getUser();
+
+ if ( $user->isAllowed( 'suppressrevision' ) ) {
$suppress = "<tr id=\"wpDeleteSuppressRow\">
<td></td>
<td class='mw-input'><strong>" .
} else {
$suppress = '';
}
- $checkWatch = $this->getContext()->getUser()->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
+ $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
$form = Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
</tr>";
# Disallow watching if user is not logged in
- if ( $this->getContext()->getUser()->isLoggedIn() ) {
+ if ( $user->isLoggedIn() ) {
$form .= "
<tr>
<td></td>
</tr>" .
Xml::closeElement( 'table' ) .
Xml::closeElement( 'fieldset' ) .
- Html::hidden( 'wpEditToken', $this->getContext()->getUser()->editToken() ) .
+ Html::hidden( 'wpEditToken', $user->editToken( array( 'delete', $this->getTitle()->getPrefixedText() ) ) ) .
Xml::closeElement( 'form' );
- if ( $this->getContext()->getUser()->isAllowed( 'editinterface' ) ) {
+ if ( $user->isAllowed( 'editinterface' ) ) {
$title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
$link = Linker::link(
$title,
$id = $this->getTitle()->getArticleID( Title::GAID_FOR_UPDATE );
$error = '';
- if ( $this->mPage->doDeleteArticle( $reason, $suppress, $id, $error ) ) {
+ if ( $this->mPage->doDeleteArticle( $reason, $suppress, $id, true, $error ) ) {
$deleted = $this->getTitle()->getPrefixedText();
$wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
$wgOut->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
$wgOut->returnToMain( false );
} else {
+ $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
if ( $error == '' ) {
- $wgOut->showFatalError(
- Html::rawElement(
- 'div',
- array( 'class' => 'error mw-error-cannotdelete' ),
- wfMsgExt( 'cannotdelete', array( 'parse' ),
- wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
- )
+ $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(
$this->getTitle()->getPrefixedText()
);
} else {
- $wgOut->showFatalError( $error );
+ $wgOut->addHTML( $error );
}
}
}