MediaWiki master
SpecialPermanentLink.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
26
33 public function __construct() {
34 parent::__construct( 'PermanentLink' );
35 $this->mAllowedRedirectParams = [];
36 }
37
42 public function getRedirect( $subpage ) {
43 $subpage = intval( $subpage );
44 if ( $subpage === 0 ) {
45 return false;
46 }
47 $this->mAddedRedirectParams['oldid'] = $subpage;
48
49 return true;
50 }
51
52 protected function showNoRedirectPage() {
53 $this->addHelpLink( 'Help:PermanentLink' );
54 $this->setHeaders();
55 $this->outputHeader();
56 $this->showForm();
57 }
58
59 private function showForm() {
60 HTMLForm::factory( 'ooui', [
61 'revid' => [
62 'type' => 'int',
63 'name' => 'revid',
64 'label-message' => 'permanentlink-revid',
65 ],
66 ], $this->getContext(), 'permanentlink' )
67 ->setSubmitTextMsg( 'permanentlink-submit' )
68 ->setSubmitCallback( [ $this, 'onFormSubmit' ] )
69 ->show();
70 }
71
72 public function onFormSubmit( $formData ) {
73 $revid = $formData['revid'];
74 $title = $this->getPageTitle( $revid ?: null );
75 $url = $title->getFullUrlForRedirect();
76 $this->getOutput()->redirect( $url );
77 }
78
79 public function isListed() {
80 return true;
81 }
82
83 protected function getGroupName() {
84 return 'redirects';
85 }
86}
87
92class_alias( SpecialPermanentLink::class, 'SpecialPermanentLink' );
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:208
Shortcut to construct a special page alias.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getPageTitle( $subpage=false)
Get a self-referential title object.
getContext()
Gets the context this SpecialPage is executed in.
getOutput()
Get the OutputPage being used for this instance.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages By default the message key is the canonical name of...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Represents a title within MediaWiki.
Definition Title.php:79