MediaWiki REL1_41
SpecialPermanentLink.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
26use HTMLForm;
29
36 public function __construct() {
37 parent::__construct( 'PermanentLink' );
38 $this->mAllowedRedirectParams = [];
39 }
40
45 public function getRedirect( $subpage ) {
46 $subpage = intval( $subpage );
47 if ( $subpage === 0 ) {
48 return false;
49 }
50 $this->mAddedRedirectParams['oldid'] = $subpage;
51
52 return true;
53 }
54
55 protected function showNoRedirectPage() {
56 $this->addHelpLink( 'Help:PermanentLink' );
57 $this->setHeaders();
58 $this->outputHeader();
59 $this->showForm();
60 }
61
62 private function showForm() {
63 HTMLForm::factory( 'ooui', [
64 'revid' => [
65 'type' => 'int',
66 'name' => 'revid',
67 'label-message' => 'permanentlink-revid',
68 ],
69 ], $this->getContext(), 'permanentlink' )
70 ->setSubmitTextMsg( 'permanentlink-submit' )
71 ->setSubmitCallback( [ $this, 'onFormSubmit' ] )
72 ->show();
73 }
74
75 public function onFormSubmit( $formData ) {
76 $revid = $formData['revid'];
77 $title = $this->getPageTitle( $revid ?: null );
78 $url = $title->getFullUrlForRedirect();
79 $this->getOutput()->redirect( $url );
80 }
81
82 public function isListed() {
83 return true;
84 }
85
86 protected function getGroupName() {
87 return 'redirects';
88 }
89}
90
95class_alias( SpecialPermanentLink::class, 'SpecialPermanentLink' );
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:158
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 Per default the message key is the canonical name o...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Represents a title within MediaWiki.
Definition Title.php:76
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...