Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7445010
SkinComponentUtils.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
SkinComponentUtils.php
View Options
<?php
namespace
MediaWiki\Skin
;
use
MediaWiki\Permissions\Authority
;
use
MediaWiki\Request\WebRequest
;
use
MediaWiki\SpecialPage\SpecialPage
;
use
MediaWiki\Title\Title
;
class
SkinComponentUtils
{
/**
* Adds a class to the existing class value, supporting it as a string
* or array.
*
* @param string|array $class to update.
* @param string $newClass to add.
* @return string|array classes.
* @internal
*/
public
static
function
addClassToClassList
(
$class
,
string
$newClass
)
{
if
(
is_array
(
$class
)
)
{
$class
[]
=
$newClass
;
}
else
{
$class
.=
' '
.
$newClass
;
$class
=
trim
(
$class
);
}
return
$class
;
}
/**
* Builds query params for the page to return to, used when building links
* @unstable
*
* @param Title $title
* @param WebRequest $request
* @param Authority $authority
* @return string[]
*/
public
static
function
getReturnToParam
(
$title
,
$request
,
$authority
)
{
# Due to T34276, if a user does not have read permissions,
# $this->getTitle() will just give Special:Badtitle, which is
# not especially useful as a returnto parameter. Use the title
# from the request instead, if there was one.
if
(
$authority
->
isAllowed
(
'read'
)
)
{
$page
=
$title
;
}
else
{
$page
=
Title
::
newFromText
(
$request
->
getVal
(
'title'
,
''
)
);
}
$page
=
$request
->
getVal
(
'returnto'
,
$page
);
$query
=
[];
if
(
!
$request
->
wasPosted
()
)
{
$query
=
$request
->
getValues
();
unset
(
$query
[
'title'
]
);
unset
(
$query
[
'returnto'
]
);
unset
(
$query
[
'returntoquery'
]
);
}
$thisquery
=
wfArrayToCgi
(
$query
);
$returnto
=
[];
if
(
strval
(
$page
)
!==
''
)
{
$returnto
[
'returnto'
]
=
$page
;
$query
=
$request
->
getVal
(
'returntoquery'
,
$thisquery
);
$paramsArray
=
wfCgiToArray
(
$query
);
$query
=
wfArrayToCgi
(
$paramsArray
);
if
(
$query
!=
''
)
{
$returnto
[
'returntoquery'
]
=
$query
;
}
}
return
$returnto
;
}
/**
* Make a URL for a Special Page using the given query and protocol.
*
* If $proto is set to null, make a local URL. Otherwise, make a full
* URL with the protocol specified.
*
* @param string $name Name of the Special page
* @param string|array $urlaction Query to append
* @param string|null $proto Protocol to use or null for a local URL
* @return string
*/
public
static
function
makeSpecialUrl
(
$name
,
$urlaction
=
''
,
$proto
=
null
)
{
$title
=
SpecialPage
::
getSafeTitleFor
(
$name
);
if
(
$proto
===
null
)
{
return
$title
->
getLocalURL
(
$urlaction
);
}
else
{
return
$title
->
getFullURL
(
$urlaction
,
false
,
$proto
);
}
}
/**
* @param string $name
* @param string|bool $subpage false for no subpage
* @param string|array $urlaction
* @return string
*/
public
static
function
makeSpecialUrlSubpage
(
$name
,
$subpage
,
$urlaction
=
''
)
{
$title
=
SpecialPage
::
getSafeTitleFor
(
$name
,
$subpage
);
return
$title
->
getLocalURL
(
$urlaction
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 17:54 (1 d, 2 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
78/ab/6b8df52babd0ce6d7bfc3c686532
Default Alt Text
SkinComponentUtils.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment