manifest.json.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. /**
  23. * \file htdocs/theme/eldy/manifest.json.php
  24. * \brief File for The Web App
  25. */
  26. if (!defined('NOREQUIREUSER')) {
  27. define('NOREQUIREUSER', '1');
  28. }
  29. if (!defined('NOREQUIRESOC')) {
  30. define('NOREQUIRESOC', '1');
  31. }
  32. if (!defined('NOREQUIRETRAN')) {
  33. define('NOREQUIRETRAN', '1');
  34. }
  35. if (!defined('NOTOKENRENEWAL')) {
  36. define('NOTOKENRENEWAL', '1');
  37. }
  38. if (!defined('NOLOGIN')) {
  39. define('NOLOGIN', '1');
  40. }
  41. if (!defined('NOREQUIREMENU')) {
  42. define('NOREQUIREMENU', '1');
  43. }
  44. if (!defined('NOREQUIREHTML')) {
  45. define('NOREQUIREHTML', '1');
  46. }
  47. if (!defined('NOREQUIREAJAX')) {
  48. define('NOREQUIREAJAX', '1');
  49. }
  50. if (!defined('NOSESSION')) {
  51. define('NOSESSION', '1');
  52. }
  53. require_once __DIR__.'/../../main.inc.php';
  54. top_httphead('text/json');
  55. // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
  56. if (empty($dolibarr_nocache)) {
  57. header('Cache-Control: max-age=10800, public, must-revalidate');
  58. // For a text/json, we must set an Expires to avoid to have it forced to an expired value by the web server
  59. header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + 10800).' GMT');
  60. } else {
  61. header('Cache-Control: no-cache');
  62. }
  63. $manifest = new stdClass();
  64. $manifest->name = constant('DOL_APPLICATION_TITLE');
  65. if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
  66. $manifest->name = $conf->global->MAIN_APPLICATION_TITLE;
  67. }
  68. $manifest->theme_color = !empty($conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR) ? $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR : '#F05F40';
  69. $manifest->background_color = !empty($conf->global->MAIN_MANIFEST_APPLI_BG_COLOR) ? $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR : "#ffffff";
  70. $manifest->display = "standalone";
  71. $manifest->splash_pages = null;
  72. $manifest->icons = array();
  73. if (!empty($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL)) {
  74. $icon = new stdClass();
  75. $icon->src = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL;
  76. if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) {
  77. $icon->sizes = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE."x".$conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE;
  78. } else {
  79. $icon->sizes = "512x512";
  80. }
  81. $icon->type = "image/png";
  82. $manifest->icons[] = $icon;
  83. } elseif (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)) {
  84. if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI)) {
  85. $iconRelativePath = 'logos/thumbs/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI;
  86. $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
  87. if (is_readable($iconPath)) {
  88. $imgSize = getimagesize($iconPath);
  89. if (!empty($imgSize)) {
  90. $icon = new stdClass();
  91. $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
  92. $icon->sizes = $imgSize[0]."x".$imgSize[1];
  93. $icon->type = "image/png";
  94. $manifest->icons[] = $icon;
  95. }
  96. }
  97. }
  98. if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL)) {
  99. $iconRelativePath = 'logos/thumbs/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL;
  100. $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
  101. if (is_readable($iconPath)) {
  102. $imgSize = getimagesize($iconPath);
  103. if ($imgSize) {
  104. $icon = new stdClass();
  105. $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
  106. $icon->sizes = $imgSize[0]."x".$imgSize[1];
  107. $icon->type = "image/png";
  108. $manifest->icons[] = $icon;
  109. }
  110. }
  111. }
  112. if (!empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED)) {
  113. $iconRelativePath = 'logos/'.$conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED;
  114. $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
  115. if (is_readable($iconPath)) {
  116. $imgSize = getimagesize($iconPath);
  117. if ($imgSize) {
  118. $icon = new stdClass();
  119. $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
  120. $icon->sizes = $imgSize[0]."x".$imgSize[1];
  121. $icon->type = "image/png";
  122. $manifest->icons[] = $icon;
  123. }
  124. }
  125. }
  126. }
  127. // Add Dolibarr std icon
  128. if (empty($manifest->icons)) {
  129. $icon = new stdClass();
  130. $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png';
  131. $icon->sizes = "256x256";
  132. $icon->type = "image/png";
  133. $manifest->icons[] = $icon;
  134. }
  135. print json_encode($manifest);