MediaWiki  1.34.0
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  $form = HTMLForm::factory( 'ooui', [
58  'revid' => [
59  'type' => 'int',
60  'name' => 'revid',
61  'label-message' => 'permanentlink-revid',
62  ],
63  ], $this->getContext(), 'permanentlink' );
64  $form->setSubmitTextMsg( 'permanentlink-submit' );
65  $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
66  $form->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 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:672
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:719
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:29
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:828
$title
$title
Definition: testCompression.php:34
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:537
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:692
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:303
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:639