Index: trunk/phase3/CREDITS |
— | — | @@ -30,6 +30,7 @@ |
31 | 31 | * Ilmari Karonen |
32 | 32 | * Jack D. Pond |
33 | 33 | * Jack Phoenix |
| 34 | +* Jan Paul Posma |
34 | 35 | * Jason Richey |
35 | 36 | * Jon Harald Søby |
36 | 37 | * Juliano F. Ravasi |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -57,6 +57,7 @@ |
58 | 58 | var $isCssJsSubpage = false; |
59 | 59 | var $isCssSubpage = false; |
60 | 60 | var $isJsSubpage = false; |
| 61 | + var $isNew = false; // new page or new section |
61 | 62 | var $deletedSinceEdit; |
62 | 63 | var $formtype; |
63 | 64 | var $firsttime; |
— | — | @@ -165,7 +166,7 @@ |
166 | 167 | |
167 | 168 | $preload = $wgRequest->getVal( 'preload', |
168 | 169 | // Custom preload text for new sections |
169 | | - $section === 'new' ? 'MediaWiki:addsection-preload' : '' ); |
| 170 | + $section === 'new' ? 'MediaWiki:addsection-preload' : '' ); /* use $this->isNew here? */ |
170 | 171 | $undoafter = $wgRequest->getVal( 'undoafter' ); |
171 | 172 | $undo = $wgRequest->getVal( 'undo' ); |
172 | 173 | |
— | — | @@ -232,7 +233,7 @@ |
233 | 234 | $this->editFormPageTop .= $wgOut->parse( '<div class="error mw-undo-norev">' . wfMsgNoTrans( 'undo-norev' ) . '</div>' ); |
234 | 235 | } |
235 | 236 | } else if ( $section != '' ) { |
236 | | - if ( $section == 'new' ) { |
| 237 | + if ( $section == 'new' ) { /* use $this->isNew here? */ |
237 | 238 | $text = $this->getPreloadedText( $preload ); |
238 | 239 | } else { |
239 | 240 | // Get section edit text (returns $def_text for invalid sections) |
— | — | @@ -415,10 +416,11 @@ |
416 | 417 | |
417 | 418 | $this->isConflict = false; |
418 | 419 | // css / js subpages of user pages get a special treatment |
419 | | - $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); |
420 | | - $this->isCssSubpage = $this->mTitle->isCssSubpage(); |
421 | | - $this->isJsSubpage = $this->mTitle->isJsSubpage(); |
| 420 | + $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); |
| 421 | + $this->isCssSubpage = $this->mTitle->isCssSubpage(); |
| 422 | + $this->isJsSubpage = $this->mTitle->isJsSubpage(); |
422 | 423 | $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage(); |
| 424 | + $this->isNew = !$this->mTitle->exists() || $this->section == 'new'; |
423 | 425 | |
424 | 426 | # Show applicable editing introductions |
425 | 427 | if ( $this->formtype == 'initial' || $this->firsttime ) |
— | — | @@ -530,7 +532,7 @@ |
531 | 533 | } elseif ( $wgRequest->getVal( 'preview' ) == 'no' ) { |
532 | 534 | // Explicit override from request |
533 | 535 | return false; |
534 | | - } elseif ( $this->section == 'new' ) { |
| 536 | + } elseif ( $this->section == 'new' ) { /* use $this->isNew here? */ |
535 | 537 | // Nothing *to* preview for new sections |
536 | 538 | return false; |
537 | 539 | } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) { |
— | — | @@ -688,10 +690,10 @@ |
689 | 691 | $this->watchthis = $request->getBool( 'watchthis', false ); // Watch may be overriden by request parameters |
690 | 692 | $this->recreate = false; |
691 | 693 | |
692 | | - if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) { |
| 694 | + if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) { /* use $this->isNew here? */ |
693 | 695 | $this->summary = $request->getVal( 'preloadtitle' ); |
694 | 696 | } |
695 | | - elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) { |
| 697 | + elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) { /* use $this->isNew here? */ |
696 | 698 | $this->summary = $request->getText( 'summary' ); |
697 | 699 | } |
698 | 700 | |
— | — | @@ -709,7 +711,7 @@ |
710 | 712 | $this->live = $request->getCheck( 'live' ); |
711 | 713 | $this->editintro = $request->getText( 'editintro', |
712 | 714 | // Custom edit intro for new sections |
713 | | - $this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' ); |
| 715 | + $this->section === 'new' ? 'MediaWiki:addsection-editintro' : '' ); /* use $this->isNew here? */ |
714 | 716 | |
715 | 717 | // Allow extensions to modify form data |
716 | 718 | wfRunHooks( 'EditPage::importFormData', array( $this, $request ) ); |
— | — | @@ -976,7 +978,7 @@ |
977 | 979 | } |
978 | 980 | |
979 | 981 | $text = $this->textbox1; |
980 | | - if ( $this->section == 'new' && $this->summary != '' ) { |
| 982 | + if ( $this->section == 'new' && $this->summary != '' ) { /* use $this->isNew here? */ |
981 | 983 | $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text; |
982 | 984 | } |
983 | 985 | |
— | — | @@ -992,7 +994,7 @@ |
993 | 995 | |
994 | 996 | if ( $this->mArticle->getTimestamp() != $this->edittime ) { |
995 | 997 | $this->isConflict = true; |
996 | | - if ( $this->section == 'new' ) { |
| 998 | + if ( $this->section == 'new' ) { /* use $this->isNew here? */ |
997 | 999 | if ( $this->mArticle->getUserText() == $wgUser->getName() && |
998 | 1000 | $this->mArticle->getComment() == $this->summary ) { |
999 | 1001 | // Probably a duplicate submission of a new comment. |
— | — | @@ -1058,7 +1060,7 @@ |
1059 | 1061 | } |
1060 | 1062 | |
1061 | 1063 | # Handle the user preference to force summaries here, but not for null edits |
1062 | | - if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text ) |
| 1064 | + if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text ) /* use $this->isNew here? */ |
1063 | 1065 | && !Title::newFromRedirect( $text ) ) # check if it's not a redirect |
1064 | 1066 | { |
1065 | 1067 | if ( md5( $this->summary ) == $this->autoSumm ) { |
— | — | @@ -1069,7 +1071,7 @@ |
1070 | 1072 | } |
1071 | 1073 | |
1072 | 1074 | # And a similar thing for new sections |
1073 | | - if ( $this->section == 'new' && !$this->allowBlankSummary ) { |
| 1075 | + if ( $this->section == 'new' && !$this->allowBlankSummary ) { /* use $this->isNew here? */ |
1074 | 1076 | if ( trim( $this->summary ) == '' ) { |
1075 | 1077 | $this->missingSummary = true; |
1076 | 1078 | wfProfileOut( __METHOD__ ); |
— | — | @@ -1080,7 +1082,7 @@ |
1081 | 1083 | # All's well |
1082 | 1084 | wfProfileIn( __METHOD__ . '-sectionanchor' ); |
1083 | 1085 | $sectionanchor = ''; |
1084 | | - if ( $this->section == 'new' ) { |
| 1086 | + if ( $this->section == 'new' ) { /* use $this->isNew here? */ |
1085 | 1087 | if ( $this->textbox1 == '' ) { |
1086 | 1088 | $this->missingComment = true; |
1087 | 1089 | wfProfileOut( __METHOD__ . '-sectionanchor' ); |
— | — | @@ -1128,7 +1130,7 @@ |
1129 | 1131 | |
1130 | 1132 | $flags = EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | |
1131 | 1133 | ( $new ? EDIT_NEW : EDIT_UPDATE ) | |
1132 | | - ( $this->minoredit ? EDIT_MINOR : 0 ) | |
| 1134 | + ( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) | |
1133 | 1135 | ( $bot ? EDIT_FORCE_BOT : 0 ); |
1134 | 1136 | |
1135 | 1137 | $status = $this->mArticle->doEdit( $text, $this->summary, $flags ); |
— | — | @@ -1237,7 +1239,7 @@ |
1238 | 1240 | # Already watched |
1239 | 1241 | $this->watchthis = true; |
1240 | 1242 | } |
1241 | | - if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true; |
| 1243 | + if ( $wgUser->getOption( 'minordefault' ) && !$this->isNew ) $this->minoredit = true; |
1242 | 1244 | if ( $this->textbox1 === false ) return false; |
1243 | 1245 | wfProxyCheck(); |
1244 | 1246 | return true; |
— | — | @@ -1252,7 +1254,7 @@ |
1253 | 1255 | if ( $this->isConflict ) { |
1254 | 1256 | $wgOut->setPageTitle( wfMsg( 'editconflict', $this->getContextTitle()->getPrefixedText() ) ); |
1255 | 1257 | } elseif ( $this->section != '' ) { |
1256 | | - $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection'; |
| 1258 | + $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection'; /* use $this->isNew here? */ |
1257 | 1259 | $wgOut->setPageTitle( wfMsg( $msg, $this->getContextTitle()->getPrefixedText() ) ); |
1258 | 1260 | } else { |
1259 | 1261 | # Use the title defined by DISPLAYTITLE magic word when present |
— | — | @@ -1375,14 +1377,14 @@ |
1376 | 1378 | # For a bit more sophisticated detection of blank summaries, hash the |
1377 | 1379 | # automatic one and pass that in the hidden field wpAutoSummary. |
1378 | 1380 | if ( $this->missingSummary || |
1379 | | - ( $this->section == 'new' && $this->nosummary ) ) |
| 1381 | + ( $this->section == 'new' && $this->nosummary ) ) /* use $this->isNew here? */ |
1380 | 1382 | $wgOut->addHTML( Html::hidden( 'wpIgnoreBlankSummary', true ) ); |
1381 | 1383 | $autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary ); |
1382 | 1384 | $wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) ); |
1383 | 1385 | |
1384 | 1386 | $wgOut->addHTML( Html::hidden( 'oldid', $this->mArticle->getOldID() ) ); |
1385 | 1387 | |
1386 | | - if ( $this->section == 'new' ) { |
| 1388 | + if ( $this->section == 'new' ) { /* use $this->isNew here? */ |
1387 | 1389 | $this->showSummaryInput( true, $this->summary ); |
1388 | 1390 | $wgOut->addHTML( $this->getSummaryPreview( true, $this->summary ) ); |
1389 | 1391 | } |
— | — | @@ -1449,7 +1451,7 @@ |
1450 | 1452 | return false; |
1451 | 1453 | } |
1452 | 1454 | |
1453 | | - if ( $this->section != '' && $this->section != 'new' ) { |
| 1455 | + if ( $this->section != '' && $this->section != 'new' ) { /* use $this->isNew here? */ |
1454 | 1456 | $matches = array(); |
1455 | 1457 | if ( !$this->summary && !$this->preview && !$this->diff ) { |
1456 | 1458 | preg_match( "/^(=+)(.+)\\1/mi", $this->textbox1, $matches ); |
— | — | @@ -1466,11 +1468,11 @@ |
1467 | 1469 | $wgOut->wrapWikiMsg( "<div id='mw-missingcommenttext'>\n$1\n</div>", 'missingcommenttext' ); |
1468 | 1470 | } |
1469 | 1471 | |
1470 | | - if ( $this->missingSummary && $this->section != 'new' ) { |
| 1472 | + if ( $this->missingSummary && $this->section != 'new' ) { /* use $this->isNew here? */ |
1471 | 1473 | $wgOut->wrapWikiMsg( "<div id='mw-missingsummary'>\n$1\n</div>", 'missingsummary' ); |
1472 | 1474 | } |
1473 | 1475 | |
1474 | | - if ( $this->missingSummary && $this->section == 'new' ) { |
| 1476 | + if ( $this->missingSummary && $this->section == 'new' ) { /* use $this->isNew here? */ |
1475 | 1477 | $wgOut->wrapWikiMsg( "<div id='mw-missingcommentheader'>\n$1\n</div>", 'missingcommentheader' ); |
1476 | 1478 | } |
1477 | 1479 | |
— | — | @@ -1854,7 +1856,7 @@ |
1855 | 1857 | global $wgOut, $wgUser; |
1856 | 1858 | $wgOut->addHTML( "<div class='editOptions'>\n" ); |
1857 | 1859 | |
1858 | | - if ( $this->section != 'new' ) { |
| 1860 | + if ( $this->section != 'new' ) { /* use $this->isNew here? */ |
1859 | 1861 | $this->showSummaryInput( false, $this->summary ); |
1860 | 1862 | $wgOut->addHTML( $this->getSummaryPreview( false, $this->summary ) ); |
1861 | 1863 | } |
— | — | @@ -1997,7 +1999,7 @@ |
1998 | 2000 | |
1999 | 2001 | # If we're adding a comment, we need to show the |
2000 | 2002 | # summary as the headline |
2001 | | - if ( $this->section == "new" && $this->summary != "" ) { |
| 2003 | + if ( $this->section == "new" && $this->summary != "" ) { /* use $this->isNew here? */ |
2002 | 2004 | $toparse = "== {$this->summary} ==\n\n" . $toparse; |
2003 | 2005 | } |
2004 | 2006 | |
— | — | @@ -2439,19 +2441,22 @@ |
2440 | 2442 | |
2441 | 2443 | $checkboxes = array(); |
2442 | 2444 | |
2443 | | - $checkboxes['minor'] = ''; |
2444 | | - $minorLabel = wfMsgExt( 'minoredit', array( 'parseinline' ) ); |
2445 | | - if ( $wgUser->isAllowed( 'minoredit' ) ) { |
2446 | | - $attribs = array( |
2447 | | - 'tabindex' => ++$tabindex, |
2448 | | - 'accesskey' => wfMsg( 'accesskey-minoredit' ), |
2449 | | - 'id' => 'wpMinoredit', |
2450 | | - ); |
2451 | | - $checkboxes['minor'] = |
2452 | | - Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) . |
2453 | | - " <label for='wpMinoredit' id='mw-editpage-minoredit'" . |
2454 | | - Xml::expandAttributes( array( 'title' => $skin->titleAttrib( 'minoredit', 'withaccess' ) ) ) . |
2455 | | - ">{$minorLabel}</label>"; |
| 2445 | + // don't show the minor edit checkbox if it's a new page or section |
| 2446 | + if ( !$this->isNew ) { |
| 2447 | + $checkboxes['minor'] = ''; |
| 2448 | + $minorLabel = wfMsgExt( 'minoredit', array( 'parseinline' ) ); |
| 2449 | + if ( $wgUser->isAllowed( 'minoredit' ) ) { |
| 2450 | + $attribs = array( |
| 2451 | + 'tabindex' => ++$tabindex, |
| 2452 | + 'accesskey' => wfMsg( 'accesskey-minoredit' ), |
| 2453 | + 'id' => 'wpMinoredit', |
| 2454 | + ); |
| 2455 | + $checkboxes['minor'] = |
| 2456 | + Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) . |
| 2457 | + " <label for='wpMinoredit' id='mw-editpage-minoredit'" . |
| 2458 | + Xml::expandAttributes( array( 'title' => $skin->titleAttrib( 'minoredit', 'withaccess' ) ) ) . |
| 2459 | + ">{$minorLabel}</label>"; |
| 2460 | + } |
2456 | 2461 | } |
2457 | 2462 | |
2458 | 2463 | $watchLabel = wfMsgExt( 'watchthis', array( 'parseinline' ) ); |