X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=5ab5adc923a92b338f49cd72d201d696186d748e;hb=35c222b736c3d5a5500f654f2572d54209d05cea;hp=963b4af4140a1b5e0ecebc6245c71d1a9a6a5ff6;hpb=95a4edf10a4a8bcdf3af8e786cf54a5c78d9ee59;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/EditPage.php b/includes/EditPage.php index 963b4af414..5ab5adc923 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1063,6 +1063,7 @@ class EditPage { $title = Title::newFromText( $preload ); # Check for existence to avoid getting MediaWiki:Noarticletext if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) { + //TODO: somehow show a warning to the user! return $handler->makeEmptyContent(); } @@ -1071,6 +1072,7 @@ class EditPage { $title = $page->getRedirectTarget(); # Same as before if ( $title === null || !$title->exists() || !$title->userCan( 'read', $wgUser ) ) { + //TODO: somehow show a warning to the user! return $handler->makeEmptyContent(); } $page = WikiPage::factory( $title ); @@ -1080,9 +1082,25 @@ class EditPage { $content = $page->getContent( Revision::RAW ); if ( !$content ) { + //TODO: somehow show a warning to the user! return $handler->makeEmptyContent(); } + if ( $content->getModel() !== $handler->getModelID() ) { + $converted = $content->convert( $handler->getModelID() ); + + if ( !$converted ) { + //TODO: somehow show a warning to the user! + wfDebug( "Attempt to preload incompatible content: " + . "can't convert " . $content->getModel() + . " to " . $handler->getModelID() ); + + return $handler->makeEmptyContent(); + } + + $content = $converted; + } + return $content->preloadTransform( $title, $parserOptions ); } @@ -1473,16 +1491,14 @@ class EditPage { $this->isConflict = true; $content = $textbox_content; // do not try to merge here! } elseif ( $this->isConflict ) { - $contentObj = $content; # Attempt merge - if ( $this->mergeChangesInto( $content ) ) { + if ( $this->mergeChangesIntoContent( $content ) ) { // Successful merge! Maybe we should tell the user the good news? $this->isConflict = false; - $content = $this->toEditContent( $content ); wfDebug( __METHOD__ . ": Suppressing edit conflict, successful merge.\n" ); } else { $this->section = ''; - $this->textbox1 = ContentHandler::getContentText( $contentObj ); + $this->textbox1 = ContentHandler::getContentText( $content ); wfDebug( __METHOD__ . ": Keeping edit conflict, failed merge.\n" ); } } @@ -1666,37 +1682,15 @@ class EditPage { function mergeChangesInto( &$editText ){ ContentHandler::deprecated( __METHOD__, "1.21" ); - wfProfileIn( __METHOD__ ); - - $db = wfGetDB( DB_MASTER ); + $editContent = $this->toEditContent( $editText ); - // This is the revision the editor started from - $baseRevision = $this->getBaseRevision(); - if ( is_null( $baseRevision ) ) { - wfProfileOut( __METHOD__ ); - return false; - } - $baseText = $baseRevision->getText(); + $ok = $this->mergeChangesIntoContent( $editContent ); - // The current state, we want to merge updates into it - $currentRevision = Revision::loadFromTitle( $db, $this->mTitle ); - if ( is_null( $currentRevision ) ) { - wfProfileOut( __METHOD__ ); - return false; - } - $currentText = $currentRevision->getText(); - - $result = ''; - $editText = $this->toEditText( $editText ); - - if ( wfMerge( $baseText, $editText, $currentText, $result ) ) { - $editText = $result; - wfProfileOut( __METHOD__ ); + if ( $ok ) { + $editText = $this->toEditText( $editContent ); return true; - } else { - wfProfileOut( __METHOD__ ); - return false; } + return false; } /** @@ -2786,7 +2780,9 @@ HTML wfMessage( 'newwindow' )->parse(); $wgOut->addHTML( " {$cancel}\n" ); $wgOut->addHTML( " {$edithelp}\n" ); - $wgOut->addHTML( "\n\n" ); + $wgOut->addHTML( "\n" ); + wfRunHooks( 'EditPage::showStandardInputs:options', array( $this, $wgOut, &$tabindex ) ); + $wgOut->addHTML( "\n" ); } /** @@ -2936,6 +2932,12 @@ HTML try { $content = $this->toEditContent( $this->textbox1 ); + $previewHTML = ''; + if ( !wfRunHooks( 'AlternateEditPreview', array( $this, &$content, &$previewHTML, &$this->mParserOutput ) ) ) { + wfProfileOut( __METHOD__ ); + return $previewHTML; + } + if ( $this->mTriedSave && !$this->mTokenOk ) { if ( $this->mTokenOkExceptSuffix ) { $note = wfMessage( 'token_suffix_mismatch' )->plain() ;