dolibarr 21.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 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FI8TNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
29if (!defined('NOREQUIREUSER')) {
30 define('NOREQUIREUSER', '1');
31}
32if (!defined('NOREQUIRESOC')) {
33 define('NOREQUIRESOC', '1');
34}
35if (!defined('NOREQUIRETRAN')) {
36 define('NOREQUIRETRAN', '1');
37}
38if (!defined('NOTOKENRENEWAL')) {
39 define('NOTOKENRENEWAL', '1');
40}
41if (!defined('NOLOGIN')) {
42 define('NOLOGIN', '1');
43}
44if (!defined('NOREQUIREMENU')) {
45 define('NOREQUIREMENU', '1');
46}
47if (!defined('NOREQUIREHTML')) {
48 define('NOREQUIREHTML', '1');
49}
50if (!defined('NOREQUIREAJAX')) {
51 define('NOREQUIREAJAX', '1');
52}
53if (!defined('NOSESSION')) {
54 define('NOSESSION', '1');
55}
56
57require_once __DIR__.'/../../main.inc.php';
62top_httphead('text/json');
63// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
64if (empty($dolibarr_nocache)) {
65 header('Cache-Control: max-age=10800, public, must-revalidate');
66 // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server
67 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800).' GMT');
68} else {
69 header('Cache-Control: no-cache');
70}
71
72
73$manifest = new stdClass();
74
75$manifest->manifest_version = 3;
76
77$manifest->name = constant('DOL_APPLICATION_TITLE');
78if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
79 $manifest->name = getDolGlobalString('MAIN_APPLICATION_TITLE');
80}
81$manifest->short_name = $manifest->name;
82
83
84$manifest->theme_color = getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR', getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40'));
85if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->theme_color)) {
86 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
87 $manifest->theme_color = '#'.colorArrayToHex(colorStringToArray($manifest->theme_color));
88}
89$manifest->background_color = getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR', "#ffffff");
90if (!preg_match('/#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]$/', $manifest->background_color)) {
91 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
92 $manifest->background_color = '#'.colorArrayToHex(colorStringToArray($manifest->background_color));
93}
94$manifest->display = getDolGlobalString('MAIN_MANIFEST_DISPLAY', "minimal-ui");
95$manifest->splash_pages = null;
96$manifest->icons = array();
97$manifest->start_url = constant('DOL_MAIN_URL_ROOT');
98$manifest->id = constant('DOL_MAIN_URL_ROOT');
99
100if (getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL')) {
101 $icon = new stdClass();
102 $icon->src = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL');
103 if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) {
104 $icon->sizes = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE') . "x" . getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE');
105 } else {
106 $icon->sizes = "512x512";
107 }
108 $icon->type = "image/png";
109 $manifest->icons[] = $icon;
110} elseif (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED')) {
111 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI')) {
112 $iconRelativePath = 'logos/thumbs/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI');
113 $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
114 if (is_readable($iconPath)) {
115 $imgSize = getimagesize($iconPath);
116 if (!empty($imgSize)) {
117 $icon = new stdClass();
118 $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
119 $icon->sizes = $imgSize[0]."x".$imgSize[1];
120 $icon->type = "image/png";
121 $manifest->icons[] = $icon;
122 }
123 }
124 }
125
126 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL')) {
127 $iconRelativePath = 'logos/thumbs/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL');
128 $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
129 if (is_readable($iconPath)) {
130 $imgSize = getimagesize($iconPath);
131 if ($imgSize) {
132 $icon = new stdClass();
133 $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
134 $icon->sizes = $imgSize[0]."x".$imgSize[1];
135 $icon->type = "image/png";
136 $manifest->icons[] = $icon;
137 }
138 }
139 }
140
141 if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED')) {
142 $iconRelativePath = 'logos/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED');
143 $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
144 if (is_readable($iconPath)) {
145 $imgSize = getimagesize($iconPath);
146 if ($imgSize) {
147 $icon = new stdClass();
148 $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
149 $icon->sizes = $imgSize[0]."x".$imgSize[1];
150 $icon->type = "image/png";
151 $manifest->icons[] = $icon;
152 }
153 }
154 }
155}
156
157// Add Dolibarr std icon
158if (empty($manifest->icons)) {
159 $icon = new stdClass();
160 $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png';
161 $icon->sizes = "256x256";
162 $icon->type = "image/png";
163 $manifest->icons[] = $icon;
164}
165
166
167print json_encode($manifest);
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='auto')
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79