From 507f2244206d2886a301b0f0c51a3a061a515f7e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 15 May 2005 11:11:23 +0000 Subject: [PATCH] * (bug 2176) Section edit 'show changes' button works correctly now --- RELEASE-NOTES | 1 + includes/EditPage.php | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3f93e911f3..b90a08e773 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -187,6 +187,7 @@ Various bugfixes, small features, and a few experimental things: * (bug 2152) Add missing bgcolor to attribute whitelist for and * Group table renamed.....? * (bug 2178) Use temp dir from environment in parser tests +* (bug 2176) Section edit 'show changes' button works correctly now === Caveats === diff --git a/includes/EditPage.php b/includes/EditPage.php index b168152823..fbcb6af407 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -574,21 +574,9 @@ class EditPage { } $wgOut->addHTML( '' ); if ( 'diff' == $formtype ) { - $wgOut->addHTML( '
' ); - require_once( 'DifferenceEngine.php' ); - $oldtext = $this->mArticle->getContent( true ); - $newtext = $this->textbox1; - $oldtitle = wfMsg( 'currentrev' ); - $newtitle = wfMsg( 'yourtext' ); - - if ( $oldtext != wfMsg( 'noarticletext' ) || $newtext != '' ) { - $difftext = DifferenceEngine::getDiff( $oldtext, $newtext, $oldtitle, $newtitle ); - } if ( $wgUser->getOption('previewontop' ) ) { - $wgOut->addHTML( $difftext ); - $wgOut->addHTML( "
\n" ); + $wgOut->addHTML( $this->getDiff() ); } - $wgOut->addHTML( '
' ); } @@ -711,7 +699,8 @@ END $wgOut->addHTML( '
' . $previewOutput . '
' ); } if ( $formtype == 'diff' && !$wgUser->getOption( 'previewontop' ) ) { - $wgOut->addHTML( '
' . $difftext . '
' ); + #$wgOut->addHTML( '
' . $difftext . '
' ); + $wgOut->addHTML( $this->getDiff() ); } } @@ -1066,6 +1055,30 @@ END echo $this->getPreviewText( false, false ); } + + /** + * Get a diff between the current contents of the edit box and the + * version of the page we're editing from. + * + * If this is a section edit, we'll replace the section as for final + * save and then make a comparison. + * + * @return string HTML + */ + function getDiff() { + require_once( 'DifferenceEngine.php' ); + $oldtext = $this->mArticle->getContent( true ); + $newtext = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded( + $this->section, $this->textbox1, $this->summary, $this->edittime ); + $oldtitle = wfMsg( 'currentrev' ); + $newtitle = wfMsg( 'yourtext' ); + if ( $oldtext != wfMsg( 'noarticletext' ) || $newtext != '' ) { + $difftext = DifferenceEngine::getDiff( $oldtext, $newtext, $oldtitle, $newtitle ); + } + + return '
' . $difftext . '
'; + } + } ?> -- 2.20.1