Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2752568
MobileFrontendSkinHooks.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
MobileFrontendSkinHooks.php
View Options
<?php
use
MediaWiki\Html\Html
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\Title\Title
;
class
MobileFrontendSkinHooks
{
/**
* Returns HTML of terms of use link or null if it shouldn't be displayed
* Note: This is called by a hook in the WikimediaMessages extension.
*
* @param MessageLocalizer $localizer
* @return null|string
*/
public
static
function
getTermsLink
(
MessageLocalizer
$localizer
)
{
$urlMsg
=
$localizer
->
msg
(
'mobile-frontend-terms-url'
)->
inContentLanguage
();
if
(
$urlMsg
->
isDisabled
()
)
{
return
null
;
}
$url
=
$urlMsg
->
plain
();
return
Html
::
element
(
'a'
,
[
'href'
=>
Skin
::
makeInternalOrExternalUrl
(
$url
)
],
$localizer
->
msg
(
'mobile-frontend-terms-text'
)->
text
()
);
}
/**
* @param Skin $skin
* @param MobileContext $context
* @return string representing the desktop link.
*/
public
static
function
getDesktopViewLink
(
Skin
$skin
,
MobileContext
$context
)
{
$url
=
$skin
->
getOutput
()->
getProperty
(
'desktopUrl'
);
$req
=
$skin
->
getRequest
();
if
(
$url
)
{
$url
=
wfAppendQuery
(
$url
,
'mobileaction=toggle_view_desktop'
);
}
else
{
$title
=
$skin
->
getTitle
()
??
Title
::
newMainPage
();
$url
=
$title
->
getLocalURL
(
$req
->
appendQueryValue
(
'mobileaction'
,
'toggle_view_desktop'
)
);
}
$urlUtils
=
MediaWikiServices
::
getInstance
()->
getUrlUtils
();
$desktopUrl
=
$context
->
getDesktopUrl
(
$urlUtils
->
expand
(
$url
,
PROTO_RELATIVE
)
??
''
);
$desktop
=
$context
->
msg
(
'mobile-frontend-view-desktop'
)->
text
();
return
Html
::
element
(
'a'
,
[
'id'
=>
'mw-mf-display-toggle'
,
'href'
=>
$desktopUrl
,
'data-event-name'
=>
'switch_to_desktop'
],
$desktop
);
}
/**
* @param Skin $skin
* @param MobileContext $context
* @return string representing the mobile link.
*/
public
static
function
getMobileViewLink
(
Skin
$skin
,
MobileContext
$context
)
{
$req
=
$skin
->
getRequest
();
$args
=
$req
->
getQueryValues
();
// avoid title being set twice
unset
(
$args
[
'title'
],
$args
[
'useformat'
]
);
$args
[
'mobileaction'
]
=
'toggle_view_mobile'
;
$title
=
$skin
->
getTitle
();
// Title could be null
// If no title, there is a problem with context. Possibly inside a test.
if
(
!
$title
)
{
return
''
;
}
$mobileViewUrl
=
$title
->
getFullURL
(
$args
);
$mobileViewUrl
=
$context
->
getMobileUrl
(
$mobileViewUrl
);
return
Html
::
element
(
'a'
,
[
'href'
=>
$mobileViewUrl
,
'class'
=>
'noprint stopMobileRedirectToggle'
],
$context
->
msg
(
'mobile-frontend-view'
)->
text
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Jul 3, 20:09 (1 d, 11 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1f/81/6137e799f5a041a016b5147065d7
Default Alt Text
MobileFrontendSkinHooks.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment