X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPermanentLink.php;h=71b505aa79170b1da47eab5e11b802cf30cdb056;hp=53789c0da68b11b5c717b8c26161f414080571c1;hb=dfec83932fd38a9086eb5a2e212889ad00f35b0e;hpb=012248fc5a7d6d0257df1a0feadbda5ae4a477e2 diff --git a/includes/specials/SpecialPermanentLink.php b/includes/specials/SpecialPermanentLink.php index 53789c0da6..71b505aa79 100644 --- a/includes/specials/SpecialPermanentLink.php +++ b/includes/specials/SpecialPermanentLink.php @@ -29,7 +29,7 @@ class SpecialPermanentLink extends RedirectSpecialPage { public function __construct() { parent::__construct( 'PermanentLink' ); - $this->mAllowedRedirectParams = array(); + $this->mAllowedRedirectParams = []; } /** @@ -39,11 +39,45 @@ 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->addHelpLink( 'Help:PermanentLink' ); + $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'; + } }