diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index d7f01b3375e..8af5af5a756 100644 --- a/htdocs/theme/eldy/manifest.json.php +++ b/htdocs/theme/eldy/manifest.json.php @@ -26,7 +26,6 @@ */ if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); -if (!defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); @@ -38,22 +37,86 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require_once __DIR__.'/../../main.inc.php'; -$appli = constant('DOL_APPLICATION_TITLE'); -if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli = $conf->global->MAIN_APPLICATION_TITLE; top_httphead('text/json'); -?> -{ - "name": "", - "icons": [ - { - "src": "", - "sizes": "256x256", - "type": "image/png" - } - ], - "theme_color": "#ffffff", - "background_color": "#ffffff", - "display": "standalone" -} \ No newline at end of file + +$manifest = new stdClass(); + + +$manifest->name = constant('DOL_APPLICATION_TITLE'); +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $manifest->name = $conf->global->MAIN_APPLICATION_TITLE; + + +$manifest->theme_color = !empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR)?$conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR:'#F05F40'; +$manifest->background_color = !empty($conf->global->MAIN_MANIFEST_APPLI_BG_COLOR)?$conf->global->MAIN_MANIFEST_APPLI_BG_COLOR:"#ffffff"; +$manifest->display = "standalone"; +$manifest->splash_pages = null; +$manifest->icons = array(); + +if (!empty($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL)){ + $icon = new stdClass(); + $icon->src = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL; + if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) { $icon->sizes = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE."x".$conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE; } + else { $icon->sizes = "512x512"; } + $icon->type = "image/png"; + $manifest->icons[] = $icon; +} +elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ + if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)){ + $iconRelativePath = 'logos/thumbs/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI; + $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; + if (is_readable($iconPath)) { + $imgSize = getimagesize($iconPath); + if ($imgSize){ + $icon = new stdClass(); + $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath); + $icon->sizes = $imgSize[0]."x".$imgSize[1]; + $icon->type = "image/png"; + $manifest->icons[] = $icon; + } + } + } + + if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL)){ + $iconRelativePath = 'logos/thumbs/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL; + $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; + if (is_readable($iconPath)) { + $imgSize = getimagesize($iconPath); + if ($imgSize){ + $icon = new stdClass(); + $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath); + $icon->sizes = $imgSize[0]."x".$imgSize[1]; + $icon->type = "image/png"; + $manifest->icons[] = $icon; + } + } + } + + if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ + $iconRelativePath = 'logos/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED; + $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; + if (is_readable($iconPath)) { + $imgSize = getimagesize($iconPath); + if ($imgSize){ + $icon = new stdClass(); + $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath); + $icon->sizes = $imgSize[0]."x".$imgSize[1]; + $icon->type = "image/png"; + $manifest->icons[] = $icon; + } + } + } +} + +// Add Dolibarr std icon +if (empty($manifest->icons)){ + $icon = new stdClass(); + $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; + $icon->sizes = "256x256"; + $icon->type = "image/png"; + $manifest->icons[] = $icon; +} + + +print json_encode($manifest);