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