X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=e2c95c2e0bd65d683bdc96f5f4fe492eb685cd67;hb=bd756e66843bd1f346ebfed21d11996fde92ba62;hp=ddbad63a5d27b164fc388cb9b9c2865582b1a878;hpb=88403ed2c564bcd168d8b3b0d0dd9dbd815e94e5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index ddbad63a5d..e2c95c2e0b 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -37,7 +37,7 @@ class FileDeleteForm { return; } $permission_errors = $this->title->getUserPermissionsErrors('delete', $wgUser); - if (count($permission_errors)>0) { + if ( count( $permission_errors ) > 0 ) { $wgOut->showPermissionsErrorPage( $permission_errors ); return; } @@ -74,8 +74,12 @@ class FileDeleteForm { $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress ); - if( !$status->isGood() ) + if( !$status->isGood() ) { + $wgOut->addHTML( '

' . $this->prepareMessage( 'filedeleteerror-short' ) . "

\n" ); + $wgOut->addHTML( '' ); $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) ); + $wgOut->addHTML( '' ); + } if( $status->ok ) { $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); $wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) ); @@ -110,32 +114,29 @@ class FileDeleteForm { // Need to do a log item $log = new LogPage( 'delete' ); $logComment = wfMsgForContent( 'deletedrevision', $oldimage ); - if( trim( $reason ) != '' ) + if( trim( $reason ) != '' ) { $logComment .= wfMsgForContent( 'colon-separator' ) . $reason; - $log->addEntry( 'delete', $title, $logComment ); + } + $log->addEntry( 'delete', $title, $logComment ); } } else { - $id = $title->getArticleID( GAID_FOR_UPDATE ); + $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 ) { @@ -144,7 +145,7 @@ class FileDeleteForm { throw $e; } } - if( $status->isGood() ) + if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( &$file, &$oldimage, &$article, &$wgUser, &$reason)); return $status; @@ -173,7 +174,7 @@ class FileDeleteForm { 'id' => 'mw-img-deleteconfirm' ) ) . Xml::openElement( 'fieldset' ) . Xml::element( 'legend', null, wfMsg( 'filedelete-legend' ) ) . - Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ) . + Html::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ) . $this->prepareMessage( 'filedelete-intro' ) . Xml::openElement( 'table', array( 'id' => 'mw-img-deleteconfirm-table' ) ) . " @@ -196,7 +197,7 @@ class FileDeleteForm { " {$suppress}"; - if( $wgUser->isLoggedIn() ) { + if( $wgUser->isLoggedIn() ) { $form .= " @@ -256,15 +257,15 @@ class FileDeleteForm { 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() ) ); } }