From: Rob Church Date: Tue, 10 Jul 2007 19:23:01 +0000 (+0000) Subject: (bug 9936) Per-edit suppression of preview-on-first edit with "preview=no", and allow... X-Git-Tag: 1.31.0-rc.0~52162 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/load.php?a=commitdiff_plain;h=fe80acc8f5bf5f092e0366e6b307884e791971c1;p=lhc%2Fweb%2Fwiklou.git (bug 9936) Per-edit suppression of preview-on-first edit with "preview=no", and allow showing a one-off preview on first edit with "preview=yes". I broke down the huge boolean test in the return statement to make it much clearer and easier to read. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f8908bf0e2..6a0b0650fa 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/EditPage.php b/includes/EditPage.php index b86768d212..867431b14c 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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; + } } /**