Localisation updates for core messages from Betawiki (2008-01-02 18:22 CET)
[lhc/web/wiklou.git] / includes / FileDeleteForm.php
index bd96e3d..24586d4 100644 (file)
@@ -39,7 +39,7 @@ class FileDeleteForm {
                        $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
                        return;
                } elseif( !$wgUser->isAllowed( 'delete' ) ) {
-                       $wgOut->permissionError( 'delete' );
+                       $wgOut->permissionRequired( 'delete' );
                        return;
                } elseif( $wgUser->isBlocked() ) {
                        $wgOut->blockedPage();
@@ -63,13 +63,16 @@ class FileDeleteForm {
                
                // Perform the deletion if appropriate
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
-                       $comment = $wgRequest->getText( 'wpComment' );
+                       $comment = $wgRequest->getText( 'wpReason' );
                        if( $this->oldimage ) {
                                $status = $this->file->deleteOld( $this->oldimage, $comment );
                                if( $status->ok ) {
                                        // Need to do a log item
                                        $log = new LogPage( 'delete' );
-                                       $log->addEntry( 'delete', $this->title, wfMsg( 'deletedrevision' , $this->oldimage ) );
+                                       $logComment = wfMsg( 'deletedrevision', $this->oldimage );
+                                       if( trim( $comment ) != '' )
+                                               $logComment .= ": {$comment}";
+                                       $log->addEntry( 'delete', $this->title, $logComment );
                                }
                        } else {
                                $status = $this->file->delete( $comment );
@@ -82,6 +85,7 @@ class FileDeleteForm {
                        if( !$status->isGood() )
                                $wgOut->addWikiText( $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) );
                        if( $status->ok ) {
+                               $wgOut->setPagetitle( wfMsg( '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
@@ -90,28 +94,48 @@ class FileDeleteForm {
                        return;
                }
                
-               // Show the form
-               $this->showForm();              
+               $this->showForm();
+               $this->showLogEntries();
        }
-       
+
        /**
         * Show the confirmation form
         */
        private function showForm() {
-               global $wgOut, $wgUser;
-               
+               global $wgOut, $wgUser, $wgRequest;
+
                $form  = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) );
                $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) );
                $form .= '<fieldset><legend>' . wfMsgHtml( 'filedelete-legend' ) . '</legend>';
                $form .= $this->prepareMessage( 'filedelete-intro' );
-               
-               $form .= '<p>' . Xml::inputLabel( wfMsg( 'filedelete-comment' ), 'wpComment', 'wpComment', 60 ) . '</p>';
-               $form .= '<p>' . Xml::submitButton( wfMsg( 'filedelete-submit' ) ) . '</p>';
+
+               $form .= '<p>' . Xml::inputLabel( wfMsg( 'filedelete-comment' ), 'wpReason', 'wpReason',
+                       60, $wgRequest->getText( 'wpReason' ) ) . '</p>';
+               $form .= '<p>' . Xml::submitButton( wfMsg( 'filedelete-submit' ), array( 'name' => 'mw-filedelete-submit', 'id' => 'mw-filedelete-submit' ) ) . '</p>';
                $form .= '</fieldset>';
                $form .= '</form>';
-               
+
                $wgOut->addHtml( $form );
        }
+
+       /**
+        * Show deletion log fragments pertaining to the current file
+        */
+       private function showLogEntries() {
+               global $wgOut;
+               $wgOut->addHtml( '<h2>' . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
+               $reader = new LogViewer(
+                       new LogReader(
+                               new FauxRequest(
+                                       array(
+                                               'type' => 'delete',
+                                               'page' => $this->title->getPrefixedText(),
+                                       )
+                               )
+                       )
+               );
+               $reader->showList( $wgOut );            
+       }
        
        /**
         * Prepare a message referring to the file being deleted,