mymodule.css.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /* Copyright (C) ---Put here your own copyright and developer email---
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/modulebuilder/template/css/mymodule.css.php
  19. * \ingroup mymodule
  20. * \brief CSS file for module MyModule.
  21. */
  22. //if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language
  23. //if (!defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled. Language code is found on url.
  24. if (!defined('NOREQUIRESOC')) {
  25. define('NOREQUIRESOC', '1');
  26. }
  27. //if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations
  28. //if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); // Should be disable only for special situation
  29. if (!defined('NOTOKENRENEWAL')) {
  30. define('NOTOKENRENEWAL', 1);
  31. }
  32. if (!defined('NOLOGIN')) {
  33. define('NOLOGIN', 1); // File must be accessed by logon page so without login
  34. }
  35. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content
  36. if (!defined('NOREQUIREHTML')) {
  37. define('NOREQUIREHTML', 1);
  38. }
  39. if (!defined('NOREQUIREAJAX')) {
  40. define('NOREQUIREAJAX', '1');
  41. }
  42. session_cache_limiter('public');
  43. // false or '' = keep cache instruction added by server
  44. // 'public' = remove cache instruction added by server
  45. // and if no cache-control added later, a default cache delay (10800) will be added by PHP.
  46. // Load Dolibarr environment
  47. $res = 0;
  48. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  49. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  50. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
  51. }
  52. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  53. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
  54. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  55. $i--; $j--;
  56. }
  57. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
  58. $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
  59. }
  60. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) {
  61. $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php";
  62. }
  63. // Try main.inc.php using relative path
  64. if (!$res && file_exists("../../main.inc.php")) {
  65. $res = @include "../../main.inc.php";
  66. }
  67. if (!$res && file_exists("../../../main.inc.php")) {
  68. $res = @include "../../../main.inc.php";
  69. }
  70. if (!$res) {
  71. die("Include of main fails");
  72. }
  73. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  74. // Load user to have $user->conf loaded (not done by default here because of NOLOGIN constant defined) and load permission if we need to use them in CSS
  75. /*if (empty($user->id) && !empty($_SESSION['dol_login'])) {
  76. $user->fetch('',$_SESSION['dol_login']);
  77. $user->getrights();
  78. }*/
  79. // Define css type
  80. header('Content-type: text/css');
  81. // Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
  82. // You can use CTRL+F5 to refresh your browser cache.
  83. if (empty($dolibarr_nocache)) {
  84. header('Cache-Control: max-age=10800, public, must-revalidate');
  85. } else {
  86. header('Cache-Control: no-cache');
  87. }
  88. ?>
  89. div.mainmenu.mymodule::before {
  90. content: "\f249";
  91. }
  92. div.mainmenu.mymodule {
  93. background-image: none;
  94. }
  95. .myclasscss {
  96. /* ... */
  97. }