dolibarr 24.0.0-beta
manifest.json.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2007-2017 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
6 * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FI8TNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
30if (!defined('NOREQUIREUSER')) {
31 define('NOREQUIREUSER', '1');
32}
33if (!defined('NOREQUIRESOC')) {
34 define('NOREQUIRESOC', '1');
35}
36if (!defined('NOREQUIRETRAN')) {
37 define('NOREQUIRETRAN', '1');
38}
39if (!defined('NOTOKENRENEWAL')) {
40 define('NOTOKENRENEWAL', '1');
41}
42if (!defined('NOLOGIN')) {
43 define('NOLOGIN', '1');
44}
45if (!defined('NOREQUIREMENU')) {
46 define('NOREQUIREMENU', '1');
47}
48if (!defined('NOREQUIREHTML')) {
49 define('NOREQUIREHTML', '1');
50}
51if (!defined('NOREQUIREAJAX')) {
52 define('NOREQUIREAJAX', '1');
53}
54if (!defined('NOSESSION')) {
55 define('NOSESSION', '1');
56}
57
58require_once __DIR__.'/../main.inc.php';
59
64top_httphead('text/json');
65// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
66header('Cache-Control: max-age=10800, public, must-revalidate');
67// For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server
68header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800).' GMT');
69
70
71$manifest = new stdClass();
72
73$manifest->manifest_version = 3;
74
75$manifest->name = constant('DOL_APPLICATION_TITLE');
76if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
77 $manifest->name = getDolGlobalString('MAIN_APPLICATION_TITLE');
78}
79$manifest->short_name = $manifest->name;
80
81
82$manifest->theme_color = getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR', getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40'));
83if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->theme_color)) {
84 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
85 $manifest->theme_color = '#'.colorArrayToHex(colorStringToArray($manifest->theme_color));
86}
87$manifest->background_color = getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR', "#ffffff");
88if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->background_color)) {
89 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
90 $manifest->background_color = '#'.colorArrayToHex(colorStringToArray($manifest->background_color));
91}
92$manifest->display = getDolGlobalString('MAIN_MANIFEST_DISPLAY', "minimal-ui");
93$manifest->splash_pages = null;
94$manifest->icons = array();
95$manifest->start_url = constant('DOL_MAIN_URL_ROOT');
96$manifest->id = constant('DOL_MAIN_URL_ROOT');
97
98if (getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL')) {
99 $icon = new stdClass();
100 $icon->src = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL');
101 if (getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE')) {
102 $icon->sizes = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE') . "x" . getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE');
103 } else {
104 $icon->sizes = "512x512";
105 }
106 $icon->type = "image/png";
107 $manifest->icons[] = $icon;
108} else {
109 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI')) {
110 $iconRelativePath = 'logos/thumbs/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI');
111 $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
112 if (is_readable($iconPath)) {
113 $imgSize = getimagesize($iconPath);
114 if (!empty($imgSize)) {
115 $icon = new stdClass();
116 $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
117 $icon->sizes = $imgSize[0]."x".$imgSize[1];
118 $icon->type = "image/png";
119 $manifest->icons[] = $icon;
120 }
121 }
122 }
123
124 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL')) {
125 $iconRelativePath = 'logos/thumbs/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL');
126 $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
127 if (is_readable($iconPath)) {
128 $imgSize = getimagesize($iconPath);
129 if ($imgSize) {
130 $icon = new stdClass();
131 $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
132 $icon->sizes = $imgSize[0]."x".$imgSize[1];
133 $icon->type = "image/png";
134 $manifest->icons[] = $icon;
135 }
136 }
137 }
138
139 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED')) {
140 $iconRelativePath = 'logos/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED');
141 $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
142 if (is_readable($iconPath)) {
143 $imgSize = getimagesize($iconPath);
144 if ($imgSize) {
145 $icon = new stdClass();
146 $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
147 $icon->sizes = $imgSize[0]."x".$imgSize[1];
148 $icon->type = "image/png";
149 $manifest->icons[] = $icon;
150 }
151 }
152 }
153}
154
155// Add Dolibarr std icon
156if (empty($manifest->icons)) {
157 $icon = new stdClass();
158 $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png';
159 $icon->sizes = "256x256";
160 $icon->type = "image/png";
161 $manifest->icons[] = $icon;
162}
163
164
165print json_encode($manifest);
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
dol_now($mode='gmt')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.