(bug 9936) Per-edit suppression of preview-on-first edit with "preview=no", and allow...
authorRob Church <robchurch@users.mediawiki.org>
Tue, 10 Jul 2007 19:23:01 +0000 (19:23 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 10 Jul 2007 19:23:01 +0000 (19:23 +0000)
RELEASE-NOTES
includes/EditPage.php

index f8908bf..6a0b065 100644 (file)
@@ -128,6 +128,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Improved feedback on "rollback success" page
 * Show distinct 'namespaceprotected' message to users when namespace protection
   prevents page editing
+* (bug 9936) Per-edit suppression of preview-on-first edit with "preview=no"
+* Allow showing a one-off preview on first edit with "preview=yes"
 
 == Bugfixes since 1.10 ==
 
index b86768d..867431b 100644 (file)
@@ -456,17 +456,30 @@ class EditPage {
        }
 
        /**
-        * Return true if this page should be previewed when the edit form
-        * is initially opened.
+        * Should we show a preview when the edit form is first shown?
+        *
         * @return bool
-        * @private
         */
-       function previewOnOpen() {
-               global $wgUser;
-               return $this->section != 'new' &&
-                       ( ( $wgUser->getOption( 'previewonfirst' ) && $this->mTitle->exists() ) ||
-                               ( $this->mTitle->getNamespace() == NS_CATEGORY &&
-                                       !$this->mTitle->exists() ) );
+       private function previewOnOpen() {
+               global $wgRequest, $wgUser;
+               if( $wgRequest->getVal( 'preview' ) == 'yes' ) {
+                       // Explicit override from request
+                       return true;
+               } elseif( $wgRequest->getVal( 'preview' ) == 'no' ) {
+                       // Explicit override from request
+                       return false;
+               } elseif( $this->section == 'new' ) {
+                       // Nothing *to* preview for new sections
+                       return false;
+               } elseif( $this->mTitle->exists() && $wgUser->getOption( 'previewonfirst' ) ) {
+                       // Standard preference behaviour
+                       return true;
+               } elseif( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) {
+                       // Categories are special
+                       return true;
+               } else {
+                       return false;
+               }
        }
 
        /**