global $wgOut, $wgRequest, $wgUser;
$this->setHeaders();
- if( wfReadOnly() ) {
- $wgOut->readOnlyPage();
- return;
- }
$permission_errors = $this->title->getUserPermissionsErrors('delete', $wgUser);
- if (count($permission_errors)>0) {
+ if ( count( $permission_errors ) > 0 ) {
$wgOut->showPermissionsErrorPage( $permission_errors );
return;
}
+ if ( wfReadOnly() ) {
+ throw new ReadOnlyError;
+ }
+
$this->oldimage = $wgRequest->getText( 'oldimage', false );
$token = $wgRequest->getText( 'wpEditToken' );
# Flag to hide all contents of the archived revisions
$suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed('suppressrevision');
- if( $this->oldimage && !self::isValidOldSpec($this->oldimage) ) {
- $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->oldimage ) );
- return;
- }
- if( $this->oldimage )
+ if( $this->oldimage ) {
$this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
+ }
if( !self::haveDeletableFile($this->file, $this->oldfile, $this->oldimage) ) {
$wgOut->addHTML( $this->prepareMessage( 'filedelete-nofile' ) );
$status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress );
- if( !$status->isGood() )
+ if( !$status->isGood() ) {
+ $wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
+ $wgOut->addHTML( '<span class="error">' );
$wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
+ $wgOut->addHTML( '</span>' );
+ }
if( $status->ok ) {
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
$wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) );
} else {
$id = $title->getArticleID( Title::GAID_FOR_UPDATE );
$article = new Article( $title );
- $error = '';
$dbw = wfGetDB( DB_MASTER );
try {
- if( wfRunHooks( 'ArticleDelete', array( &$article, &$wgUser, &$reason, &$error ) ) ) {
- // delete the associated article first
- if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) {
- global $wgRequest;
- if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
- $article->doWatch();
- } elseif( $title->userIsWatching() ) {
- $article->doUnwatch();
- }
- $status = $file->delete( $reason, $suppress );
- if( $status->ok ) {
- $dbw->commit();
- wfRunHooks( 'ArticleDeleteComplete', array( &$article, &$wgUser, $reason, $id ) );
- } else {
- $dbw->rollback();
- }
+ // delete the associated article first
+ if( $article->doDeleteArticle( $reason, $suppress, $id, false ) ) {
+ global $wgRequest;
+ if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
+ WatchAction::doWatch( $title, $wgUser );
+ } elseif ( $title->userIsWatching() ) {
+ WatchAction::doUnwatch( $title, $wgUser );
+ }
+ $status = $file->delete( $reason, $suppress );
+ if( $status->ok ) {
+ $dbw->commit();
+ } else {
+ $dbw->rollback();
}
}
} catch ( MWException $e ) {
throw $e;
}
}
- if( $status->isGood() )
+ if( $status->isGood() )
wfRunHooks('FileDeleteComplete', array( &$file, &$oldimage, &$article, &$wgUser, &$reason));
return $status;
"</td>
</tr>
{$suppress}";
- if( $wgUser->isLoggedIn() ) {
+ if( $wgUser->isLoggedIn() ) {
$form .= "
<tr>
<td></td>
Xml::closeElement( 'form' );
if ( $wgUser->isAllowed( 'editinterface' ) ) {
- $skin = $wgUser->getSkin();
$title = Title::makeTitle( NS_MEDIAWIKI, 'Filedelete-reason-dropdown' );
- $link = $skin->link(
+ $link = Linker::link(
$title,
wfMsgHtml( 'filedelete-edit-reasonlist' ),
array(),
private function showLogEntries() {
global $wgOut;
$wgOut->addHTML( '<h2>' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
- LogEventsList::showLogExtract( $wgOut, 'delete', $this->title->getPrefixedText() );
+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->title );
}
/**
return wfMsgExt(
"{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
'parse',
- $this->title->getText(),
+ wfEscapeWikiText( $this->title->getText() ),
$wgLang->date( $this->getTimestamp(), true ),
$wgLang->time( $this->getTimestamp(), true ),
- wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) );
+ wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) );
} else {
return wfMsgExt(
$message,
'parse',
- $this->title->getText()
+ wfEscapeWikiText( $this->title->getText() )
);
}
}
* Set headers, titles and other bits
*/
private function setHeaders() {
- global $wgOut, $wgUser;
+ global $wgOut;
$wgOut->setPageTitle( wfMsg( 'filedelete', $this->title->getText() ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setSubtitle( wfMsg(
'filedelete-backlink',
- $wgUser->getSkin()->link(
- $this->title,
- null,
- array(),
- array(),
- array( 'known', 'noclasses' )
- )
+ Linker::linkKnown( $this->title )
) );
}