MediaWiki
REL1_39
SpecialGoToInterwiki.php
Go to the documentation of this file.
1
<?php
47
class
SpecialGoToInterwiki
extends
UnlistedSpecialPage
{
48
public
function
__construct
() {
49
parent::__construct(
'GoToInterwiki'
);
50
}
51
52
public
function
execute
( $par ) {
53
$par = $par ??
''
;
54
55
// Allow forcing an interstitial for local interwikis. This is used
56
// when a redirect page is reached via a special page which resolves
57
// to a user-dependent value (as defined by
58
// RedirectSpecialPage::personallyIdentifiableTarget). See the hack
59
// for avoiding T109724 in MediaWiki::performRequest (which also
60
// explains why we can't use a query parameter instead).
61
$force = ( strpos( $par,
'force/'
) === 0 );
62
if
( $force ) {
63
$par = substr( $par, 6 );
64
}
65
66
$this->
setHeaders
();
67
$target = Title::newFromText( $par );
68
// Disallow special pages as a precaution against
69
// possible redirect loops.
70
if
( !$target || $target->isSpecialPage() ) {
71
$this->
getOutput
()->setStatusCode( 404 );
72
$this->
getOutput
()->addWikiMsg(
'gotointerwiki-invalid'
);
73
return
;
74
}
75
76
$url = $target->getFullURL();
77
if
( !$target->isExternal() || ( $target->isLocal() && !$force ) ) {
78
// Either a normal page, or a local interwiki.
79
// Just redirect.
80
$this->
getOutput
()->redirect( $url,
'301'
);
81
}
else
{
82
$this->
getOutput
()->addWikiMsg(
83
'gotointerwiki-external'
,
84
$url,
85
$target->getFullText()
86
);
87
}
88
}
89
93
public
function
requiresWrite
() {
94
return
false
;
95
}
96
100
protected
function
getGroupName
() {
101
return
'redirects'
;
102
}
103
}
SpecialGoToInterwiki
Landing page for non-local interwiki links.
Definition
SpecialGoToInterwiki.php:47
SpecialGoToInterwiki\requiresWrite
requiresWrite()
Definition
SpecialGoToInterwiki.php:93
SpecialGoToInterwiki\getGroupName
getGroupName()
Definition
SpecialGoToInterwiki.php:100
SpecialGoToInterwiki\__construct
__construct()
Definition
SpecialGoToInterwiki.php:48
SpecialGoToInterwiki\execute
execute( $par)
Default execute method Checks user permissions.
Definition
SpecialGoToInterwiki.php:52
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 Mon Nov 25 2024 06:57:01 for MediaWiki by
1.10.0