MediaWiki
master
Toggle main menu visibility
SkinComponentUtils.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Skin\Components;
4
5
use MediaWiki\Context\RequestContext;
6
use MediaWiki\Permissions\Authority;
7
use MediaWiki\Request\WebRequest;
8
use MediaWiki\SpecialPage\SpecialPage;
9
use MediaWiki\Specials\Helpers\LoginHelper;
10
use MediaWiki\Title\Title;
11
12
class
SkinComponentUtils
{
13
23
public
static
function
getReturnToParam
( $title,
$request
, $authority ) {
24
// T379295/T381216: Preserve authentication query params so they don't get lost
25
// during switching between Login/Logout or CreateAccount pages where we need them.
26
// See AuthManagerSpecialPage/LoginSignupSpecialPage::getPreservedParams().
27
// This special case also avoids "nesting" returnto values on these pages.
28
if
(
29
$title->isSpecial(
'Userlogin'
)
30
|| $title->isSpecial(
'CreateAccount'
)
31
|| $title->isSpecial(
'Userlogout'
)
32
) {
33
$loginHelper =
new
LoginHelper
( RequestContext::getMain() );
34
return
$loginHelper->getPreservedParams( [
'request'
=>
$request
,
'reset'
=>
true
] );
35
}
36
37
# Due to T34276, if a user does not have read permissions,
38
# $this->getTitle() will just give Special:Badtitle, which is
39
# not especially useful as a returnto parameter. Use the title
40
# from the request instead, if there was one.
41
if
( !$title->isSpecial(
'Badtitle'
) ) {
42
$page = $title;
43
}
else
{
44
$page = Title::newFromText(
$request
->getVal(
'title'
,
''
) );
45
}
46
47
$query = [];
48
if
( !
$request
->wasPosted() ) {
49
$query =
$request
->getQueryValues();
50
unset( $query[
'title'
] );
51
}
52
53
$params = [];
54
if
( $page ) {
55
$params[
'returnto'
] = $page->getPrefixedText();
56
if
( $query ) {
57
$params[
'returntoquery'
] =
wfArrayToCgi
( $query );
58
}
59
}
60
61
return
$params;
62
}
63
75
public
static
function
makeSpecialUrl
( $name, $urlaction =
''
, $proto =
null
) {
76
$title =
SpecialPage::getSafeTitleFor
( $name );
77
if
( $proto ===
null
) {
78
return
$title->getLocalURL( $urlaction );
79
}
else
{
80
return
$title->getFullURL( $urlaction,
false
, $proto );
81
}
82
}
83
90
public
static
function
makeSpecialUrlSubpage
( $name, $subpage, $urlaction =
''
) {
91
$title =
SpecialPage::getSafeTitleFor
( $name, $subpage );
92
return
$title->getLocalURL( $urlaction );
93
}
94
}
95
97
class_alias( SkinComponentUtils::class,
'MediaWiki\\Skin\\SkinComponentUtils'
);
wfArrayToCgi
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
Definition
GlobalFunctions.php:219
MediaWiki\Skin\Components\SkinComponentUtils
Definition
SkinComponentUtils.php:12
MediaWiki\Skin\Components\SkinComponentUtils\getReturnToParam
static getReturnToParam( $title, $request, $authority)
Builds query params for the page to return to, used when building links.
Definition
SkinComponentUtils.php:23
MediaWiki\Skin\Components\SkinComponentUtils\makeSpecialUrl
static makeSpecialUrl( $name, $urlaction='', $proto=null)
Make a URL for a Special Page using the given query and protocol.
Definition
SkinComponentUtils.php:75
MediaWiki\Skin\Components\SkinComponentUtils\makeSpecialUrlSubpage
static makeSpecialUrlSubpage( $name, $subpage, $urlaction='')
Definition
SkinComponentUtils.php:90
MediaWiki\SpecialPage\SpecialPage\getSafeTitleFor
static getSafeTitleFor( $name, $subpage=false)
Get a localised Title object for a page name with a possibly unvalidated subpage.
Definition
SpecialPage.php:158
MediaWiki\Specials\Helpers\LoginHelper
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
Definition
LoginHelper.php:18
$request
$request
Definition
opensearch_desc.php:26
includes
Skin
Components
SkinComponentUtils.php
Generated on
for MediaWiki by
1.18.0