r23972 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23971‎ | r23972 | r23973 >
Date:19:23, 10 July 2007
Author:robchurch
Status:old
Tags:
Comment:
(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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -456,17 +456,30 @@
457457 }
458458
459459 /**
460 - * Return true if this page should be previewed when the edit form
461 - * is initially opened.
 460+ * Should we show a preview when the edit form is first shown?
 461+ *
462462 * @return bool
463 - * @private
464463 */
465 - function previewOnOpen() {
466 - global $wgUser;
467 - return $this->section != 'new' &&
468 - ( ( $wgUser->getOption( 'previewonfirst' ) && $this->mTitle->exists() ) ||
469 - ( $this->mTitle->getNamespace() == NS_CATEGORY &&
470 - !$this->mTitle->exists() ) );
 464+ private function previewOnOpen() {
 465+ global $wgRequest, $wgUser;
 466+ if( $wgRequest->getVal( 'preview' ) == 'yes' ) {
 467+ // Explicit override from request
 468+ return true;
 469+ } elseif( $wgRequest->getVal( 'preview' ) == 'no' ) {
 470+ // Explicit override from request
 471+ return false;
 472+ } elseif( $this->section == 'new' ) {
 473+ // Nothing *to* preview for new sections
 474+ return false;
 475+ } elseif( $this->mTitle->exists() && $wgUser->getOption( 'previewonfirst' ) ) {
 476+ // Standard preference behaviour
 477+ return true;
 478+ } elseif( !$this->mTitle->exists() && $this->mTitle->getNamespace() == NS_CATEGORY ) {
 479+ // Categories are special
 480+ return true;
 481+ } else {
 482+ return false;
 483+ }
471484 }
472485
473486 /**
Index: trunk/phase3/RELEASE-NOTES
@@ -128,6 +128,8 @@
129129 * Improved feedback on "rollback success" page
130130 * Show distinct 'namespaceprotected' message to users when namespace protection
131131 prevents page editing
 132+* (bug 9936) Per-edit suppression of preview-on-first edit with "preview=no"
 133+* Allow showing a one-off preview on first edit with "preview=yes"
132134
133135 == Bugfixes since 1.10 ==
134136

Follow-up revisions

RevisionCommit summaryAuthorDate
r24096Merged revisions 23910-24094 via svnmerge from...david22:38, 14 July 2007

Status & tagging log