MediaWiki REL1_39
SpecialPermanentLink.php
Go to the documentation of this file.
1<?php
30 public function __construct() {
31 parent::__construct( 'PermanentLink' );
32 $this->mAllowedRedirectParams = [];
33 }
34
39 public function getRedirect( $subpage ) {
40 $subpage = intval( $subpage );
41 if ( $subpage === 0 ) {
42 return false;
43 }
44 $this->mAddedRedirectParams['oldid'] = $subpage;
45
46 return true;
47 }
48
49 protected function showNoRedirectPage() {
50 $this->addHelpLink( 'Help:PermanentLink' );
51 $this->setHeaders();
52 $this->outputHeader();
53 $this->showForm();
54 }
55
56 private function showForm() {
57 HTMLForm::factory( 'ooui', [
58 'revid' => [
59 'type' => 'int',
60 'name' => 'revid',
61 'label-message' => 'permanentlink-revid',
62 ],
63 ], $this->getContext(), 'permanentlink' )
64 ->setSubmitTextMsg( 'permanentlink-submit' )
65 ->setSubmitCallback( [ $this, 'onFormSubmit' ] )
66 ->show();
67 }
68
69 public function onFormSubmit( $formData ) {
70 $revid = $formData['revid'];
71 $title = $this->getPageTitle( $revid ?: null );
72 $url = $title->getFullUrlForRedirect();
73 $this->getOutput()->redirect( $url );
74 }
75
76 public function isListed() {
77 return true;
78 }
79
80 protected function getGroupName() {
81 return 'redirects';
82 }
83}
Shortcut to construct a special page alias.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
getPageTitle( $subpage=false)
Get a self-referential title object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.