X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialPermanentLink.php;h=53789c0da68b11b5c717b8c26161f414080571c1;hb=16c80e429be5904fb42a93f260f8de3d18f0c692;hp=6c2ffe906d0e030f24d2da482b33b1ee76df53d0;hpb=d4eefca4dd645bbef2b435ef1228a141f6a48e67;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialPermanentLink.php b/includes/specials/SpecialPermanentLink.php index 6c2ffe906d..b1772b78e3 100644 --- a/includes/specials/SpecialPermanentLink.php +++ b/includes/specials/SpecialPermanentLink.php @@ -27,18 +27,56 @@ * @ingroup SpecialPage */ class SpecialPermanentLink extends RedirectSpecialPage { - function __construct() { + public function __construct() { parent::__construct( 'PermanentLink' ); - $this->mAllowedRedirectParams = array(); + $this->mAllowedRedirectParams = []; } - function getRedirect( $subpage ) { + /** + * @param string|null $subpage + * @return Title|bool + */ + 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'; + } }