const AS_IMAGE_REDIRECT_ANON = 233;
const AS_IMAGE_REDIRECT_LOGGED = 234;
+ /**
+ * @var Article
+ */
var $mArticle;
+
+ /**
+ * @var Title
+ */
var $mTitle;
private $mContextTitle = null;
var $action;
var $isCssJsSubpage = false;
var $isCssSubpage = false;
var $isJsSubpage = false;
+ var $isNew = false; // new page or new section
var $deletedSinceEdit;
var $formtype;
var $firsttime;
$this->preview = true;
}
- $wgOut->addModules( array( 'mediawiki.legacy.edit', 'mediawiki.action.edit' ) );
+ $wgOut->addModules( array( 'mediawiki.action.edit' ) );
if ( $wgUser->getOption( 'uselivepreview', false ) ) {
$wgOut->addModules( 'mediawiki.legacy.preview' );
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
- $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
- $this->isCssSubpage = $this->mTitle->isCssSubpage();
- $this->isJsSubpage = $this->mTitle->isJsSubpage();
+ $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
+ $this->isCssSubpage = $this->mTitle->isCssSubpage();
+ $this->isJsSubpage = $this->mTitle->isJsSubpage();
$this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
+ $this->isNew = !$this->mTitle->exists() || $this->section == 'new';
# Show applicable editing introductions
if ( $this->formtype == 'initial' || $this->firsttime )
} elseif ( $wgRequest->getVal( 'preview' ) == 'no' ) {
// Explicit override from request
return false;
- } elseif ( $this->section == 'new' ) {
+ } elseif ( $this->section == 'new' ) {
// Nothing *to* preview for new sections
return false;
} elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
}
$text = $this->textbox1;
- if ( $this->section == 'new' && $this->summary != '' ) {
+ if ( $this->section == 'new' && $this->summary != '' ) {
$text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text;
}
# Article exists. Check for edit conflict.
$this->mArticle->clear(); # Force reload of dates, etc.
- $this->mArticle->forUpdate( true ); # Lock the article
wfDebug( "timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n" );
}
# Handle the user preference to force summaries here, but not for null edits
- if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text )
+ if ( $this->section != 'new' && !$this->allowBlankSummary && 0 != strcmp( $oldtext, $text )
&& !Title::newFromRedirect( $text ) ) # check if it's not a redirect
{
if ( md5( $this->summary ) == $this->autoSumm ) {
}
# And a similar thing for new sections
- if ( $this->section == 'new' && !$this->allowBlankSummary ) {
+ if ( $this->section == 'new' && !$this->allowBlankSummary ) {
if ( trim( $this->summary ) == '' ) {
$this->missingSummary = true;
wfProfileOut( __METHOD__ );
# All's well
wfProfileIn( __METHOD__ . '-sectionanchor' );
$sectionanchor = '';
- if ( $this->section == 'new' ) {
+ if ( $this->section == 'new' ) {
if ( $this->textbox1 == '' ) {
$this->missingComment = true;
wfProfileOut( __METHOD__ . '-sectionanchor' );
$flags = EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
( $new ? EDIT_NEW : EDIT_UPDATE ) |
- ( $this->minoredit ? EDIT_MINOR : 0 ) |
+ ( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) |
( $bot ? EDIT_FORCE_BOT : 0 );
$status = $this->mArticle->doEdit( $text, $this->summary, $flags );
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
if ( $this->watchthis ) {
- $this->mArticle->doWatch();
+ Action::factory( 'watch', $this->mArticle )->execute();
} else {
- $this->mArticle->doUnwatch();
+ Action::factory( 'unwatch', $this->mArticle )->execute();
}
$dbw->commit();
}
# Already watched
$this->watchthis = true;
}
- if ( $wgUser->getOption( 'minordefault' ) ) $this->minoredit = true;
+ if ( $wgUser->getOption( 'minordefault' ) && !$this->isNew ) $this->minoredit = true;
if ( $this->textbox1 === false ) return false;
wfProxyCheck();
return true;
/**
* Send the edit form and related headers to $wgOut
- * @param $formCallback Optional callable that takes an OutputPage
- * parameter; will be called during form output
- * near the top, for captchas and the like.
+ * @param $formCallback Callback that takes an OutputPage parameter; will be called
+ * during form output near the top, for captchas and the like.
*/
function showEditForm( $formCallback = null ) {
global $wgOut, $wgUser;
// @todo move this to a cleaner conditional instead of blanking a variable
}
$wgOut->addHTML( <<<HTML
-{$toolbar}
<form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
HTML
);
// It is better to not parse the comment at all than to have templates expanded in the middle
// TODO: can the checkLabel be moved outside of the div so that wrapWikiMsg could be used?
+ $key = $comment === ''
+ ? 'confirmrecreate-noreason'
+ : 'confirmrecreate';
$wgOut->addHTML(
'<div class="mw-confirm-recreate">' .
- wfMsgExt( 'confirmrecreate', 'parseinline', $username, "<nowiki>$comment</nowiki>" ) .
+ wfMsgExt( $key, 'parseinline', $username, "<nowiki>$comment</nowiki>" ) .
Xml::checkLabel( wfMsg( 'recreate' ), 'wpRecreate', 'wpRecreate', false,
array( 'title' => $sk->titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' )
) .
}
$wgOut->addHTML( $this->editFormTextBeforeContent );
+
+ $wgOut->addHTML( $toolbar );
if ( $this->isConflict ) {
// In an edit conflict bypass the overrideable content form method
* Produce the stock "your edit contains spam" page
*
* @param $match Text which triggered one or more filters
- * @deprecated Use method spamPageWithContent() instead
+ * @deprecated since 1.17 Use method spamPageWithContent() instead
*/
static function spamPage( $match = false ) {
global $wgOut, $wgTitle;
return true;
}
- /**
- * @deprecated use $wgParser->stripSectionName()
- */
- function pseudoParseSectionAnchor( $text ) {
- global $wgParser;
- return $wgParser->stripSectionName( $text );
- }
-
/**
* Format an anchor fragment as it would appear for a given section name
* @param $text String
$paramList = implode( ',',
array_map( array( 'Xml', 'encodeJsVar' ), $params ) );
- $script .= "addButton($paramList);\n";
+ $script .= "mw.toolbar.addButton($paramList);\n";
}
-
$wgOut->addScript( Html::inlineScript(
- "if ( window.mediaWiki ) { jQuery(function(){{$script}}); }"
+ "if ( window.mediaWiki ) {{$script}}"
) );
$toolbar .= "\n</div>";
$checkboxes = array();
- $checkboxes['minor'] = '';
- $minorLabel = wfMsgExt( 'minoredit', array( 'parseinline' ) );
- if ( $wgUser->isAllowed( 'minoredit' ) ) {
- $attribs = array(
- 'tabindex' => ++$tabindex,
- 'accesskey' => wfMsg( 'accesskey-minoredit' ),
- 'id' => 'wpMinoredit',
- );
- $checkboxes['minor'] =
- Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
- " <label for='wpMinoredit' id='mw-editpage-minoredit'" .
- Xml::expandAttributes( array( 'title' => $skin->titleAttrib( 'minoredit', 'withaccess' ) ) ) .
- ">{$minorLabel}</label>";
+ // don't show the minor edit checkbox if it's a new page or section
+ if ( !$this->isNew ) {
+ $checkboxes['minor'] = '';
+ $minorLabel = wfMsgExt( 'minoredit', array( 'parseinline' ) );
+ if ( $wgUser->isAllowed( 'minoredit' ) ) {
+ $attribs = array(
+ 'tabindex' => ++$tabindex,
+ 'accesskey' => wfMsg( 'accesskey-minoredit' ),
+ 'id' => 'wpMinoredit',
+ );
+ $checkboxes['minor'] =
+ Xml::check( 'wpMinoredit', $checked['minor'], $attribs ) .
+ " <label for='wpMinoredit' id='mw-editpage-minoredit'" .
+ Xml::expandAttributes( array( 'title' => $skin->titleAttrib( 'minoredit', 'withaccess' ) ) ) .
+ ">{$minorLabel}</label>";
+ }
}
$watchLabel = wfMsgExt( 'watchthis', array( 'parseinline' ) );
$result = "";
$working = 0;
for( $i = 0; $i < strlen( $invalue ); $i++ ) {
- $bytevalue = ord( $invalue{$i} );
+ $bytevalue = ord( $invalue[$i] );
if ( $bytevalue <= 0x7F ) { //0xxx xxxx
$result .= chr( $bytevalue );
$bytesleft = 0;
function unmakesafe( $invalue ) {
$result = "";
for( $i = 0; $i < strlen( $invalue ); $i++ ) {
- if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue{$i+3} != '0' ) ) {
+ if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue[$i+3] != '0' ) ) {
$i += 3;
$hexstring = "";
do {
- $hexstring .= $invalue{$i};
+ $hexstring .= $invalue[$i];
$i++;
- } while( ctype_xdigit( $invalue{$i} ) && ( $i < strlen( $invalue ) ) );
+ } while( ctype_xdigit( $invalue[$i] ) && ( $i < strlen( $invalue ) ) );
// Do some sanity checks. These aren't needed for reversability,
// but should help keep the breakage down if the editor