functions.core.theme.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* $Id: functions.core.theme.php 2835 2007-04-08 13:20:05Z b4rt $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  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. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. /**
  16. * Get the theme that is avaible and can be used
  17. *
  18. * @return string
  19. */
  20. function CheckandSetUserTheme()
  21. {
  22. global $cfg;
  23. // check personal theme
  24. if (isset($cfg["theme"])) {
  25. if (@is_dir("themes/".$cfg["theme"]) === true)
  26. return $cfg["theme"];
  27. else
  28. echo 'Your choosen theme does not exist any more. Please got to your Profile Settings and change your theme.<br />';
  29. }
  30. // no personal theme or check failed, check default-theme
  31. if (isset($cfg["default_theme"])) {
  32. // either no theme set or we are in login
  33. if (@is_dir("themes/".$cfg["default_theme"]) === true)
  34. return $cfg["default_theme"];
  35. else
  36. echo 'The default theme (-> Login-Theme) does not exist any more. Contact the System Administrator.<br />';
  37. }
  38. // failure, use default
  39. return 'default';
  40. }
  41. /**
  42. * Get the default theme that is avaible and can be used
  43. *
  44. * @return string
  45. */
  46. function CheckandSetDefaultTheme()
  47. {
  48. global $cfg;
  49. if( isset($cfg["default_theme"]) && is_dir("themes/".$cfg["default_theme"]))
  50. {
  51. $theme = $cfg["default_theme"];
  52. }
  53. elseif ( is_dir("themes/default") )
  54. {
  55. $theme = "default";
  56. $msg = "The default theme does not exist any more. System Administrator has to change default theme.";
  57. }
  58. else
  59. die("Fatal Error: No suitable theme could be found and included.<br />Please check your Files.");
  60. // This complettely breaks theme validation, but i haven't found a quick solution to get
  61. // an error message displayed on all sites. I think we first need to change the theme-engine to be more flexible. -danez
  62. if( isset($msg) ) echo $msg;
  63. return $theme;
  64. }
  65. ?>