Merge "Document Special:Diff and Special:PermanentLink"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 10 Aug 2017 18:22:31 +0000 (18:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 10 Aug 2017 18:22:32 +0000 (18:22 +0000)
includes/specialpage/RedirectSpecialPage.php
includes/specials/SpecialDiff.php
includes/specials/SpecialPermanentLink.php
languages/i18n/en.json
languages/i18n/qqq.json

index 9b5d5f4..4e5da97 100644 (file)
@@ -52,8 +52,7 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
 
                        return $redirect;
                } else {
-                       $class = static::class;
-                       throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
+                       $this->showNoRedirectPage();
                }
        }
 
@@ -106,6 +105,11 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
        public function personallyIdentifiableTarget() {
                return false;
        }
+       
+       protected function showNoRedirectPage() {
+               $class = static::class;
+               throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
+       }
 }
 
 /**
index 9804e77..28cd0d1 100644 (file)
@@ -56,11 +56,64 @@ class SpecialDiff extends RedirectSpecialPage {
                        $this->mAddedRedirectParams['oldid'] = $parts[0];
                        $this->mAddedRedirectParams['diff'] = $parts[1];
                } else {
-                       // Wrong number of parameters, bail out
-                       $this->addHelpLink( 'Help:Diff' );
-                       throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
+                       return false;
                }
 
                return true;
        }
+
+       protected function showNoRedirectPage() {
+               $this->addHelpLink( 'Help:Diff' );
+               $this->setHeaders();
+               $this->outputHeader();
+               $this->showForm();
+       }
+
+       private function showForm() {
+               $form = HTMLForm::factory( 'ooui', [
+                       'oldid' => [
+                               'name' => 'oldid',
+                               'type' => 'int',
+                               'label-message' => 'diff-form-oldid',
+                       ],
+                       'diff' => [
+                               'name' => 'diff',
+                               'class' => 'HTMLTextField',
+                               'label-message' => 'diff-form-revid',
+                       ],
+               ], $this->getContext(), 'diff-form' );
+               $form->setSubmitTextMsg( 'diff-form-submit' );
+               $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
+               $form->show();
+       }
+
+       public function onFormSubmit( $formData ) {
+               $params = [];
+               if ( $formData['oldid'] ) {
+                       $params[] = $formData['oldid'];
+               }
+               if ( $formData['diff'] ) {
+                       $params[] = $formData['diff'];
+               }
+               $title = $this->getPageTitle( $params ? implode( '/', $params ) : null );
+               $url = $title->getFullUrlForRedirect();
+               $this->getOutput()->redirect( $url );
+       }
+
+       public function getDescription() {
+               // 'diff' message is in lowercase, using own message
+               return $this->msg( 'diff-form' )->text();
+       }
+
+       public function getName() {
+               return 'diff-form';
+       }
+
+       public function isListed() {
+               return true;
+       }
+
+       protected function getGroupName() {
+               return 'redirects';
+       }
 }
index 2bd3ab7..b1772b7 100644 (file)
@@ -39,11 +39,44 @@ class SpecialPermanentLink extends RedirectSpecialPage {
        public function getRedirect( $subpage ) {
                $subpage = intval( $subpage );
                if ( $subpage === 0 ) {
-                       # throw an error page when no subpage was given
-                       throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
+                       return false;
                }
                $this->mAddedRedirectParams['oldid'] = $subpage;
 
                return true;
        }
+
+       protected function showNoRedirectPage() {
+               $this->setHeaders();
+               $this->outputHeader();
+               $this->showForm();
+       }
+
+       private function showForm() {
+               $form = HTMLForm::factory( 'ooui', [
+                       'revid' => [
+                               'type' => 'int',
+                               'name' => 'revid',
+                               'label-message' => 'permanentlink-revid',
+                       ],
+               ], $this->getContext(), 'permanentlink' );
+               $form->setSubmitTextMsg( 'permanentlink-submit' );
+               $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
+               $form->show();
+       }
+
+       public function onFormSubmit( $formData ) {
+               $revid = $formData['revid'];
+               $title = $this->getPageTitle( $revid ?: null );
+               $url = $title->getFullUrlForRedirect();
+               $this->getOutput()->redirect( $url );
+       }
+
+       public function isListed() {
+               return true;
+       }
+
+       protected function getGroupName() {
+               return 'redirects';
+       }
 }
index 61a113e..86ac78e 100644 (file)
        "compare-invalid-title": "The title you specified is invalid.",
        "compare-title-not-exists": "The title you specified does not exist.",
        "compare-revision-not-exists": "The revision you specified does not exist.",
+       "diff-form": "Differences",
+       "diff-form-oldid": "Old revision ID (optional)",
+       "diff-form-revid": "Revision ID of difference",
+       "diff-form-submit": "Show differences",
+       "diff-form-summary": "",
+       "permanentlink": "Permanent link",
+       "permanentlink-revid": "Revision ID",
+       "permanentlink-submit": "Go to revision",
+       "permanentlink-summary": "",
        "dberr-problems": "Sorry! This site is experiencing technical difficulties.",
        "dberr-again": "Try waiting a few minutes and reloading.",
        "dberr-info": "(Cannot access the database: $1)",
index 7be71f0..62b4d66 100644 (file)
        "compare-invalid-title": "Used as error message in [[Special:ComparePages]].",
        "compare-title-not-exists": "Used as error message in [[Special:ComparePages]].",
        "compare-revision-not-exists": "Used as error message in [[Special:ComparePages]].",
+       "permanentlink": "The title of [[Special:PermanentLink]]",
+       "permanentlink-revid": "Label for the field for the revision ID in [[Special:PermanentLink]]",
+       "permanentlink-submit": "Submit button on [[Special:PermanentLink]]",
+       "permanentlink-summary": "{{doc-specialpagesummary|permanentlink}}",
+       "diff-form": "The title of [[Special:Diff]]",
+       "diff-form-summary": "{{doc-specialpagesummary|diff}}",
+       "diff-form-oldid": "Label for the field of the old revision in the comparison for [[Special:Diff]]",
+       "diff-form-revid": "Label for the field of the new revision in the comparison for [[Special:Diff]]",
+       "diff-form-submit": "Submit button on [[Special:Diff]]",
        "dberr-problems": "This message does not allow any wiki nor html markup.",
        "dberr-again": "This message does not allow any wiki nor html markup.",
        "dberr-info": "This message does not allow any wiki nor html markup. Parameters:\n* $1 - database server name\nSee also:\n* {{msg-mw|Dberr-info-hidden}} - hides database server name",