MediaWiki master
SpecialPermanentLink.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
12
19 public function __construct() {
20 parent::__construct( 'PermanentLink' );
21 $this->mAllowedRedirectParams = [];
22 }
23
28 public function getRedirect( $subpage ) {
29 $subpage = intval( $subpage );
30 if ( $subpage === 0 ) {
31 return false;
32 }
33 $this->mAddedRedirectParams['oldid'] = $subpage;
34
35 return true;
36 }
37
38 protected function showNoRedirectPage() {
39 $this->addHelpLink( 'Help:PermanentLink' );
40 $this->setHeaders();
41 $this->outputHeader();
42 $this->showForm();
43 }
44
45 private function showForm() {
46 HTMLForm::factory( 'ooui', [
47 'revid' => [
48 'type' => 'int',
49 'name' => 'revid',
50 'label-message' => 'permanentlink-revid',
51 ],
52 ], $this->getContext(), 'permanentlink' )
53 ->setSubmitTextMsg( 'permanentlink-submit' )
54 ->setSubmitCallback( $this->onFormSubmit( ... ) )
55 ->show();
56 }
57
61 private function onFormSubmit( $formData ) {
62 $revid = $formData['revid'];
63 $title = $this->getPageTitle( $revid ?: null );
64 $url = $title->getFullUrlForRedirect();
65 $this->getOutput()->redirect( $url );
66 }
67
69 public function isListed() {
70 return true;
71 }
72
74 protected function getGroupName() {
75 return 'redirects';
76 }
77}
78
83class_alias( SpecialPermanentLink::class, 'SpecialPermanentLink' );
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:195
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:69