X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FFileDeleteForm.php;h=65d82b8782c1235fca19569f90a6fbbd3b5a2b69;hb=9a3b6e5639d0fae23c721ed803a3feb0a0462c14;hp=7e616b24933b0682c14684aee16072a5f5e43627;hpb=f6cbdfb5e2c3ffc05858612e219a24e22bdbc72e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 7e616b2493..65d82b8782 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -80,20 +80,20 @@ class FileDeleteForm { $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'); + $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); - 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) ) { + if ( !self::haveDeletableFile( $this->file, $this->oldfile, $this->oldimage ) ) { $wgOut->addHTML( $this->prepareMessage( 'filedelete-nofile' ) ); $wgOut->addReturnTo( $this->title ); return; } // Perform the deletion if appropriate - if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) { + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) { $deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' ); $deleteReason = $wgRequest->getText( 'wpReason' ); @@ -109,24 +109,18 @@ class FileDeleteForm { $status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress, $wgUser ); - if( !$status->isGood() ) { + if ( !$status->isGood() ) { $wgOut->addHTML( '

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

\n" ); $wgOut->addWikiText( '
' . $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) . '
' ); } - if( $status->ok ) { + if ( $status->ok ) { $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) ); $wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) ); // Return to the main page if we just deleted all versions of the // file, otherwise go back to the description page $wgOut->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() ); - if ( $wgUser->isLoggedIn() && $wgRequest->getCheck( 'wpWatch' ) != $wgUser->isWatched( $this->title ) ) { - if ( $wgRequest->getCheck( 'wpWatch' ) ) { - WatchAction::doWatch( $this->title, $wgUser ); - } else { - WatchAction::doUnwatch( $this->title, $wgUser ); - } - } + WatchAction::doWatchOrUnwatch( $wgRequest->getCheck( 'wpWatch' ), $this->title, $wgUser ); } return; } @@ -140,10 +134,11 @@ class FileDeleteForm { * * @param $title Title object * @param File $file: file object - * @param $oldimage String: archive name - * @param $reason String: reason of the deletion + * @param string $oldimage archive name + * @param string $reason reason of the deletion * @param $suppress Boolean: whether to mark all deleted versions as restricted * @param $user User object performing the request + * @throws MWException * @return bool|Status */ public static function doDelete( &$title, &$file, &$oldimage, $reason, $suppress, User $user = null ) { @@ -152,13 +147,13 @@ class FileDeleteForm { $user = $wgUser; } - if( $oldimage ) { + if ( $oldimage ) { $page = null; $status = $file->deleteOld( $oldimage, $reason, $suppress ); - if( $status->ok ) { + if ( $status->ok ) { // Need to do a log item $logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text(); - if( trim( $reason ) != '' ) { + if ( trim( $reason ) != '' ) { $logComment .= wfMessage( 'colon-separator' ) ->inContentLanguage()->text() . $reason; } @@ -186,7 +181,7 @@ class FileDeleteForm { // or revision is missing, so check for isOK() rather than isGood() if ( $deleteStatus->isOK() ) { $status = $file->delete( $reason, $suppress ); - if( $status->isOK() ) { + if ( $status->isOK() ) { $dbw->commit( __METHOD__ ); } else { $dbw->rollback( __METHOD__ ); @@ -212,7 +207,7 @@ class FileDeleteForm { private function showForm() { global $wgOut, $wgUser, $wgRequest; - if( $wgUser->isAllowed( 'suppressrevision' ) ) { + if ( $wgUser->isAllowed( 'suppressrevision' ) ) { $suppress = " " . @@ -257,7 +252,7 @@ class FileDeleteForm { " {$suppress}"; - if( $wgUser->isLoggedIn() ) { + if ( $wgUser->isLoggedIn() ) { $form .= " @@ -308,12 +303,12 @@ class FileDeleteForm { * showing an appropriate message depending upon whether * it's a current file or an old version * - * @param $message String: message base + * @param string $message message base * @return String */ private function prepareMessage( $message ) { global $wgLang; - if( $this->oldimage ) { + if ( $this->oldimage ) { return wfMessage( "{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old' wfEscapeWikiText( $this->title->getText() ), @@ -343,7 +338,7 @@ class FileDeleteForm { * * @return bool */ - public static function isValidOldSpec($oldimage) { + public static function isValidOldSpec( $oldimage ) { return strlen( $oldimage ) >= 16 && strpos( $oldimage, '/' ) === false && strpos( $oldimage, '\\' ) === false; @@ -359,7 +354,7 @@ class FileDeleteForm { * @param $oldimage File * @return bool */ - public static function haveDeletableFile(&$file, &$oldfile, $oldimage) { + public static function haveDeletableFile( &$file, &$oldfile, $oldimage ) { return $oldimage ? $oldfile && $oldfile->exists() && $oldfile->isLocal() : $file && $file->exists() && $file->isLocal(); @@ -374,11 +369,11 @@ class FileDeleteForm { $q = array(); $q['action'] = 'delete'; - if( $this->oldimage ) { + if ( $this->oldimage ) { $q['oldimage'] = $this->oldimage; } - return $this->title->getLocalUrl( $q ); + return $this->title->getLocalURL( $q ); } /**