Tweak for r29770 (yes, some months after it):
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 20 Aug 2008 21:27:12 +0000 (21:27 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 20 Aug 2008 21:27:12 +0000 (21:27 +0000)
If the wiki is read only mode, don't show a "database locked" error if previewing or showing diff, but rather the "normal" action with a warning that the database is currently locked. If the user is trying to save the page, he'll see the preview page instead. Currently, if you are saving or previewing a page while the database is locked, you'll see the "database locked" error with the current text (or no text at all if the page doesn't exist), not your text, this might be confusing.

Also added the reason of the lock to the readonlywarning message.

includes/EditPage.php
languages/messages/MessagesEn.php

index 614019e..c3baebb 100644 (file)
@@ -122,7 +122,7 @@ class EditPage {
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                                $wgMessageCache->loadAllMessages();
                                # If this is a system message, get the default text.
-                               $text = wfMsgWeirdKey ( $this->mTitle->getText() ) ;
+                               $text = wfMsgWeirdKey( $this->mTitle->getText() ) ;
                        } else {
                                # If requested, preload some text.
                                $text = $this->getPreloadedText( $preload );
@@ -370,7 +370,7 @@ class EditPage {
                wfDebug( __METHOD__.": enter\n" );
 
                // this is not an article
-               $wgOut->setArticleFlag(false);
+               $wgOut->setArticleFlag( false );
 
                $this->importFormData( $wgRequest );
                $this->firsttime = false;
@@ -380,20 +380,28 @@ class EditPage {
                        wfProfileOut( __METHOD__ );
                        return;
                }
-               
-               $wgOut->addScriptFile( 'edit.js' );
 
                if( wfReadOnly() ) {
-                       $this->readOnlyPage( $this->getContent() );
-                       wfProfileOut( __METHOD__ );
-                       return;
+                       if( $this->save ){
+                               // Force preview
+                               $this->save = false;
+                               $this->preview = true;
+                       } elseif( $this->preview || $this->diff ){
+                               // A warning will be displayed instead
+                       } else {
+                               $this->readOnlyPage( $this->getContent() );
+                               wfProfileOut( __METHOD__ );
+                               return;
+                       }
                }
 
-               $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser);
+               $wgOut->addScriptFile( 'edit.js' );
+
+               $permErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
                
                if( !$this->mTitle->exists() ) {
                        $permErrors = array_merge( $permErrors,
-                               wfArrayDiff2( $this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors ) );
+                               wfArrayDiff2( $this->mTitle->getUserPermissionsErrors( 'create', $wgUser ), $permErrors ) );
                }
 
                # Ignore some permissions errors.
@@ -405,15 +413,6 @@ class EditPage {
                                // Don't worry about blocks when previewing/diffing
                                $remove[] = $error;
                        }
-
-                       if ($error[0] == 'readonlytext')
-                       {
-                               if ($this->edit) {
-                                       $this->formtype = 'preview';
-                               } elseif ($this->save || $this->preview || $this->diff) {
-                                       $remove[] = $error;
-                               }
-                       }
                }
                $permErrors = wfArrayDiff2( $permErrors, $remove );
                
@@ -425,7 +424,7 @@ class EditPage {
                } else {
                        if ( $this->save ) {
                                $this->formtype = 'save';
-                       } else if ( $this->preview ) {
+                       } else if( $this->preview ) {
                                $this->formtype = 'preview';
                        } else if ( $this->diff ) {
                                $this->formtype = 'diff';
@@ -1160,9 +1159,9 @@ class EditPage {
                }
 
                if( wfReadOnly() ) {
-                       $wgOut->addHTML( '<div id="mw-read-only-warning">'.wfMsgWikiHTML( 'readonlywarning' ).'</div>' );
+                       $wgOut->wrapWikiMsg( "<div id=\"mw-read-only-warning\">\n$1\n</div>", array( 'readonlywarning', wfReadOnlyReason() ) );
                } elseif( $wgUser->isAnon() && $this->formtype != 'preview' ) {
-                       $wgOut->addHTML( '<div id="mw-anon-edit-warning">'.wfMsgWikiHTML( 'anoneditwarning' ).'</div>' );
+                       $wgOut->wrapWikiMsg( '<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning' );
                } else {
                        if( $this->isCssJsSubpage && $this->formtype != 'preview' ) {
                                # Check the skin exists
index 4b8f53d..20a30bc 100644 (file)
@@ -1149,7 +1149,9 @@ Please consider breaking the page into smaller sections.</strong>',
 'longpageerror'                    => '<strong>ERROR: The text you have submitted is $1 kilobytes long, which is longer than the maximum of $2 kilobytes.
 It cannot be saved.</strong>',
 'readonlywarning'                  => '<strong>WARNING: The database has been locked for maintenance, so you will not be able to save your edits right now.
-You may wish to cut-n-paste the text into a text file and save it for later.</strong>',
+You may wish to cut-n-paste the text into a text file and save it for later.</strong>
+
+The administrator who locked it offered this explanation: $1',
 'protectedpagewarning'             => '<strong>WARNING: This page has been locked so that only users with sysop privileges can edit it.</strong>',
 'semiprotectedpagewarning'         => "'''Note:''' This page has been locked so that only registered users can edit it.",
 'cascadeprotectedwarning'          => "'''Warning:''' This page has been locked so that only users with sysop privileges can edit it, because it is included in the following cascade-protected {{PLURAL:$1|page|pages}}:",