*/
const AS_HOOK_ERROR = 210;
- /**
- * Status: The filter function set in $wgFilterCallback returned true (= block it)
- */
- const AS_FILTERING = 211;
-
/**
* Status: A hook function returned an error
*/
*/
const AS_IMAGE_REDIRECT_LOGGED = 234;
+ /**
+ * HTML id and name for the beginning of the edit form.
+ */
+ const EDITFORM_ID = 'editform';
+
/**
* @var Article
*/
# If we just undid one rev, use an autosummary
$firstrev = $oldrev->getNext();
- if ( $firstrev->getId() == $undo ) {
+ if ( $firstrev && $firstrev->getId() == $undo ) {
$undoSummary = wfMsgForContent( 'undo-summary', $undo, $undorev->getUserText() );
if ( $this->summary === '' ) {
$this->summary = $undoSummary;
return true;
case self::AS_HOOK_ERROR:
- case self::AS_FILTERING:
return false;
case self::AS_SUCCESS_NEW_ARTICLE:
* AS_CONTENT_TOO_BIG and AS_BLOCKED_PAGE_FOR_USER. All that stuff needs to be cleaned up some time.
*/
function internalAttemptSave( &$result, $bot = false ) {
- global $wgFilterCallback, $wgUser, $wgRequest, $wgParser;
- global $wgMaxArticleSize;
+ global $wgUser, $wgRequest, $wgParser, $wgMaxArticleSize;
$status = Status::newGood();
wfProfileOut( __METHOD__ );
return $status;
}
- if ( $wgFilterCallback && is_callable( $wgFilterCallback ) && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section, $this->hookError, $this->summary ) ) {
- # Error messages or other handling should be performed by the filter function
- $status->setResult( false, self::AS_FILTERING );
- wfProfileOut( __METHOD__ . '-checks' );
- wfProfileOut( __METHOD__ );
- return $status;
- }
if ( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) ) ) {
# Error messages etc. could be handled within the hook...
$status->fatal( 'hookaborted' );
wfProfileOut( __METHOD__ . '-checks' );
- # If article is new, insert it.
- $aid = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
- $new = ( $aid == 0 );
+ // Use SELECT FOR UPDATE here to avoid transaction collision in
+ // WikiPage::updateRevisionOn() and ending in the self::AS_END case.
+ $this->mArticle->loadPageData( 'forupdate' );
+ $new = !$this->mArticle->exists();
if ( $new ) {
// Late check for create permission, just in case *PARANOIA*
} else {
# Article exists. Check for edit conflict.
-
- $this->mArticle->clear(); # Force reload of dates, etc.
$timestamp = $this->mArticle->getTimestamp();
-
wfDebug( "timestamp: {$timestamp}, edittime: {$this->edittime}\n" );
if ( $timestamp != $this->edittime ) {
# Enabled article-related sidebar, toplinks, etc.
$wgOut->setArticleRelated( true );
+ $contextTitle = $this->getContextTitle();
if ( $this->isConflict ) {
- $wgOut->setPageTitle( wfMessage( 'editconflict', $this->getContextTitle()->getPrefixedText() ) );
- } elseif ( $this->section != '' ) {
+ $msg = 'editconflict';
+ } elseif ( $contextTitle->exists() && $this->section != '' ) {
$msg = $this->section == 'new' ? 'editingcomment' : 'editingsection';
- $wgOut->setPageTitle( wfMessage( $msg, $this->getContextTitle()->getPrefixedText() ) );
} else {
- # Use the title defined by DISPLAYTITLE magic word when present
- if ( isset( $this->mParserOutput )
- && ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) {
- $title = $dt;
- } else {
- $title = $this->getContextTitle()->getPrefixedText();
- }
- $wgOut->setPageTitle( wfMessage( 'editing', $title ) );
+ $msg = $contextTitle->exists() || ( $contextTitle->getNamespace() == NS_MEDIAWIKI && $contextTitle->getDefaultMessageText() !== false ) ?
+ 'editing' : 'creating';
+ }
+ # Use the title defined by DISPLAYTITLE magic word when present
+ $displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() : false;
+ if ( $displayTitle === false ) {
+ $displayTitle = $contextTitle->getPrefixedText();
}
+ $wgOut->setPageTitle( wfMessage( $msg, $displayTitle ) );
}
/**
}
}
- $wgOut->addHTML( Html::openElement( 'form', array( 'id' => 'editform', 'name' => 'editform',
+ $wgOut->addHTML( Html::openElement( 'form', array( 'id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID,
'method' => 'post', 'action' => $this->getActionURL( $this->getContextTitle() ),
'enctype' => 'multipart/form-data' ) ) );
);
}
+ # When the summary is hidden, also hide them on preview/show changes
+ if( $this->nosummary ) {
+ $wgOut->addHTML( Html::hidden( 'nosummary', true ) );
+ }
+
# If a blank edit summary was previously provided, and the appropriate
# user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
# user being bounced back more than once in the event that a summary
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
- $editnotice_ns_message = wfMessage( $editnotice_ns )->inContentLanguage();
+ $editnotice_ns_message = wfMessage( $editnotice_ns );
if ( $editnotice_ns_message->exists() ) {
$wgOut->addWikiText( $editnotice_ns_message->plain() );
}
$editnotice_base = $editnotice_ns;
while ( count( $parts ) > 0 ) {
$editnotice_base .= '-' . array_shift( $parts );
- $editnotice_base_msg = wfMessage( $editnotice_base )->inContentLanguage();
+ $editnotice_base_msg = wfMessage( $editnotice_base );
if ( $editnotice_base_msg->exists() ) {
$wgOut->addWikiText( $editnotice_base_msg->plain() );
}
} else {
# Even if there are no subpages in namespace, we still don't want / in MW ns.
$editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->mTitle->getDBkey() );
- $editnoticeMsg = wfMessage( $editnoticeText )->inContentLanguage();
+ $editnoticeMsg = wfMessage( $editnoticeText );
if ( $editnoticeMsg->exists() ) {
$wgOut->addWikiText( $editnoticeMsg->plain() );
}
function showDiff() {
global $wgUser, $wgContLang, $wgParser, $wgOut;
- $oldtext = $this->mArticle->getRawText();
+ $oldtitlemsg = 'currentrev';
+ # if message does not exist, show diff against the preloaded default
+ if( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists() ) {
+ $oldtext = $this->mTitle->getDefaultMessageText();
+ if( $oldtext !== false ) {
+ $oldtitlemsg = 'defaultmessagetext';
+ }
+ } else {
+ $oldtext = $this->mArticle->getRawText();
+ }
$newtext = $this->mArticle->replaceSection(
$this->section, $this->textbox1, $this->summary, $this->edittime );
$newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts );
if ( $oldtext !== false || $newtext != '' ) {
- $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) );
+ $oldtitle = wfMsgExt( $oldtitlemsg, array( 'parseinline' ) );
$newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) );
$de = new DifferenceEngine( $this->mArticle->getContext() );
* @return string
*/
function getPreviewText() {
- global $wgOut, $wgUser, $wgParser, $wgRawHtml;
+ global $wgOut, $wgUser, $wgParser, $wgRawHtml, $wgLang;
wfProfileIn( __METHOD__ );
} elseif ( $this->incompleteForm ) {
$note = wfMsg( 'edit_form_incomplete' );
} else {
- $note = wfMsg( 'previewnote' );
+ $note = wfMsg( 'previewnote' ) .
+ ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMsg( 'continue-editing' ) . ']]';
}
$parserOptions = ParserOptions::newFromUser( $wgUser );
$parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' );
# don't parse non-wikitext pages, show message about preview
- # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
-
- if ( $this->isCssJsSubpage || !$this->mTitle->isWikitextPage() ) {
+ if ( $this->mTitle->isCssJsSubpage() || !$this->mTitle->isWikitextPage() ) {
if ( $this->mTitle->isCssJsSubpage() ) {
$level = 'user';
} elseif ( $this->mTitle->isCssOrJsPage() ) {
# Used messages to make sure grep find them:
# Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
+ $class = 'mw-code';
if ( $level ) {
if ( preg_match( "/\\.css$/", $this->mTitle->getText() ) ) {
$previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg( "{$level}csspreview" ) . "\n</div>";
- $class = "mw-code mw-css";
+ $class .= " mw-css";
} elseif ( preg_match( "/\\.js$/", $this->mTitle->getText() ) ) {
$previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg( "{$level}jspreview" ) . "\n</div>";
- $class = "mw-code mw-js";
+ $class .= " mw-js";
} else {
throw new MWException( 'A CSS/JS (sub)page but which is not css nor js!' );
}
+ $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
+ $previewHTML = $parserOutput->getText();
+ } else {
+ $previewHTML = '';
}
- $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
- $previewHTML = $parserOutput->mText;
$previewHTML .= "<pre class=\"$class\" dir=\"ltr\">\n" . htmlspecialchars( $this->textbox1 ) . "\n</pre>\n";
} else {
$toparse = $this->textbox1;