Merge pull request #16046 from atm-john/new/manifest_use_squared_img

NEW : manifest use squared image or custom
This commit is contained in:
Laurent Destailleur 2021-01-22 02:05:35 +01:00 committed by GitHub
commit d368b3c7d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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": "<?php echo $appli; ?>",
"icons": [
{
"src": "<?php echo DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png'; ?>",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
$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);