MediaWiki REL1_32
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->setHeaders();
51 $this->outputHeader();
52 $this->showForm();
53 }
54
55 private function showForm() {
56 $form = HTMLForm::factory( 'ooui', [
57 'revid' => [
58 'type' => 'int',
59 'name' => 'revid',
60 'label-message' => 'permanentlink-revid',
61 ],
62 ], $this->getContext(), 'permanentlink' );
63 $form->setSubmitTextMsg( 'permanentlink-submit' );
64 $form->setSubmitCallback( [ $this, 'onFormSubmit' ] );
65 $form->show();
66 }
67
68 public function onFormSubmit( $formData ) {
69 $revid = $formData['revid'];
70 $title = $this->getPageTitle( $revid ?: null );
71 $url = $title->getFullUrlForRedirect();
72 $this->getOutput()->redirect( $url );
73 }
74
75 public function isListed() {
76 return true;
77 }
78
79 protected function getGroupName() {
80 return 'redirects';
81 }
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.