MediaWiki
master
SpecialGoToInterwiki.php
Go to the documentation of this file.
1
<?php
36
class
SpecialGoToInterwiki
extends
UnlistedSpecialPage
{
37
public
function
__construct
() {
38
parent::__construct(
'GoToInterwiki'
);
39
}
40
41
public
function
execute
( $par ) {
42
// Allow forcing an interstitial for local interwikis. This is used
43
// when a redirect page is reached via a special page which resolves
44
// to a user-dependent value (as defined by
45
// RedirectSpecialPage::personallyIdentifiableTarget). See the hack
46
// for avoiding T109724 in MediaWiki::performRequest (which also
47
// explains why we can't use a query parameter instead).
48
$force = ( strpos( $par,
'force/'
) === 0 );
49
if
( $force ) {
50
$par = substr( $par, 6 );
51
}
52
53
$this->
setHeaders
();
54
$target =
Title::newFromText
( $par );
55
// Disallow special pages as a precaution against
56
// possible redirect loops.
57
if
( !$target || $target->isSpecialPage() ) {
58
$this->
getOutput
()->setStatusCode( 404 );
59
$this->
getOutput
()->addWikiMsg(
'gotointerwiki-invalid'
);
60
return
;
61
}
62
63
$url = $target->getFullURL();
64
if
( !$target->isExternal() || ( $target->isLocal() && !$force ) ) {
65
// Either a normal page, or a local interwiki.
66
// Just redirect.
67
$this->
getOutput
()->redirect( $url,
'301'
);
68
}
else
{
69
$this->
getOutput
()->addWikiMsg(
70
'gotointerwiki-external'
,
71
$url,
72
$target->getFullText()
73
);
74
}
75
}
76
80
public
function
requiresWrite
() {
81
return
false
;
82
}
83
87
protected
function
getGroupName
() {
88
return
'redirects'
;
89
}
90
}
SpecialGoToInterwiki
Landing page for non-local interwiki links.
Definition:
SpecialGoToInterwiki.php:36
SpecialGoToInterwiki\requiresWrite
requiresWrite()
Definition:
SpecialGoToInterwiki.php:80
SpecialGoToInterwiki\getGroupName
getGroupName()
Definition:
SpecialGoToInterwiki.php:87
SpecialGoToInterwiki\__construct
__construct()
Definition:
SpecialGoToInterwiki.php:37
SpecialGoToInterwiki\execute
execute( $par)
Default execute method Checks user permissions.
Definition:
SpecialGoToInterwiki.php:41
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition:
SpecialPage.php:659
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition:
SpecialPage.php:830
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition:
Title.php:370
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition:
UnlistedSpecialPage.php:31
includes
specials
SpecialGoToInterwiki.php
Generated on Sat May 28 2022 03:09:14 for MediaWiki by
1.9.1