MediaWiki  1.33.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->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 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:678
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:29
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
HTMLForm\factory
static factory( $displayFormat)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:286
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:698
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:633