From 6bfaecba3b56862f29b8b77b702afbb46e98fb64 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 9 Feb 2009 07:42:54 +0000 Subject: [PATCH] * Tweaks for bug 17052: ** Made radio button default selection fallback to the next one for deleted revs ** Use deleted diff message rather than showing an ambiguous "empty diff" * Code style tweaks --- includes/PageHistory.php | 39 ++++++++++++------------------ includes/diff/DifferenceEngine.php | 29 +++++++++++++--------- languages/messages/MessagesEn.php | 2 ++ 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/includes/PageHistory.php b/includes/PageHistory.php index f1e23e31b6..2e44c68dab 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -23,6 +23,8 @@ class PageHistory { var $lastdate; var $linesonpage; var $mLatestId = null; + + private $mOldIdChecked = 0; /** * Construct a new PageHistory. @@ -442,40 +444,29 @@ class PageHistory { * @return string HTML output for the radio buttons */ function diffButtons( $rev, $firstInList, $counter ) { - if( $this->linesonpage > 1) { - $radio = array( - 'type' => 'radio', - 'value' => $rev->getId(), - ); - - if( !$rev->userCan( Revision::DELETED_TEXT ) ) { - $radio['disabled'] = 'disabled'; - } - + if( $this->linesonpage > 1 ) { + $radio = array( 'type' => 'radio', 'value' => $rev->getId() ); /** @todo: move title texts to javascript */ if( $firstInList ) { - $first = Xml::element( 'input', array_merge( - $radio, - array( - 'style' => 'visibility:hidden', - 'name' => 'oldid' ) ) ); + $first = Xml::element( 'input', + array_merge( $radio, array( 'style' => 'visibility:hidden', 'name' => 'oldid' ) ) + ); $checkmark = array( 'checked' => 'checked' ); } else { - if( $counter == 2 ) { + # Check visibility of old revisions + if( !$rev->userCan( Revision::DELETED_TEXT ) ) { + $radio['disabled'] = 'disabled'; + $checkmark = array(); // We will check the next possible one + } else if( $counter == 2 || !$this->mOldIdChecked ) { $checkmark = array( 'checked' => 'checked' ); + $this->mOldIdChecked = $rev->getId(); } else { $checkmark = array(); } - $first = Xml::element( 'input', array_merge( - $radio, - $checkmark, - array( 'name' => 'oldid' ) ) ); + $first = Xml::element( 'input', array_merge( $radio, $checkmark, array( 'name' => 'oldid' ) ) ); $checkmark = array(); } - $second = Xml::element( 'input', array_merge( - $radio, - $checkmark, - array( 'name' => 'diff' ) ) ); + $second = Xml::element( 'input', array_merge( $radio, $checkmark, array( 'name' => 'diff' ) ) ); return $first . $second; } else { return ''; diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index a0848d064a..15035c6e02 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -219,11 +219,10 @@ CONTROL; $oldminor = ''; $newminor = ''; - if ($this->mOldRev->mMinorEdit == 1) { + if( $this->mOldRev->isMinor() ) { $oldminor = Xml::span( wfMsg( 'minoreditletter' ), 'minor' ) . ' '; } - - if ($this->mNewRev->mMinorEdit == 1) { + if( $this->mNewRev->isMinor() ) { $newminor = Xml::span( wfMsg( 'minoreditletter' ), 'minor' ) . ' '; } @@ -263,16 +262,22 @@ CONTROL; '
' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "
" . '
' . $nextlink . $patrol . '
'; - if( $wgEnableHtmlDiff && $this->htmldiff) { + # Output the diff + if( !$this->mOldRev->userCan(Revision::DELETED_TEXT) || !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { + $this->showDiffStyle(); + $multi = $this->getMultiNotice(); + $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) ); + $wgOut->addWikiMsg( 'rev-deleted-no-diff' ); + } else if( $wgEnableHtmlDiff && $this->htmldiff ) { $multi = $this->getMultiNotice(); $wgOut->addHTML('
'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'wikicodecomparison' ), - 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).'
'); + 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).''); $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) ); $this->renderHtmlDiff(); } else { - if($wgEnableHtmlDiff){ + if( $wgEnableHtmlDiff ) { $wgOut->addHTML('
'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'visualcomparison' ), - 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).'
'); + 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).''); } $this->showDiff( $oldHeader, $newHeader ); if( !$diffOnly ) { @@ -290,7 +295,7 @@ CONTROL; wfProfileIn( __METHOD__ ); $wgOut->addHTML( "

{$this->mPagetitle}

\n" ); - #add deleted rev tag if needed + # Add deleted rev tag if needed if( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) { $wgOut->addWikiMsg( 'rev-deleted-text-permission' ); } else if( $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) { @@ -306,9 +311,8 @@ CONTROL; $wgOut->setRevisionId( $this->mNewRev->getId() ); } - if ($this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage()) { + if( $this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage() ) { // Stolen from Article::view --AG 2007-10-11 - // Give hooks a chance to customise the output if( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mTitle, $wgOut ) ) ) { // Wrap the whole lot in a
 and don't parse
@@ -318,8 +322,9 @@ CONTROL;
 				$wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
 				$wgOut->addHTML( "\n
\n" ); } - } else - $wgOut->addWikiTextTidy( $this->mNewtext ); + } else { + $wgOut->addWikiTextTidy( $this->mNewtext ); + } if( !$this->mNewRev->isCurrent() ) { $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 8383620750..8b3dff9cc9 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1291,6 +1291,8 @@ There may be details in the [{{fullurl:Special:Log/delete|page={{FULLPAGENAMEE}} This page revision has been removed from the public archives. As an administrator on {{SITENAME}} you can view it; there may be details in the [{{fullurl:Special:Log/delete|page={{FULLPAGENAMEE}}}} deletion log].', +'rev-deleted-no-diff' => '', 'rev-delundel' => 'show/hide', 'revisiondelete' => 'Delete/undelete revisions', 'revdelete-nooldid-title' => 'Invalid target revision', -- 2.20.1