Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / specials / SpecialPermanentLink.php
blob9423d090ed6b7409a37c555993db85b834ff258f
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
21 namespace MediaWiki\Specials;
23 use MediaWiki\HTMLForm\HTMLForm;
24 use MediaWiki\SpecialPage\RedirectSpecialPage;
25 use MediaWiki\Title\Title;
27 /**
28 * Redirect from Special:PermanentLink/### to index.php?oldid=###.
30 * @ingroup SpecialPage
32 class SpecialPermanentLink extends RedirectSpecialPage {
33 public function __construct() {
34 parent::__construct( 'PermanentLink' );
35 $this->mAllowedRedirectParams = [];
38 /**
39 * @param string|null $subpage
40 * @return Title|bool
42 public function getRedirect( $subpage ) {
43 $subpage = intval( $subpage );
44 if ( $subpage === 0 ) {
45 return false;
47 $this->mAddedRedirectParams['oldid'] = $subpage;
49 return true;
52 protected function showNoRedirectPage() {
53 $this->addHelpLink( 'Help:PermanentLink' );
54 $this->setHeaders();
55 $this->outputHeader();
56 $this->showForm();
59 private function showForm() {
60 HTMLForm::factory( 'ooui', [
61 'revid' => [
62 'type' => 'int',
63 'name' => 'revid',
64 'label-message' => 'permanentlink-revid',
66 ], $this->getContext(), 'permanentlink' )
67 ->setSubmitTextMsg( 'permanentlink-submit' )
68 ->setSubmitCallback( [ $this, 'onFormSubmit' ] )
69 ->show();
72 public function onFormSubmit( $formData ) {
73 $revid = $formData['revid'];
74 $title = $this->getPageTitle( $revid ?: null );
75 $url = $title->getFullUrlForRedirect();
76 $this->getOutput()->redirect( $url );
79 public function isListed() {
80 return true;
83 protected function getGroupName() {
84 return 'redirects';
88 /**
89 * Retain the old class name for backwards compatibility.
90 * @deprecated since 1.41
92 class_alias( SpecialPermanentLink::class, 'SpecialPermanentLink' );