MediaWiki
REL1_40
SpecialGoToInterwiki.php
Go to the documentation of this file.
1
<?php
24
use
MediaWiki\Title\Title
;
25
49
class
SpecialGoToInterwiki
extends
UnlistedSpecialPage
{
50
public
function
__construct
() {
51
parent::__construct(
'GoToInterwiki'
);
52
}
53
54
public
function
execute
( $par ) {
55
$par ??=
''
;
56
57
// Allow forcing an interstitial for local interwikis. This is used
58
// when a redirect page is reached via a special page which resolves
59
// to a user-dependent value (as defined by
60
// RedirectSpecialPage::personallyIdentifiableTarget). See the hack
61
// for avoiding T109724 in MediaWiki::performRequest (which also
62
// explains why we can't use a query parameter instead).
63
$force = str_starts_with( $par,
'force/'
);
64
if
( $force ) {
65
$par = substr( $par, 6 );
66
}
67
68
$this->
setHeaders
();
69
$target = Title::newFromText( $par );
70
// Disallow special pages as a precaution against
71
// possible redirect loops.
72
if
( !$target || $target->isSpecialPage() ) {
73
$this->
getOutput
()->setStatusCode( 404 );
74
$this->
getOutput
()->addWikiMsg(
'gotointerwiki-invalid'
);
75
return
;
76
}
77
78
$url = $target->getFullURL();
79
if
( !$target->isExternal() || ( $target->isLocal() && !$force ) ) {
80
// Either a normal page, or a local interwiki.
81
// Just redirect.
82
$this->
getOutput
()->redirect( $url,
'301'
);
83
}
else
{
84
$this->
getOutput
()->addWikiMsg(
85
'gotointerwiki-external'
,
86
$url,
87
$target->getFullText()
88
);
89
}
90
}
91
95
public
function
requiresWrite
() {
96
return
false
;
97
}
98
102
protected
function
getGroupName
() {
103
return
'redirects'
;
104
}
105
}
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:82
SpecialGoToInterwiki
Landing page for non-local interwiki links.
Definition
SpecialGoToInterwiki.php:49
SpecialGoToInterwiki\requiresWrite
requiresWrite()
Definition
SpecialGoToInterwiki.php:95
SpecialGoToInterwiki\getGroupName
getGroupName()
Definition
SpecialGoToInterwiki.php:102
SpecialGoToInterwiki\__construct
__construct()
Definition
SpecialGoToInterwiki.php:50
SpecialGoToInterwiki\execute
execute( $par)
Default execute method Checks user permissions.
Definition
SpecialGoToInterwiki.php:54
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition
SpecialPage.php:672
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition
SpecialPage.php:862
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition
UnlistedSpecialPage.php:31
includes
specials
SpecialGoToInterwiki.php
Generated on Thu Jun 27 2024 14:04:20 for MediaWiki by
1.10.0