RSSThemes.php 808 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class RSSThemes extends Model {
  3. private static $themes_dir = '/themes';
  4. private static $list = array();
  5. public static function init() {
  6. $basedir = PUBLIC_PATH . self::$themes_dir;
  7. $themes_list = array_diff(
  8. scandir($basedir),
  9. array('..', '.')
  10. );
  11. foreach ($themes_list as $theme_dir) {
  12. $json_filename = $basedir . '/' . $theme_dir . '/metadata.json';
  13. if(file_exists($json_filename)) {
  14. $content = file_get_contents($json_filename);
  15. $res = json_decode($content, true);
  16. if($res &&
  17. isset($res['name']) &&
  18. isset($res['author']) &&
  19. isset($res['description']) &&
  20. isset($res['version'])) {
  21. $theme = $res;
  22. $theme['path'] = $theme_dir;
  23. self::$list[] = $theme;
  24. }
  25. }
  26. }
  27. }
  28. public static function get() {
  29. return self::$list;
  30. }
  31. }