MediaWiki REL1_40
SpecialPermanentLink.php
Go to the documentation of this file.
1<?php
25
32 public function __construct() {
33 parent::__construct( 'PermanentLink' );
34 $this->mAllowedRedirectParams = [];
35 }
36
41 public function getRedirect( $subpage ) {
42 $subpage = intval( $subpage );
43 if ( $subpage === 0 ) {
44 return false;
45 }
46 $this->mAddedRedirectParams['oldid'] = $subpage;
47
48 return true;
49 }
50
51 protected function showNoRedirectPage() {
52 $this->addHelpLink( 'Help:PermanentLink' );
53 $this->setHeaders();
54 $this->outputHeader();
55 $this->showForm();
56 }
57
58 private function showForm() {
59 HTMLForm::factory( 'ooui', [
60 'revid' => [
61 'type' => 'int',
62 'name' => 'revid',
63 'label-message' => 'permanentlink-revid',
64 ],
65 ], $this->getContext(), 'permanentlink' )
66 ->setSubmitTextMsg( 'permanentlink-submit' )
67 ->setSubmitCallback( [ $this, 'onFormSubmit' ] )
68 ->show();
69 }
70
71 public function onFormSubmit( $formData ) {
72 $revid = $formData['revid'];
73 $title = $this->getPageTitle( $revid ?: null );
74 $url = $title->getFullUrlForRedirect();
75 $this->getOutput()->redirect( $url );
76 }
77
78 public function isListed() {
79 return true;
80 }
81
82 protected function getGroupName() {
83 return 'redirects';
84 }
85}
Represents a title within MediaWiki.
Definition Title.php:82
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.