// Standard preference behaviour
return true;
} elseif ( !$this->mTitle->exists() &&
- isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) &&
- $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
+ isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) &&
+ $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
{
// Categories are special
return true;
}
/**
- * Does this EditPage class support section editing?
- * This is used by EditPage subclasses to indicate their ui cannot handle section edits
+ * Returns whether section editing is supported for the current page.
+ * Subclasses may override this to replace the default behavior, which is
+ * to check ContentHandler::supportsSections.
*
- * @return bool
+ * @return bool true if this edit page supports sections, false otherwise.
*/
protected function isSectionEditSupported() {
- return true;
+ $contentHandler = ContentHandler::getForTitle( $this->mTitle );
+ return $contentHandler->supportsSections();
}
/**
# Section edit can come from either the form or a link
$this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
+
+ if ( $this->section !== null && $this->section !== '' && !$this->isSectionEditSupported() ) {
+ throw new ErrorPageError( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' );
+ }
+
$this->isNew = !$this->mTitle->exists() || $this->section == 'new';
if ( $request->wasPosted() ) {
wfProfileOut( get_class( $this ) . "::importContentFormData" );
}
+ # Trim spaces on user supplied text
+ $summary = trim( $request->getText( 'wpSummary' ) );
+
# Truncate for whole multibyte characters
- $this->summary = $wgContLang->truncate( $request->getText( 'wpSummary' ), 255 );
+ $this->summary = $wgContLang->truncate( $summary, 255 );
# If the summary consists of a heading, e.g. '==Foobar==', extract the title from the
# header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
return false;
case self::AS_PARSE_ERROR:
- $wgOut->addWikiText( '<div class="error">' . $status->getWikiText() . '</div>');
+ $wgOut->addWikiText( '<div class="error">' . $status->getWikiText() . '</div>' );
return true;
case self::AS_SUCCESS_NEW_ARTICLE:
$this->isConflict = false;
wfDebug( __METHOD__ . ": conflict suppressed; new section\n" );
}
- } elseif ( $this->section == '' && Revision::userWasLastToEdit( DB_MASTER, $this->mTitle->getArticleID(),
+ } elseif ( $this->section == '' && Revision::userWasLastToEdit( DB_MASTER, $this->mTitle->getArticleID(),
$wgUser->getId(), $this->edittime ) ) {
# Suppress edit conflict with self, except for section edits where merging is required.
wfDebug( __METHOD__ . ": Suppressing edit conflict, same user.\n" );
$doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
false, null, $this->contentFormat );
- if ( $doEditStatus->isOK() ) {
- $result['redirect'] = $content->isRedirect();
- $this->updateWatchlist();
- wfProfileOut( __METHOD__ );
- return $status;
- } else {
+ if ( !$doEditStatus->isOK() ) {
// Failure from doEdit()
// Show the edit conflict page for certain recognized errors from doEdit(),
// but don't show it for errors from extension hooks
wfProfileOut( __METHOD__ );
return $doEditStatus;
}
+
+ $result['redirect'] = $content->isRedirect();
+ $this->updateWatchlist();
+ wfProfileOut( __METHOD__ );
+ return $status;
}
/**
* @return bool
* @deprecated since 1.21, use mergeChangesIntoContent() instead
*/
- function mergeChangesInto( &$editText ){
+ function mergeChangesInto( &$editText ) {
ContentHandler::deprecated( __METHOD__, "1.21" );
$editContent = $this->toEditContent( $editText );
*
* @return bool
*/
- private function mergeChangesIntoContent( &$editContent ){
+ private function mergeChangesIntoContent( &$editContent ) {
wfProfileIn( __METHOD__ );
$db = wfGetDB( DB_MASTER );
$editContent = $result;
wfProfileOut( __METHOD__ );
return true;
- } else {
- wfProfileOut( __METHOD__ );
- return false;
}
+
+ wfProfileOut( __METHOD__ );
+ return false;
}
/**
} catch ( MWContentSerializationException $ex ) {
// this can't really happen, but be nice if it does.
$msg = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
- $wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>');
+ $wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>' );
}
}
$this->showDiff();
} catch ( MWContentSerializationException $ex ) {
$msg = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
- $wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>');
+ $wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>' );
}
}
}
$dbr = wfGetDB( DB_SLAVE );
$data = $dbr->selectRow(
array( 'logging', 'user' ),
- array( 'log_type',
- 'log_action',
- 'log_timestamp',
- 'log_user',
- 'log_namespace',
- 'log_title',
- 'log_comment',
- 'log_params',
- 'log_deleted',
- 'user_name' ),
- array( 'log_namespace' => $this->mTitle->getNamespace(),
- 'log_title' => $this->mTitle->getDBkey(),
- 'log_type' => 'delete',
- 'log_action' => 'delete',
- 'user_id=log_user' ),
+ array(
+ 'log_type',
+ 'log_action',
+ 'log_timestamp',
+ 'log_user',
+ 'log_namespace',
+ 'log_title',
+ 'log_comment',
+ 'log_params',
+ 'log_deleted',
+ 'user_name'
+ ), array(
+ 'log_namespace' => $this->mTitle->getNamespace(),
+ 'log_title' => $this->mTitle->getDBkey(),
+ 'log_type' => 'delete',
+ 'log_action' => 'delete',
+ 'user_id=log_user'
+ ),
__METHOD__,
array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' )
);
if ( $this->mTriedSave && !$this->mTokenOk ) {
if ( $this->mTokenOkExceptSuffix ) {
- $note = wfMessage( 'token_suffix_mismatch' )->plain() ;
+ $note = wfMessage( 'token_suffix_mismatch' )->plain();
} else {
- $note = wfMessage( 'session_fail_preview' )->plain() ;
+ $note = wfMessage( 'session_fail_preview' )->plain();
}
} elseif ( $this->incompleteForm ) {
- $note = wfMessage( 'edit_form_incomplete' )->plain() ;
+ $note = wfMessage( 'edit_form_incomplete' )->plain();
} else {
$note = wfMessage( 'previewnote' )->plain() .
' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text() . ']]';
$parserOptions = $this->mArticle->makeParserOptions( $this->mArticle->getContext() );
$parserOptions->setEditSection( false );
$parserOptions->setIsPreview( true );
- $parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' );
+ $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' );
# don't parse non-wikitext pages, show message about preview
if ( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) {
# Used messages to make sure grep find them:
# Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
if( $level && $format ) {
- $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage( "{$level}{$format}preview" )->text() . "</div>";
+ $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage( "{$level}{$format}preview" )->text() . "</div>";
}
}
}
}
} catch ( MWContentSerializationException $ex ) {
- $m = wfMessage('content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
+ $m = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
$note .= "\n\n" . $m->parse();
$previewHTML = '';
}
global $wgOut, $wgLang;
$this->textbox2 = $this->textbox1;
- if( is_array( $match ) ){
+ if( is_array( $match ) ) {
$match = $wgLang->listToText( $match );
}
$wgOut->prepareErrorPage( wfMessage( 'spamprotectiontitle' ) );