Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4119217
ApiWebappManifest.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
ApiWebappManifest.php
View Options
<?php
namespace
MobileFrontend\Api
;
use
MediaWiki\Api\ApiBase
;
use
MediaWiki\Api\ApiFormatJson
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\Title\Title
;
/**
* Return the webapp manifest for this wiki
*/
class
ApiWebappManifest
extends
ApiBase
{
/**
* Execute the requested Api actions.
*/
public
function
execute
()
{
$services
=
MediaWikiServices
::
getInstance
();
$urlUtils
=
$services
->
getUrlUtils
();
$config
=
$this
->
getConfig
();
$resultObj
=
$this
->
getResult
();
$resultObj
->
addValue
(
null
,
'name'
,
$config
->
get
(
'Sitename'
)
);
$resultObj
->
addValue
(
null
,
'orientation'
,
'portrait'
);
$resultObj
->
addValue
(
null
,
'dir'
,
$services
->
getContentLanguage
()->
getDir
()
);
$resultObj
->
addValue
(
null
,
'lang'
,
$config
->
get
(
'LanguageCode'
)
);
$resultObj
->
addValue
(
null
,
'display'
,
'minimal-ui'
);
$resultObj
->
addValue
(
null
,
'theme_color'
,
$config
->
get
(
'MFManifestThemeColor'
)
);
$resultObj
->
addValue
(
null
,
'background_color'
,
$config
->
get
(
'MFManifestBackgroundColor'
)
);
$resultObj
->
addValue
(
null
,
'start_url'
,
Title
::
newMainPage
()->
getLocalURL
()
);
$icons
=
[];
$appleTouchIcon
=
$config
->
get
(
'AppleTouchIcon'
);
if
(
$appleTouchIcon
!==
false
)
{
$appleTouchIconUrl
=
$urlUtils
->
expand
(
$appleTouchIcon
,
PROTO_CURRENT
)
??
''
;
$request
=
$services
->
getHttpRequestFactory
()->
create
(
$appleTouchIconUrl
,
[],
__METHOD__
);
$request
->
execute
();
$appleTouchIconContent
=
$request
->
getContent
();
if
(
$appleTouchIconContent
!==
''
)
{
$appleTouchIconSize
=
getimagesizefromstring
(
$appleTouchIconContent
);
}
$icon
=
[
'src'
=>
$appleTouchIcon
];
if
(
isset
(
$appleTouchIconSize
)
&&
$appleTouchIconSize
!==
false
)
{
$icon
[
'sizes'
]
=
$appleTouchIconSize
[
0
]
.
'x'
.
$appleTouchIconSize
[
1
];
$icon
[
'type'
]
=
$appleTouchIconSize
[
'mime'
];
}
$icons
[]
=
$icon
;
}
$resultObj
->
addValue
(
null
,
'icons'
,
$icons
);
$main
=
$this
->
getMain
();
$main
->
setCacheControl
(
[
's-maxage'
=>
86400
,
'max-age'
=>
86400
]
);
$main
->
setCacheMode
(
'public'
);
}
/**
* Get the JSON printer
*
* @return ApiFormatJson
*/
public
function
getCustomPrinter
()
{
return
new
ApiFormatJson
(
$this
->
getMain
(),
'json'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 03:13 (2 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
dc/3c/053d43b2c1334514eb7d0a399f66
Default Alt Text
ApiWebappManifest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment