/**
* Fetch initial editing page content.
+ * @returns mixed string on success, $def_text for invalid sections
* @private
*/
function getContent( $def_text = '' ) {
if ( $section == 'new' ) {
$text = $this->getPreloadedText( $preload );
} else {
+ // Get section edit text (returns $def_text for invalid sections)
$text = $wgParser->getSection( $text, $section, $def_text );
}
}
* @return string The contents of the page.
*/
protected function getPreloadedText( $preload ) {
+ global $wgParser;
if ( !empty( $this->mPreloadText ) ) {
return $this->mPreloadText;
- } elseif ( $preload === '' ) {
- return '';
} else {
$preloadTitle = Title::newFromText( $preload );
if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
- $rev = Revision::newFromTitle( $preloadTitle );
- if ( is_object( $rev ) ) {
- $text = $rev->getText();
- // TODO FIXME: AAAAAAAAAAA, this shouldn't be implementing
- // its own mini-parser! -ævar
- $text = preg_replace( '~</?includeonly>~', '', $text );
- return $text;
- } else
- return '';
+ return $wgParser->getTransclusionText( $preloadTitle );
}
}
}
$permErrors = $this->getEditPermissionErrors();
if ( $permErrors ) {
wfDebug( __METHOD__ . ": User can't edit\n" );
- $this->readOnlyPage( $this->getContent(), true, $permErrors, 'edit' );
+ $this->readOnlyPage( $this->getContent( false ), true, $permErrors, 'edit' );
wfProfileOut( __METHOD__ );
return;
} else {
/**
* Initialise form fields in the object
* Called on the first invocation, e.g. when a user clicks an edit link
+ * @returns bool -- if the requested section is valid
*/
function initialiseForm() {
global $wgUser;
$autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
$wgOut->addHTML( Xml::hidden( 'wpAutoSummary', $autosumm ) );
+ $wgOut->addHTML( Xml::hidden( 'oldid', $this->mArticle->getOldID() ) );
+
if ( $this->section == 'new' ) {
$this->showSummaryInput( true, $this->summary );
$wgOut->addHTML( $this->getSummaryPreview( true, $this->summary ) );
}
protected function showHeader() {
- global $wgOut, $wgParser, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
+ global $wgOut, $wgUser, $wgTitle, $wgMaxArticleSize, $wgLang;
if ( $this->isConflict ) {
$wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1</div>", 'explainconflict' );
$this->edittime = $this->mArticle->getTimestamp();
$inputAttrs = ( is_array($inputAttrs) ? $inputAttrs : array() ) + array(
'id' => 'wpSummary',
'maxlength' => '200',
- 'tabindex' => '1',
+ 'tabindex' => '2',
'size' => 60,
'spellcheck' => 'true',
);
public function getCancelLink() {
global $wgUser, $wgTitle;
+
$cancelParams = array();
- if ( !$this->isConflict && isset( $this->mArticle ) &&
- isset( $this->mArticle->mRevision ) &&
- !$this->mArticle->mRevision->isCurrent() )
- $cancelParams['oldid'] = $this->mArticle->mRevision->getId();
+ if ( !$this->isConflict && $this->mArticle->getOldID() > 0 ) {
+ $cancelParams['oldid'] = $this->mArticle->getOldID();
+ }
+
return $wgUser->getSkin()->link(
$wgTitle,
wfMsgExt( 'cancel', array( 'parseinline' ) ),