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
21 namespace MediaWiki\Specials
;
23 use MediaWiki\HTMLForm\HTMLForm
;
24 use MediaWiki\SpecialPage\RedirectSpecialPage
;
25 use MediaWiki\Title\Title
;
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
= [];
39 * @param string|null $subpage
42 public function getRedirect( $subpage ) {
43 $subpage = intval( $subpage );
44 if ( $subpage === 0 ) {
47 $this->mAddedRedirectParams
['oldid'] = $subpage;
52 protected function showNoRedirectPage() {
53 $this->addHelpLink( 'Help:PermanentLink' );
55 $this->outputHeader();
59 private function showForm() {
60 HTMLForm
::factory( 'ooui', [
64 'label-message' => 'permanentlink-revid',
66 ], $this->getContext(), 'permanentlink' )
67 ->setSubmitTextMsg( 'permanentlink-submit' )
68 ->setSubmitCallback( [ $this, 'onFormSubmit' ] )
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() {
83 protected function getGroupName() {
89 * Retain the old class name for backwards compatibility.
90 * @deprecated since 1.41
92 class_alias( SpecialPermanentLink
::class, 'SpecialPermanentLink' );