From 04dc3ae8cd9dabf79a5601a0e3cb06155bd92328 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 21 Jan 2021 21:46:00 +0100 Subject: [PATCH 1/2] NEW : manifest use squared image or custom --- htdocs/theme/eldy/manifest.json.php | 101 +++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 17 deletions(-) diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index d7f01b3375e..66d5eb45a63 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,90 @@ 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); From bb09a39ce6f00f7d90bbe2dabd942af8192e1a46 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 21 Jan 2021 20:52:21 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/theme/eldy/manifest.json.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/theme/eldy/manifest.json.php b/htdocs/theme/eldy/manifest.json.php index 66d5eb45a63..8af5af5a756 100644 --- a/htdocs/theme/eldy/manifest.json.php +++ b/htdocs/theme/eldy/manifest.json.php @@ -63,14 +63,12 @@ if (!empty($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL)){ $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]; @@ -85,8 +83,7 @@ elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; if (is_readable($iconPath)) { $imgSize = getimagesize($iconPath); - if($imgSize){ - + 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]; @@ -101,8 +98,7 @@ elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath; if (is_readable($iconPath)) { $imgSize = getimagesize($iconPath); - if($imgSize){ - + 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]; @@ -114,7 +110,7 @@ elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)){ } // Add Dolibarr std icon -if(empty($manifest->icons)){ +if (empty($manifest->icons)){ $icon = new stdClass(); $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; $icon->sizes = "256x256";