blob: 83db85acfc7ec2a2a8a3a4f8604fdc0358012c3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
class RSSThemes extends Model {
private static $themes_dir = '/themes';
private static $list = array();
public static function init() {
$basedir = PUBLIC_PATH . self::$themes_dir;
$themes_list = array_diff(
scandir($basedir),
array('..', '.')
);
foreach ($themes_list as $theme_dir) {
$json_filename = $basedir . '/' . $theme_dir . '/metadata.json';
if(file_exists($json_filename)) {
$content = file_get_contents($json_filename);
$res = json_decode($content, true);
if($res &&
isset($res['name']) &&
isset($res['author']) &&
isset($res['description']) &&
isset($res['version']) &&
isset($res['files']) && is_array($res['files'])) {
$theme = $res;
$theme['path'] = $theme_dir;
self::$list[$theme_dir] = $theme;
}
}
}
}
public static function get() {
return self::$list;
}
public static function get_infos($theme_id) {
if (isset(self::$list[$theme_id])) {
return self::$list[$theme_id];
}
return false;
}
}
|