From 127e03081ce33f34f67cee031b0d13ab8c1f4735 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 15 Apr 2024 21:21:16 +0200 Subject: [PATCH] Support for subfolders in plugins/pages --- system/src/Plugins.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/system/src/Plugins.php b/system/src/Plugins.php index d30a2497..1421c630 100644 --- a/system/src/Plugins.php +++ b/system/src/Plugins.php @@ -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'])) {