Allow easy suppression of multiple deleted revs
authorLuke Faraone <luke@faraone.cc>
Sun, 13 Dec 2015 20:50:17 +0000 (20:50 +0000)
committerLuke Faraone <luke@faraone.cc>
Tue, 9 Feb 2016 03:05:18 +0000 (03:05 +0000)
Add checkboxes to revisisons on Special:Undelete, with an accompanying button
to submit the form.

Handle the form submission and redirect to the appropriate
Special:RevisionDelete page.

Bug: T22189
Co-Authored-By: Rohan <rohan1395@yahoo.com>
Change-Id: I2a0a53c3b5ae2145472e4b5a3d3cf61bd3cf4f28

includes/specials/SpecialUndelete.php
languages/i18n/en.json
languages/i18n/qqq.json

index aada064..570b336 100644 (file)
@@ -667,13 +667,14 @@ class PageArchive {
  * @ingroup SpecialPage
  */
 class SpecialUndelete extends SpecialPage {
-       private $mAction;
+       private $mAction;
        private $mTarget;
        private $mTimestamp;
        private $mRestore;
+       private $mRevdel;
        private $mInvert;
        private $mFilename;
-       private $mTargetTimestamp;
+       private $mTargetTimestamp;
        private $mAllowed;
        private $mCanView;
        private $mComment;
@@ -711,6 +712,7 @@ class SpecialUndelete extends SpecialPage {
                $posted = $request->wasPosted() &&
                        $user->matchEditToken( $request->getVal( 'wpEditToken' ) );
                $this->mRestore = $request->getCheck( 'restore' ) && $posted;
+               $this->mRevdel = $request->getCheck( 'revdel' ) && $posted;
                $this->mInvert = $request->getCheck( 'invert' ) && $posted;
                $this->mPreview = $request->getCheck( 'preview' ) && $posted;
                $this->mDiff = $request->getCheck( 'diff' );
@@ -823,13 +825,42 @@ class SpecialUndelete extends SpecialPage {
                        } else {
                                $this->showFile( $this->mFilename );
                        }
-               } elseif ( $this->mRestore && $this->mAction == 'submit' ) {
-                       $this->undelete();
+               } elseif ( $this->mAction === "submit" ) {
+                       if ( $this->mRestore ) {
+                               $this->undelete();
+                       } elseif ( $this->mRevdel ) {
+                               $this->redirectToRevDel();
+                       }
+
                } else {
                        $this->showHistory();
                }
        }
 
+       /**
+        * Convert submitted form data to format expected by RevisionDelete and
+        * redirect the request
+        */
+       private function redirectToRevDel() {
+               $archive = new PageArchive( $this->mTargetObj );
+
+               $revisions = array();
+
+               foreach ( $this->getRequest()->getValues() as $key => $val ) {
+                       $matches = array();
+                       if ( preg_match( "/^ts(\d{14})$/", $key, $matches ) ) {
+                               $revisions[ $archive->getRevision( $matches[1] )->getId() ] = 1;
+                       }
+               }
+               $query = array(
+                       "type" => "revision",
+                       "ids" => $revisions,
+                       "target" => wfUrlencode( $this->mTargetObj->getPrefixedText() )
+               );
+               $url = SpecialPage::getTitleFor( "RevisionDelete" )->getFullURL( $query );
+               $this->getOutput()->redirect( $url );
+       }
+
        function showSearchForm() {
                $out = $this->getOutput();
                $out->setPageTitle( $this->msg( 'undelete-search-title' ) );
@@ -1348,7 +1379,20 @@ class SpecialUndelete extends SpecialPage {
                $out->addHTML( Xml::element( 'h2', null, $this->msg( 'history' )->text() ) . "\n" );
 
                if ( $haveRevisions ) {
-                       # The page's stored (deleted) history:
+                       # Show the page's stored (deleted) history
+
+                       if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
+                               $out->addHTML( Html::element(
+                                       'button',
+                                       array(
+                                               'name' => 'revdel',
+                                               'type' => 'submit',
+                                               'class' => 'deleterevision-log-submit mw-log-deleterevision-button'
+                                       ),
+                                       $this->msg( 'showhideselectedversions' )->text()
+                               ) . "\n" );
+                       }
+
                        $out->addHTML( '<ul>' );
                        $remaining = $revisions->numRows();
                        $earliestLiveTime = $this->mTargetObj->getEarliestRevTime();
@@ -1458,13 +1502,9 @@ class SpecialUndelete extends SpecialPage {
                        $attribs['class'] = implode( ' ', $classes );
                }
 
-               // Revision delete links
-               $revdlink = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj );
-
-               $revisionRow = $this->msg( 'undelete-revision-row' )
+               $revisionRow = $this->msg( 'undelete-revision-row2' )
                        ->rawParams(
                                $checkBox,
-                               $revdlink,
                                $last,
                                $pageLink,
                                $userLink,
index 0c72d77..abfa508 100644 (file)
        "undelete-error-long": "Errors were encountered while undeleting the file:\n\n$1",
        "undelete-show-file-confirm": "Are you sure you want to view the deleted revision of the file \"<nowiki>$1</nowiki>\" from $2 at $3?",
        "undelete-show-file-submit": "Yes",
-       "undelete-revision-row": "$1 $2 ($3) $4 . . $5 $6 $7 $8 $9",
+       "undelete-revision-row2": "$1 ($2) $3 . . $4 $5 $6 $7 $8",
        "namespace": "Namespace:",
        "invert": "Invert selection",
        "tooltip-invert": "Check this box to hide changes to pages within the selected namespace (and the associated namespace if checked)",
index 329e901..ad80282 100644 (file)
        "undelete-error-long": "Used as error message. Parameters:\n* $1 - ...\nSee also:\n* {{msg-mw|Undelete-error-short}}",
        "undelete-show-file-confirm": "A confirmation message shown on [[Special:Undelete]] when the request does not contain a valid token (e.g. when a user clicks a link received in mail).\n\nParameters:\n* $1 - the name of the file being undeleted\n* $2 - the date of the displayed revision\n* $3 - the time of the displayed revision\n{{Identical|Are you sure you want to view the deleted revision of the file...}}",
        "undelete-show-file-submit": "{{Identical|Yes}}",
-       "undelete-revision-row": "{{Optional}}\nA revision row in the undelete page. Parameters:\n* $1 is a checkBox to indicate whether to restore this specific revision\n* $2 is a link to the revision\n* $3 is a link to the last revision of a page ({{msg-mw|last}})\n* $4 is a link to the page\n* $5 is a link to the revision's user\n* $6 is the revision's minor edit identifier\n* $7 is the revision size\n* $8 is the revision comment\n* $9 is the revision's tags",
+       "undelete-revision-row2": "{{Optional}}\nA revision row in the undelete page. Parameters:\n* $1 is a checkBox to indicate whether to restore this specific revision\n* $2 is a link to the last revision of a page ({{msg-mw|last}})\n* $3 is a link to the page\n* $4 is a link to the revision's user\n* $5 is the revision's minor edit identifier\n* $6 is the revision size\n* $7 is the revision comment\n* $8 is the revision's tags",
        "namespace": "This message is located at [[Special:Contributions]].\n{{Identical|Namespace}}",
        "invert": "Displayed in [[Special:RecentChanges|RecentChanges]], [[Special:RecentChangesLinked|RecentChangesLinked]] and [[Special:Watchlist|Watchlist]].\n\nThis message means \"Invert selection of namespace\".\n\nThis message has a tooltip {{msg-mw|tooltip-invert}}\n{{Identical|Invert selection}}",
        "tooltip-invert": "Used in [[Special:Recentchanges]] as a tooltip for the invert checkbox. See also the message {{msg-mw|invert}}",