MediaWiki REL1_31
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.