From 8c74d4b938a85b03183d9fc16841a273f10328de Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 25 Oct 2009 15:27:49 +0000 Subject: [PATCH] Added deleted diff notice for unhide=1 urls to be clear and consistent --- includes/diff/DifferenceInterface.php | 48 ++++++++++++++++++--------- languages/messages/MessagesEn.php | 4 +++ maintenance/language/messages.inc | 2 ++ 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/includes/diff/DifferenceInterface.php b/includes/diff/DifferenceInterface.php index 82b62086a3..259bef961f 100644 --- a/includes/diff/DifferenceInterface.php +++ b/includes/diff/DifferenceInterface.php @@ -318,6 +318,7 @@ CONTROL; } $rdel = ''; $ldel = ''; + # Handle RevisionDelete links... if( $wgUser->isAllowed( 'deletedhistory' ) ) { // Don't show useless link to people who cannot hide revisions if( $this->mOldRev->getVisibility() || $wgUser->isAllowed( 'deleterevision' ) ) { @@ -376,7 +377,8 @@ CONTROL; if( $this->mNewRev->isDeleted(Revision::DELETED_RESTRICTED) ) $suppressed = true; // also suppressed } - # Output the diff if allowed... + # If the diff cannot be shown due to a deleted revision, then output + # the diff header and links to unhide (if available)... if( $deleted && (!$this->unhide || !$allowed) ) { $this->showDiffStyle(); $multi = $this->getMultiNotice(); @@ -395,6 +397,7 @@ CONTROL; $msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff'; $wgOut->wrapWikiMsg( "\n", array( $msg, $link ) ); } + # Otherwise, output the HTML diff if requested... } else if( $wgEnableHtmlDiff && $this->htmldiff ) { $multi = $this->getMultiNotice(); $wgOut->addHTML( '
' . $sk->link( @@ -414,27 +417,34 @@ CONTROL; ) ) . '
'); $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) ); + # Add deletion notice if the user is viewing deleted content + if( $deleted ) { + $msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view'; + $wgOut->wrapWikiMsg( "\n", $msg ); + } $this->renderHtmlDiff(); + # Otherwise, output a regular diff... } else { if( $wgEnableHtmlDiff ) { $wgOut->addHTML( '
' . $sk->link( $this->mTitle, wfMsgHtml( 'visualcomparison' ), - array( - 'id' => 'differences-switchtype' - ), + array( 'id' => 'differences-switchtype' ), array( 'diff' => $this->mNewid, 'oldid' => $this->mOldid, 'htmldiff' => 1 ), - array( - 'known', - 'noclasses' - ) + array( 'known', 'noclasses' ) ) . '
'); } - $this->showDiff( $oldHeader, $newHeader ); + # Add deletion notice if the user is viewing deleted content + $notice = ''; + if( $deleted ) { + $msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view'; + $notice = "\n"; + } + $this->showDiff( $oldHeader, $newHeader, $notice ); if( !$diffOnly ) { $this->renderNewRevision(); } @@ -651,9 +661,9 @@ CONTROL; * Get the diff text, send it to $wgOut * Returns false if the diff could not be generated, otherwise returns true */ - function showDiff( $otitle, $ntitle ) { + function showDiff( $otitle, $ntitle, $notice = '' ) { global $wgOut; - $diff = $this->getDiff( $otitle, $ntitle ); + $diff = $this->getDiff( $otitle, $ntitle, $notice ); if ( $diff === false ) { $wgOut->addWikiMsg( 'missing-article', "(fixme, bug)", '' ); return false; @@ -680,15 +690,16 @@ CONTROL; * * @param Title $otitle Old title * @param Title $ntitle New title + * @param string $notice HTML between diff header and body * @return mixed */ - function getDiff( $otitle, $ntitle ) { + function getDiff( $otitle, $ntitle, $notice = '' ) { $body = $this->getDiffBody(); if ( $body === false ) { return false; } else { $multi = $this->getMultiNotice(); - return $this->addHeader( $body, $otitle, $ntitle, $multi ); + return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice ); } } @@ -911,8 +922,7 @@ CONTROL; /** * Add the header to a diff body */ - static function addHeader( $diff, $otitle, $ntitle, $multi = '' ) { - $colspan = 1; + static function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) { $header = ""; if( $diff ) { // Safari/Chrome show broken output if cols not used $header .= " @@ -921,6 +931,10 @@ CONTROL; "; $colspan = 2; + $multiColspan = 4; + } else { + $colspan = 1; + $multiColspan = 2; } $header .= " @@ -929,9 +943,11 @@ CONTROL; "; if ( $multi != '' ) { - $multiColspan = $diff ? 4 : 2; $header .= ""; } + if ( $notice != '' ) { + $header .= ""; + } return $header . $diff . "
{$multi}
{$notice}
"; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ddd5495296..0ec521c47e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1445,6 +1445,10 @@ As an administrator you can still [$1 view this diff] if you wish to proceed.", 'rev-suppressed-unhide-diff' => "One of the revisions of this diff has been '''suppressed'''. There may be details in the [{{fullurl:{{#Special:Log}}/suppress|page={{FULLPAGENAMEE}}}} suppression log]. As an administrator you can still [$1 view this diff] if you wish to proceed.", +'rev-deleted-diff-view' => "One of the revisions of this diff has been '''deleted'''. +As an administrator you can view this diff; there may be details in the [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} deletion log].", +'rev-suppressed-diff-view' => "One of the revisions of this diff has been '''suppressed'''. +As an administrator you can view this diff; there may be details in the [{{fullurl:{{#Special:Log}}/suppress|page={{FULLPAGENAMEE}}}} suppression log].", 'rev-delundel' => 'show/hide', 'revisiondelete' => 'Delete/undelete revisions', 'revdelete-nooldid-title' => 'Invalid target revision', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 5c76bede88..990f364368 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -665,6 +665,8 @@ $wgMessageStructure = array( 'rev-deleted-no-diff', 'rev-deleted-unhide-diff', 'rev-suppressed-unhide-diff', + 'rev-deleted-diff-view', + 'rev-suppressed-diff-view', 'rev-delundel', 'revisiondelete', 'revdelete-nooldid-title', -- 2.20.1