MediaWiki REL1_33
SpecialGoToInterwiki.php
Go to the documentation of this file.
1<?php
37 public function __construct( $name = 'GoToInterwiki' ) {
38 parent::__construct( $name );
39 }
40
41 public function execute( $par ) {
42 $this->setHeaders();
43 $target = Title::newFromText( $par );
44 // Disallow special pages as a precaution against
45 // possible redirect loops.
46 if ( !$target || $target->isSpecialPage() ) {
47 $this->getOutput()->setStatusCode( 404 );
48 $this->getOutput()->addWikiMsg( 'gotointerwiki-invalid' );
49 return;
50 }
51
52 $url = $target->getFullURL();
53 if ( !$target->isExternal() || $target->isLocal() ) {
54 // Either a normal page, or a local interwiki.
55 // just redirect.
56 $this->getOutput()->redirect( $url, '301' );
57 } else {
58 $this->getOutput()->addWikiMsg(
59 'gotointerwiki-external',
60 $url,
61 $target->getFullText()
62 );
63 }
64 }
65
69 public function requiresWrite() {
70 return false;
71 }
72
76 protected function getGroupName() {
77 return 'redirects';
78 }
79}
Landing page for non-local interwiki links.
__construct( $name='GoToInterwiki')
execute( $par)
Default execute method Checks user permissions.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
Shortcut to construct a special page which is unlisted by default.
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
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:37