Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/118744

Change subject: Explain deleted Revisions
......................................................................

Explain deleted Revisions

The DifferenceEngine in core could do with a huge refactor to
allow better reusability by inheriting classes.

This breaks out a lot of the functions into separate functions
If Max is happy with these changes, I will write a patch trying
to make them part of DifferenceEngine.php itself.

Bug: 62553
Change-Id: I3ecce8b06afe7846ff2c17b83517edce4234a2cd
---
M includes/diff/InlineDifferenceEngine.php
M includes/specials/SpecialMobileDiff.php
2 files changed, 63 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/44/118744/1

diff --git a/includes/diff/InlineDifferenceEngine.php 
b/includes/diff/InlineDifferenceEngine.php
index f5f4eba..7fe30c0 100644
--- a/includes/diff/InlineDifferenceEngine.php
+++ b/includes/diff/InlineDifferenceEngine.php
@@ -1,6 +1,59 @@
 <?php
 
 class InlineDifferenceEngine extends DifferenceEngine {
+       // FIXME: Upstream to DifferenceEngine - refactor showDiffPage
+       public function isDeletedDiff() {
+               return $this->mNewRev->isDeleted( Revision::DELETED_TEXT );
+       }
+
+       // FIXME: Upstream to DifferenceEngine - refactor showDiffPage
+       public function isSuppressedDiff() {
+               return $this->isDeletedDiff() &&
+                       $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED 
);
+       }
+
+       // FIXME: Upstream to DifferenceEngine - refactor showDiffPage
+       public function isUserAllowedToSee() {
+               $user = $this->getUser();
+               $allowed = $this->mNewRev->userCan( Revision::DELETED_TEXT, 
$user );
+               if ( $this->mOldRev &&
+                       !$this->mOldRev->userCan( Revision::DELETED_TEXT, $user 
)
+               ) {
+                       $allowed = false;
+               }
+               return $allowed;
+       }
+
+       // FIXME: Upstream to DifferenceEngine - refactor showDiffPage
+       public function isHiddenFromUser() {
+               if ( $this->isDeletedDiff() && ( !$this->unhide || 
!$this->isUserAllowedToSee() ) ) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       // FIXME: Upstream to DifferenceEngine - refactor showDiffPage
+       public function getWarningMessageText() {
+               $msg = '';
+               if ( $this->isHiddenFromUser() ) {
+                       $allowed = $this->isUserAllowedToSee();
+                       $suppressed = $this->isSuppressedDiff();
+
+                       if ( !$allowed ) {
+                               $msg = $suppressed ? 'rev-suppressed-no-diff' : 
'rev-deleted-no-diff';
+                               $msg = wfMessage( $msg )->parse();
+                       } else {
+                               # Give explanation and add a link to view the 
diff...
+                               $query = $this->getRequest()->appendQueryValue( 
'unhide', '1', true );
+                               $link = $this->getTitle()->getFullURL( $query );
+                               $msg = $suppressed ? 
'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
+                               $msg = wfMessage( $msg, $link )->parse();
+                       }
+               }
+               return $msg;
+       }
+
        function generateTextDiffBody( $otext, $ntext ) {
                global $wgContLang;
 
diff --git a/includes/specials/SpecialMobileDiff.php 
b/includes/specials/SpecialMobileDiff.php
index b38f8a9..3e15e52 100644
--- a/includes/specials/SpecialMobileDiff.php
+++ b/includes/specials/SpecialMobileDiff.php
@@ -157,7 +157,17 @@
                } else {
                        $diff = '<ins>' . htmlspecialchars( 
$this->rev->getText() ) . '</ins>';
                }
+               $warnings = $de->getWarningMessageText();
+               if ( $warnings ) {
+                       $warnings = Html::openElement( 'div',
+                               array(
+                                       'class' => 'warning alert',
+                               ) ) .
+                               $warnings .
+                               Html::closeElement( 'div' );
+               }
                $this->getOutput()->addHtml(
+                       $warnings .
                        '<div id="mw-mf-minidiff">' .
                        $diff .
                        '</div>'

-- 
To view, visit https://gerrit.wikimedia.org/r/118744
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ecce8b06afe7846ff2c17b83517edce4234a2cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to