Repository navigation
Expand file tree
/
Copy pathmanifest_pwa.json.php
More file actions
172 lines (154 loc) · 6.79 KB
/
Copy pathmanifest_pwa.json.php
File metadata and controls
172 lines (154 loc) · 6.79 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/* Copyright (C) 2024 EVARISK <technique@evarisk.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file manifest_pwa.json.php
* \ingroup digiriskdolibarr
* \brief Manifest of the internal DigiriskDolibarr PWA (prevention plans and fire permits).
* Kept separate from manifest.json.php, which serves the public ticket declaration app:
* two different start_url and scope means two installable applications.
*/
if (!defined('NOREQUIREUSER')) {
define('NOREQUIREUSER', 1);
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', 1);
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
if (!defined('NOLOGIN')) {
define('NOLOGIN', 1);
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', 1);
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', 1);
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', 1);
}
if (!defined('NOSESSION')) {
define('NOSESSION', 1);
}
if (!defined('NOCSRFCHECK')) { // We accept to go on this page from external website
define('NOCSRFCHECK', 1);
}
if (!defined('NOIPCHECK')) { // Do not check IP defined into conf $dolibarr_main_restrict_ip
define('NOIPCHECK', 1);
}
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', 1);
}
// Load Dolibarr environment
if (file_exists('../main.inc.php')) {
require_once __DIR__ . '/../main.inc.php';
} elseif (file_exists('../../main.inc.php')) {
require_once __DIR__ . '/../../main.inc.php';
} else {
die('Include of main fails');
}
top_httphead('text/json');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access
if (empty($dolibarr_nocache)) {
header('Cache-Control: max-age=10800, public, must-revalidate');
// For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server
header('Expires: ' . gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800) . ' GMT');
} else {
header('Cache-Control: no-cache');
}
// Global variables definitions
global $conf;
// Initialize technical objects
$manifest = new stdClass();
$manifest->short_name = 'Digirisk';
$manifest->name = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' - Digirisk';
$manifest->icons = [];
$img = new stdClass();
$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color_192.png', 1);
$img->type = 'image/png';
$img->sizes = '192x192';
$manifest->icons[] = $img;
$img = new stdClass();
$img->src = dol_buildpath('/custom/digiriskdolibarr/img/digiriskdolibarr_color_512.png', 1);
$img->type = 'image/png';
$img->sizes = '512x512';
$manifest->icons[] = $img;
// Android crops the home screen icon to its own shape: this one keeps the logo inside the safe zone
$img = new stdClass();
$img->src = dol_buildpath('/custom/digiriskdolibarr/img/pwa/icon-maskable-512.png', 1);
$img->type = 'image/png';
$img->sizes = '512x512';
$img->purpose = 'maskable';
$manifest->icons[] = $img;
$manifest->id = dol_buildpath('/custom/digiriskdolibarr/view/frontend/pwa_home.php', 1);
$manifest->start_url = dol_buildpath('/custom/digiriskdolibarr/view/frontend/pwa_home.php', 1);
$manifest->background_color = '#ffffff';
$manifest->display = 'standalone';
$manifest->display_override = ['window-controls-overlay'];
// The mobile creation screens live outside view/frontend/, so the scope covers the whole module
$manifest->scope = dol_buildpath('/custom/digiriskdolibarr/', 1);
$manifest->theme_color = '#2b7de9';
$manifest->description = 'Consultez et créez vos plans de prévention et vos permis de feu depuis votre téléphone.';
$manifest->lang = 'fr';
$manifest->categories = ['business', 'productivity'];
// Shortcuts offered by a long press on the installed application icon.
// They open the lists, which are the single entry point to the creation screens.
$shortcut = new stdClass();
$shortcut->name = 'Plans de prévention';
$shortcut->short_name = 'Plans';
$shortcut->url = dol_buildpath('/custom/digiriskdolibarr/view/frontend/pwa_preventionplan_list.php', 1);
$manifest->shortcuts[] = $shortcut;
$shortcut = new stdClass();
$shortcut->name = 'Permis de feu';
$shortcut->short_name = 'Permis';
$shortcut->url = dol_buildpath('/custom/digiriskdolibarr/view/frontend/pwa_firepermit_list.php', 1);
$manifest->shortcuts[] = $shortcut;
$shortcut = new stdClass();
$shortcut->name = 'Rondes apres travaux';
$shortcut->short_name = 'Rondes';
$shortcut->url = dol_buildpath('/custom/digiriskdolibarr/view/frontend/pwa_firepermit_rounds.php', 1);
$manifest->shortcuts[] = $shortcut;
// Pictures of the install dialog, in display order: the presentation visual first, then one per screen.
// Chrome shows the portrait (narrow) ones on a phone and the landscape (wide) ones on a computer, at most
// 8 entries in all, and drops a picture whose aspect ratio differs from the first one shown.
// Made from a demo data set, they are the same for every entity.
$screenshots = [
'narrow' => ['file_prefix' => 'pwa-narrow', 'sizes' => '720x1560'],
'wide' => ['file_prefix' => 'pwa-wide', 'sizes' => '1920x1080'],
];
$screenshotLabels = [
'' => 'Digirisk : plans de prévention et permis de feu sur votre téléphone',
'-create' => 'Un plan de prévention en quelques minutes',
'-list' => 'Retrouvez chaque plan en un instant',
'-home' => 'Tout ce qui vous attend, dès l\'ouverture',
];
foreach ($screenshots as $formFactor => $screenshot) {
foreach ($screenshotLabels as $fileSuffix => $label) {
$img = new stdClass();
$img->src = dol_buildpath('/custom/digiriskdolibarr/img/pwa/' . $screenshot['file_prefix'] . $fileSuffix . '.jpg', 1);
$img->type = 'image/jpeg';
$img->sizes = $screenshot['sizes'];
$img->form_factor = $formFactor;
$img->label = $label;
$manifest->screenshots[] = $img;
}
}
print json_encode($manifest);