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