Theme.class.php 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Manage themes
  4. * @author Valentin carruesco
  5. * @category Plugin
  6. * @license MIT
  7. */
  8. class Theme{
  9. public static function dir(){
  10. return File::dir().'theme'.SLASH;
  11. }
  12. public static function getAll(){
  13. global $conf;
  14. $themes = array(
  15. array(
  16. "label" => "Aucun thème",
  17. "folder" => "",
  18. "css-relative-url" => "",
  19. "path" => "",
  20. "checked" => $conf->get('core_theme') == "",
  21. "last-update" => 0
  22. )
  23. );
  24. $dir = self::dir();
  25. if(!file_exists($dir)) mkdir($dir,0755,true);
  26. foreach(glob($dir.SLASH.'*'.SLASH.'app.json') as $themeFile){
  27. $path = dirname($themeFile);
  28. $theme = json_decode(file_get_contents($themeFile),true);
  29. $theme['folder'] = $path;
  30. $theme['css-relative-url'] = '/media/theme/'.basename($path).'/public/main.css';
  31. $theme['checked'] = $conf->get('core_theme') == $theme['css-relative-url'];
  32. $theme['last-update'] = filemtime($themeFile);
  33. $themes[] = $theme;
  34. }
  35. return $themes;
  36. }
  37. }
  38. ?>