-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathLister.php
More file actions
97 lines (80 loc) · 2.65 KB
/
Lister.php
File metadata and controls
97 lines (80 loc) · 2.65 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Copyright (C) 2015-2019 FeatherBB
* based on code by (C) 2008-2015 FluxBB
* and Rickard Andersson (C) 2002-2008 PunBB
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*/
namespace FeatherBB\Core;
use FeatherBB\Core\Interfaces\ForumEnv;
class Lister
{
/**
* Get all valid plugin files.
*/
public static function getPlugins()
{
$plugins = [];
foreach (glob(ForumEnv::get('FEATHER_ROOT').'plugins/*/featherbb.json') as $pluginFile) {
$plugins[] = json_decode(file_get_contents($pluginFile));
}
return $plugins;
}
/**
* Load data of a single plugin
*/
public static function loadPlugin($pluginName = '')
{
return json_decode(file_get_contents(ForumEnv::get('FEATHER_ROOT').'plugins/'.$pluginName.'/featherbb.json'));
}
/**
* Get all official plugins using GitHub API
*/
public static function getOfficialPlugins()
{
$plugins = [];
// Get the official list from the website
$content = json_decode(AdminUtils::getContent('https://featherbb.org/plugins.json'));
// If internet is available
if (!is_null($content)) {
foreach ($content as $plugin) {
// Get information from each repo
// TODO: cache
$plugins[] = json_decode(AdminUtils::getContent('https://raw.githubusercontent.com/featherbb/'.$plugin.'/master/featherbb.json'));
}
}
return $plugins;
}
/**
* Get available styles
*/
public static function getStyles()
{
$styles = [];
$iterator = new \DirectoryIterator(ForumEnv::get('FEATHER_ROOT').'style/themes/');
foreach ($iterator as $child) {
if (!$child->isDot() && $child->isDir() && file_exists($child->getPathname().DIRECTORY_SEPARATOR.'style.css')) {
// If the theme is well formed, add it to the list
$styles[] = $child->getFileName();
}
}
natcasesort($styles);
return $styles;
}
/**
* Get available langs
*/
public static function getLangs($folder = '')
{
$langs = [];
$iterator = new \DirectoryIterator(ForumEnv::get('FEATHER_ROOT').'featherbb/lang/');
foreach ($iterator as $child) {
if (!$child->isDot() && $child->isDir() && file_exists($child->getPathname().DIRECTORY_SEPARATOR.'common.po')) {
// If the lang pack is well formed, add it to the list
$langs[] = $child->getFileName();
}
}
natcasesort($langs);
return $langs;
}
}