manifest.json.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
  66. $manifest->name = $conf->global->MAIN_APPLICATION_TITLE;
  67. }
  68. $manifest->short_name = $manifest->name;
  69. $manifest->theme_color = !getDolGlobalString('MAIN_MANIFEST_APPLI_THEME_COLOR') ? getDolGlobalString('THEME_ELDY_TOPMENU_BACK1', '#F05F40') : $conf->global->MAIN_MANIFEST_APPLI_THEME_COLOR;
  70. $manifest->background_color = !getDolGlobalString('MAIN_MANIFEST_APPLI_BG_COLOR') ? "#ffffff" : $conf->global->MAIN_MANIFEST_APPLI_BG_COLOR;
  71. $manifest->display = "standalone";
  72. $manifest->splash_pages = null;
  73. $manifest->icons = array();
  74. $manifest->start_url = constant('DOL_MAIN_URL_ROOT');
  75. $manifest->id = constant('DOL_MAIN_URL_ROOT');
  76. if (getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL')) {
  77. $icon = new stdClass();
  78. $icon->src = $conf->global->MAIN_MANIFEST_APPLI_LOGO_URL;
  79. if ($conf->global->MAIN_MANIFEST_APPLI_LOGO_URL_SIZE) {
  80. $icon->sizes = getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE') . "x" . getDolGlobalString('MAIN_MANIFEST_APPLI_LOGO_URL_SIZE');
  81. } else {
  82. $icon->sizes = "512x512";
  83. }
  84. $icon->type = "image/png";
  85. $manifest->icons[] = $icon;
  86. } elseif (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED')) {
  87. if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI')) {
  88. $iconRelativePath = 'logos/thumbs/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI');
  89. $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
  90. if (is_readable($iconPath)) {
  91. $imgSize = getimagesize($iconPath);
  92. if (!empty($imgSize)) {
  93. $icon = new stdClass();
  94. $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
  95. $icon->sizes = $imgSize[0]."x".$imgSize[1];
  96. $icon->type = "image/png";
  97. $manifest->icons[] = $icon;
  98. }
  99. }
  100. }
  101. if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL')) {
  102. $iconRelativePath = 'logos/thumbs/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED_SMALL');
  103. $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
  104. if (is_readable($iconPath)) {
  105. $imgSize = getimagesize($iconPath);
  106. if ($imgSize) {
  107. $icon = new stdClass();
  108. $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
  109. $icon->sizes = $imgSize[0]."x".$imgSize[1];
  110. $icon->type = "image/png";
  111. $manifest->icons[] = $icon;
  112. }
  113. }
  114. }
  115. if (getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED')) {
  116. $iconRelativePath = 'logos/' . getDolGlobalString('MAIN_INFO_SOCIETE_LOGO_SQUARRED');
  117. $iconPath = $conf->mycompany->dir_output.'/'.$iconRelativePath;
  118. if (is_readable($iconPath)) {
  119. $imgSize = getimagesize($iconPath);
  120. if ($imgSize) {
  121. $icon = new stdClass();
  122. $icon->src = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($iconRelativePath);
  123. $icon->sizes = $imgSize[0]."x".$imgSize[1];
  124. $icon->type = "image/png";
  125. $manifest->icons[] = $icon;
  126. }
  127. }
  128. }
  129. }
  130. // Add Dolibarr std icon
  131. if (empty($manifest->icons)) {
  132. $icon = new stdClass();
  133. $icon->src = DOL_URL_ROOT.'/theme/dolibarr_256x256_color.png';
  134. $icon->sizes = "256x256";
  135. $icon->type = "image/png";
  136. $manifest->icons[] = $icon;
  137. }
  138. print json_encode($manifest);