* Tweaks for bug 17052:
authorAaron Schulz <aaron@users.mediawiki.org>
Mon, 9 Feb 2009 07:42:54 +0000 (07:42 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Mon, 9 Feb 2009 07:42:54 +0000 (07:42 +0000)
** 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
includes/diff/DifferenceEngine.php
languages/messages/MessagesEn.php

index f1e23e3..2e44c68 100644 (file)
@@ -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 '';
index a0848d0..15035c6 100644 (file)
@@ -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;
                        '<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "</div>" .
                        '<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';
 
-               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('<div class="diff-switchtype">'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'wikicodecomparison' ),
-                       'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).'</div>');
+                               'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).'</div>');
                        $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) );
                        $this->renderHtmlDiff();
                } else {
-                       if($wgEnableHtmlDiff){
+                       if( $wgEnableHtmlDiff ) {
                                $wgOut->addHTML('<div class="diff-switchtype">'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'visualcomparison' ),
-                               'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).'</div>');
+                                       'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).'</div>');
                        }
                        $this->showDiff( $oldHeader, $newHeader );
                        if( !$diffOnly ) {
@@ -290,7 +295,7 @@ CONTROL;
                wfProfileIn( __METHOD__ );
 
                $wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\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 <pre> and don't parse
@@ -318,8 +322,9 @@ CONTROL;
                                $wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
                                $wgOut->addHTML( "\n</pre>\n" );
                        }
-               } else
-               $wgOut->addWikiTextTidy( $this->mNewtext );
+               } else {
+                       $wgOut->addWikiTextTidy( $this->mNewtext );
+               }
 
                if( !$this->mNewRev->isCurrent() ) {
                        $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
index 8383620..8b3dff9 100644 (file)
@@ -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].</div>',
+'rev-deleted-no-diff'            => '<div class="mw-warning plainlinks">You cannot view this diff because one of the revisions has been removed from the public archives.
+There may be details in the [{{fullurl:Special:Log/delete|page={{FULLPAGENAMEE}}}} deletion log].</div>',
 'rev-delundel'                   => 'show/hide',
 'revisiondelete'                 => 'Delete/undelete revisions',
 'revdelete-nooldid-title'        => 'Invalid target revision',