RSSThemes.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. isset($res['files']) && is_array($res['files'])) {
  22. $theme = $res;
  23. $theme['path'] = $theme_dir;
  24. self::$list[$theme_dir] = $theme;
  25. }
  26. }
  27. }
  28. }
  29. public static function get() {
  30. return self::$list;
  31. }
  32. public static function get_infos($theme_id) {
  33. if (isset(self::$list[$theme_id])) {
  34. return self::$list[$theme_id];
  35. }
  36. return false;
  37. }
  38. public static function icon($name) {
  39. static $alts = array(
  40. 'add' => '✚',
  41. 'all' => '☰',
  42. 'bookmark' => '★',
  43. 'category' => '☷',
  44. 'category-white' => '☷',
  45. 'close' => '❌',
  46. 'configure' => '⚙',
  47. 'down' => '▽',
  48. 'favorite' => '★',
  49. 'help' => 'ⓘ',
  50. 'link' => '↗',
  51. 'login' => '🔒',
  52. 'logout' => '🔓',
  53. 'next' => '⏩',
  54. 'non-starred' => '☆',
  55. 'prev' => '⏪',
  56. 'read' => '☑',
  57. 'unread' => '☐',
  58. 'refresh' => '🔃', //↻
  59. 'search' => '🔍',
  60. 'share' => '♺',
  61. 'starred' => '★',
  62. 'tag' => '⚐',
  63. 'up' => '△',
  64. );
  65. $alt = isset($alts[$name]) ? $alts[$name] : '?';
  66. return '<i class="icon i_' . $name . '">' . $alts[$name] . '</i>';
  67. //return '<img class="icon" src="' . Url::display('/themes/icons/' . $name . '.svg') . '" alt="' . $alts[$name] . '" />';
  68. }
  69. }