MediaWiki
master
Toggle main menu visibility
SpecialGoToInterwiki.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki\Specials;
8
9
use MediaWiki\SpecialPage\UnlistedSpecialPage;
10
use MediaWiki\Title\Title;
11
35
class
SpecialGoToInterwiki
extends
UnlistedSpecialPage
{
36
public
function
__construct
() {
37
parent::__construct(
'GoToInterwiki'
);
38
}
39
41
public
function
execute
( $par ) {
42
$par ??=
''
;
43
44
// Allow forcing an interstitial for local interwikis. This is used
45
// when a redirect page is reached via a special page which resolves
46
// to a user-dependent value (as defined by
47
// RedirectSpecialPage::personallyIdentifiableTarget). See the hack
48
// for avoiding T109724 in MediaWiki::performRequest (which also
49
// explains why we can't use a query parameter instead).
50
$force = str_starts_with( $par,
'force/'
);
51
if
( $force ) {
52
$par = substr( $par, 6 );
53
}
54
55
$this->
setHeaders
();
56
$target = Title::newFromText( $par );
57
// Disallow special pages as a precaution against
58
// possible redirect loops.
59
if
( !$target || $target->isSpecialPage() ) {
60
$this->
getOutput
()->setStatusCode( 404 );
61
$this->
getOutput
()->addWikiMsg(
'gotointerwiki-invalid'
);
62
return
;
63
}
64
65
$url
= $target->getFullURL( proto:
PROTO_FALLBACK
);
66
if
( !$target->isExternal() || ( $target->isLocal() && !$force ) ) {
67
// Either a normal page, or a local interwiki.
68
// Just redirect.
69
$this->
getOutput
()->redirect(
$url
,
'301'
);
70
}
else
{
71
$this->
getOutput
()->addWikiMsg(
72
'gotointerwiki-external'
,
73
$url
,
74
$target->getFullText()
75
);
76
}
77
}
78
82
public
function
requiresWrite
() {
83
return
false
;
84
}
85
89
protected
function
getGroupName
() {
90
return
'redirects'
;
91
}
92
}
93
94
// @codeCoverageIgnoreStart
96
class_alias( SpecialGoToInterwiki::class,
'SpecialGoToInterwiki'
);
97
// @codeCoverageIgnoreEnd
PROTO_FALLBACK
const PROTO_FALLBACK
Definition
Defines.php:220
MediaWiki\SpecialPage\SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition
SpecialPage.php:664
MediaWiki\SpecialPage\SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition
SpecialPage.php:860
MediaWiki\SpecialPage\UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition
UnlistedSpecialPage.php:19
MediaWiki\Specials\SpecialGoToInterwiki
Landing page for non-local interwiki links.
Definition
SpecialGoToInterwiki.php:35
MediaWiki\Specials\SpecialGoToInterwiki\execute
execute( $par)
Default execute method Checks user permissions.This must be overridden by subclasses; it will be made...
Definition
SpecialGoToInterwiki.php:41
MediaWiki\Specials\SpecialGoToInterwiki\__construct
__construct()
Definition
SpecialGoToInterwiki.php:36
MediaWiki\Specials\SpecialGoToInterwiki\getGroupName
getGroupName()
Definition
SpecialGoToInterwiki.php:89
MediaWiki\Specials\SpecialGoToInterwiki\requiresWrite
requiresWrite()
Definition
SpecialGoToInterwiki.php:82
$url
$url
Definition
opensearch_desc.php:25
includes
Specials
SpecialGoToInterwiki.php
Generated on
for MediaWiki by
1.18.0