Update to r32375 / bug 11874 -- !important may have whitespace between ! and important
[lhc/web/wiklou.git] / includes / FileDeleteForm.php
index 8537ca0..16a2d11 100644 (file)
@@ -48,6 +48,9 @@ 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('deleterevision');
+               
                if( $this->oldimage && !$this->isValidOldSpec() ) {
                        $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars( $this->oldimage ) );
                        return;
@@ -72,8 +75,10 @@ class FileDeleteForm {
                        } elseif ( $reason == 'other' ) {
                                $reason = $this->DeleteReason;
                        }
+                               
+                       $article = null;
                        if( $this->oldimage ) {
-                               $status = $this->file->deleteOld( $this->oldimage, $reason );
+                               $status = $this->file->deleteOld( $this->oldimage, $reason, $suppress );
                                if( $status->ok ) {
                                        // Need to do a log item
                                        $log = new LogPage( 'delete' );
@@ -83,13 +88,16 @@ class FileDeleteForm {
                                        $log->addEntry( 'delete', $this->title, $logComment );
                                }
                        } else {
-                               $status = $this->file->delete( $reason );
+                               $status = $this->file->delete( $reason, $suppress );
                                if( $status->ok ) {
                                        // Need to delete the associated article
                                        $article = new Article( $this->title );
-                                       $article->doDeleteArticle( $reason );
+                                       $article->doDeleteArticle( $reason, $suppress );
                                }
                        }
+                       if( $status->isGood() ) wfRunHooks('FileDeleteComplete', array( 
+                               &$this->file, &$this->oldimage, &$article, &$wgUser, &$reason));
+                       
                        if( !$status->isGood() )
                                $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
                        if( $status->ok ) {
@@ -113,6 +121,14 @@ class FileDeleteForm {
                global $wgOut, $wgUser, $wgRequest, $wgContLang;
                $align = $wgContLang->isRtl() ? 'left' : 'right';
 
+               if( $wgUser->isAllowed( 'deleterevision' ) ) {
+                       $suppress = "<tr id=\"wpDeleteSuppressRow\" name=\"wpDeleteSuppressRow\"><td></td><td>";
+                       $suppress .= Xml::checkLabel( wfMsg( 'revdelete-suppress' ), 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '2' ) );
+                       $suppress .= "</td></tr>";
+               } else {
+                       $suppress = '';
+               }
+
                $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) ) .
                        Xml::openElement( 'fieldset' ) .
                        Xml::element( 'legend', null, wfMsg( 'filedelete-legend' ) ) .
@@ -137,6 +153,7 @@ class FileDeleteForm {
                                        Xml::input( 'wpReason', 60, $wgRequest->getText( 'wpReason' ), array( 'type' => 'text', 'maxlength' => '255', 'tabindex' => '2', 'id' => 'wpReason' ) ) .
                                "</td>
                        </tr>
+                       {$suppress}
                        <tr>
                                <td></td>
                                <td>" .
@@ -147,6 +164,12 @@ class FileDeleteForm {
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' );
 
+                       if ( $wgUser->isAllowed( 'editinterface' ) ) {
+                               $skin = $wgUser->getSkin();
+                               $link = $skin->makeLink ( 'MediaWiki:Filedelete-reason-dropdown', wfMsgHtml( 'filedelete-edit-reasonlist' ) );
+                               $form .= '<p class="mw-filedelete-editreasons">' . $link . '</p>';
+                       }
+
                $wgOut->addHtml( $form );
        }
 
@@ -178,21 +201,16 @@ class FileDeleteForm {
         * @return string
         */
        private function prepareMessage( $message ) {
-               global $wgLang, $wgServer;
+               global $wgLang;
                if( $this->oldimage ) {
                        $url = $this->file->getArchiveUrl( $this->oldimage );
-                       if( substr( $url, 0, 1 ) == '/' ) {
-                               // Fully-qualify the URL if necessary
-                               $url = $wgServer . $url;
-                       }
                        return wfMsgExt(
                                "{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
                                'parse',
                                $this->title->getText(),
                                $wgLang->date( $this->getTimestamp(), true ),
                                $wgLang->time( $this->getTimestamp(), true ),
-                               $url
-                       );
+                               wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) );
                } else {
                        return wfMsgExt(
                                $message,