Support for subfolders in plugins/pages

This commit is contained in:
slawkens 2024-04-15 21:21:16 +02:00
parent e9c6017e60
commit 127e03081c

View File

@ -23,6 +23,9 @@ class Plugins {
$routes = [];
foreach(self::getAllPluginsJson() as $plugin) {
//
// Get all plugins/*/pages/*.php pages
//
$pluginPages = glob(PLUGINS . $plugin['filename'] . '/pages/*.php');
foreach ($pluginPages as $file) {
$file = str_replace(PLUGINS, 'plugins/', $file);
@ -31,6 +34,22 @@ class Plugins {
$routes[] = [['get', 'post'], $name, $file, 1000];
}
//
// Get all plugins/*/pages/subFolder/*.php pages
//
$pluginSubFolders = glob(PLUGINS . $plugin['filename'] . '/pages/*', GLOB_ONLYDIR);
foreach ($pluginSubFolders as $folder) {
$folderName = pathinfo($folder, PATHINFO_FILENAME);
$subFolders = glob(PLUGINS . $plugin['filename'] . '/pages/' . $folderName . '/*.php');
foreach ($subFolders as $file) {
$file = str_replace(PLUGINS, 'plugins/', $file);
$name = $folderName . '/' . pathinfo($file, PATHINFO_FILENAME);
$routes[] = [['get', 'post'], $name, $file, 1000];
}
}
$warningPreTitle = 'Plugin: ' . $plugin['name'] . ' - ';
if (isset($plugin['routes'])) {