Get rid of Title::indexTitle and Title::getIndexTitle()
[lhc/web/wiklou.git] / includes / FileDeleteForm.php
index 9ce2f76..444d26f 100644 (file)
@@ -48,7 +48,7 @@ class FileDeleteForm {
        /**
         * Constructor
         *
-        * @param $file File object we're deleting
+        * @param File $file File object we're deleting
         */
        public function __construct( $file ) {
                $this->title = $file->getTitle();
@@ -82,18 +82,18 @@ class FileDeleteForm {
                # Flag to hide all contents of the archived revisions
                $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( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
                                $wgOut->addWikiText( '<div class="error">' . $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) . '</div>' );
                        }
-                       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;
                }
@@ -138,12 +132,12 @@ class FileDeleteForm {
        /**
         * Really delete the file
         *
-        * @param $title Title object
-        * @param File $file: file object
-        * @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
+        * @param Title $title
+        * @param File $file
+        * @param string $oldimage Archive name
+        * @param string $reason Reason of the deletion
+        * @param bool $suppress Whether to mark all deleted versions as restricted
+        * @param User $user User object performing the request
         * @throws MWException
         * @return bool|Status
         */
@@ -153,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;
                                }
@@ -187,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__ );
@@ -213,7 +207,7 @@ class FileDeleteForm {
        private function showForm() {
                global $wgOut, $wgUser, $wgRequest;
 
-               if( $wgUser->isAllowed( 'suppressrevision' ) ) {
+               if ( $wgUser->isAllowed( 'suppressrevision' ) ) {
                        $suppress = "<tr id=\"wpDeleteSuppressRow\">
                                        <td></td>
                                        <td class='mw-input'><strong>" .
@@ -258,7 +252,7 @@ class FileDeleteForm {
                                "</td>
                        </tr>
                        {$suppress}";
-               if( $wgUser->isLoggedIn() ) {
+               if ( $wgUser->isLoggedIn() ) {
                        $form .= "
                        <tr>
                                <td></td>
@@ -314,7 +308,7 @@ class FileDeleteForm {
         */
        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() ),
@@ -375,7 +369,7 @@ class FileDeleteForm {
                $q = array();
                $q['action'] = 'delete';
 
-               if( $this->oldimage ) {
+               if ( $this->oldimage ) {
                        $q['oldimage'] = $this->oldimage;
                }