diff --git a/kernel/modules/admin_themes/manifest.json b/kernel/modules/admin_themes/manifest.json index b792723..50341e3 100644 --- a/kernel/modules/admin_themes/manifest.json +++ b/kernel/modules/admin_themes/manifest.json @@ -4,5 +4,6 @@ "author": "ITGuild", "slug": "admin_themes", "description": "Admin themes module", - "module_class": "AdminThemesModule" + "module_class": "AdminThemesModule", + "routs": "routs/adminThemes.php" } \ No newline at end of file diff --git a/kernel/modules/admin_themes/routs/adminThemes.php b/kernel/modules/admin_themes/routs/adminThemes.php new file mode 100644 index 0000000..44e1110 --- /dev/null +++ b/kernel/modules/admin_themes/routs/adminThemes.php @@ -0,0 +1,20 @@ +group(["prefix" => "admin"], function (RouteCollector $router){ + App::$collector->group(["prefix" => "settings"], function (RouteCollector $router){ + App::$collector->group(["prefix" => "admin-themes"], function (RouteCollector $router){ + App::$collector->get('/', [AdminThemeController::class, 'actionIndex']); + App::$collector->get('/activate', [AdminThemeController::class, 'actionActivate']); + // App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']); + // App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']); + // App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']); + // App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']); + // App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']); + // App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']); + }); + }); +}); \ No newline at end of file diff --git a/kernel/modules/menu/manifest.json b/kernel/modules/menu/manifest.json index c8b0d69..b8777ee 100644 --- a/kernel/modules/menu/manifest.json +++ b/kernel/modules/menu/manifest.json @@ -4,5 +4,6 @@ "author": "ITGuild", "slug": "menu", "description": "Menu module", - "module_class": "MenuModule" + "module_class": "MenuModule", + "routs": "routs/menu.php" } \ No newline at end of file diff --git a/kernel/modules/menu/routs/menu.php b/kernel/modules/menu/routs/menu.php new file mode 100644 index 0000000..14b907b --- /dev/null +++ b/kernel/modules/menu/routs/menu.php @@ -0,0 +1,19 @@ +group(["prefix" => "admin"], function (RouteCollector $router) { + App::$collector->group(["prefix" => "settings"], function (RouteCollector $router){ + App::$collector->group(["prefix" => "menu"], function (RouteCollector $router){ + App::$collector->get('/', [\kernel\modules\menu\controllers\MenuController::class, 'actionIndex']); + App::$collector->get('/page/{page_number}', [\kernel\modules\menu\controllers\MenuController::class, 'actionIndex']); + App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']); + App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']); + App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']); + App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']); + App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']); + App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']); + }); + }); +}); \ No newline at end of file diff --git a/kernel/modules/post/routs/post.php b/kernel/modules/post/routs/post.php index 3c48150..7b2ec42 100644 --- a/kernel/modules/post/routs/post.php +++ b/kernel/modules/post/routs/post.php @@ -1,8 +1,6 @@ group(["prefix" => "admin"], function (RouteCollector $router){ App::$collector->group(["prefix" => "module"], function (RouteCollector $router){ App::$collector->get('/', [\kernel\controllers\ModuleController::class, 'actionIndex']); App::$collector->get('/activate', [\kernel\controllers\ModuleController::class, 'actionActivate']); - App::$collector->get('/view', [\kernel\controllers\ModuleController::class, 'actionView']); - }); - App::$collector->group(["prefix" => "settings"], function (RouteCollector $router){ - App::$collector->group(["prefix" => "menu"], function (RouteCollector $router){ - App::$collector->get('/', [\kernel\modules\menu\controllers\MenuController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\kernel\modules\menu\controllers\MenuController::class, 'actionIndex']); - App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']); - App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']); - App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']); - App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']); - }); - App::$collector->group(["prefix" => "admin-themes"], function (RouteCollector $router){ - App::$collector->get('/', [AdminThemeController::class, 'actionIndex']); - App::$collector->get('/activate', [AdminThemeController::class, 'actionActivate']); -// App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']); -// App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']); -// App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']); -// App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']); -// App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']); -// App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']); - }); }); }); \ No newline at end of file diff --git a/kernel/services/ModuleService.php b/kernel/services/ModuleService.php index 5a56020..f787be5 100644 --- a/kernel/services/ModuleService.php +++ b/kernel/services/ModuleService.php @@ -107,6 +107,7 @@ class ModuleService { $modules = []; $module_paths = Option::where("key", "module_paths")->first(); + $active_modules = Option::where("key", "active_modules")->first(); $dirs = []; if ($module_paths) { $path = json_decode($module_paths->value); @@ -115,13 +116,15 @@ class ModuleService } } + $active_modules = json_decode($active_modules->value, true); + foreach ($dirs as $dir) { foreach (new DirectoryIterator($dir) as $fileInfo) { - if($fileInfo->isDot()) continue; + if($fileInfo->isDot() or !in_array($fileInfo->getFilename(), $active_modules['modules'])) continue; $modules[] = $this->getModuleInfo($fileInfo->getPathname()); } } - + return $modules; }