forked from unacms/una
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.json.php
90 lines (73 loc) · 2.71 KB
/
manifest.json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Copyright (c) UNA, Inc - https://una.io
* MIT License - https://opensource.org/licenses/MIT
*
* @defgroup UnaCore UNA Core
* @{
*/
define('BX_MANIFEST', true);
require_once('./inc/header.inc.php');
$aContent = [
'name' => '',
'short_name' => '',
'description' => getParam('sys_pwa_manifest_description'),
'orientation' => 'portrait',
'start_url' => parse_url(BX_DOL_URL_ROOT, PHP_URL_PATH),
'display' => 'standalone',
'scope' => '/',
'background_color' => getParam('sys_pwa_manifest_background_color'),
'theme_color' => getParam('sys_pwa_manifest_theme_color'),
'gcm_sender_id' => isLogged() ? '482941778795' : ''
];
$aContent['name'] = ($sName = getParam('sys_pwa_manifest_name')) != '' ? $sName : parse_url(BX_DOL_URL_ROOT, PHP_URL_HOST);
$aContent['short_name'] = ($sShortName = getParam('sys_pwa_manifest_short_name')) != '' ? $sShortName : $aContent['name'];
foreach($aContent as $sKey => $sValue)
if(empty($sValue))
unset($aContent[$sKey]);
$aAdi = [];
/*
* Apple device icons
*/
if(($iId = (int)getParam('sys_site_icon_apple')) != 0) {
$oTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_APPLE);
$sSizes = '180x180';
if(($aTranscoderParams = $oTranscoder->getFilterParams('Resize')) !== false)
$sSizes = $aTranscoderParams['w'] . 'x' . $aTranscoderParams['h'];
$aAdi[] = [
'src' => $oTranscoder->getFileUrl($iId),
'type' => $oTranscoder->getFileMimeType($iId),
'sizes' => $sSizes
];
}
/*
* Android device icons
*/
if(($iId = (int)getParam('sys_site_icon_android')) != 0) {
$oTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_ANDROID);
$sSizes = '192x192';
if(($aTranscoderParams = $oTranscoder->getFilterParams('Resize')) !== false)
$sSizes = $aTranscoderParams['w'] . 'x' . $aTranscoderParams['h'];
$aAdi[] = [
'src' => $oTranscoder->getFileUrl($iId),
'type' => $oTranscoder->getFileMimeType($iId),
'sizes' => $sSizes
];
}
if(($iId = (int)getParam('sys_site_icon_android_splash')) != 0) {
$oTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_ANDROID_SPLASH);
$sSizes = '512x512';
if(($aTranscoderParams = $oTranscoder->getFilterParams('Resize')) !== false)
$sSizes = $aTranscoderParams['w'] . 'x' . $aTranscoderParams['h'];
$aAdi[] = [
'src' => $oTranscoder->getFileUrl($iId),
'type' => $oTranscoder->getFileMimeType($iId),
'sizes' => $sSizes
];
}
if(!empty($aAdi) && is_array($aAdi))
$aContent['icons'] = $aAdi;
header("Content-Type: application/json");
header("X-Robots-Tag: none");
echo json_encode($aContent);
?>