This commit is contained in:
Kavalar 2024-09-23 12:53:49 +03:00
commit f4971f1c7d
7 changed files with 48 additions and 29 deletions

View File

@ -4,5 +4,6 @@
"author": "ITGuild", "author": "ITGuild",
"slug": "admin_themes", "slug": "admin_themes",
"description": "Admin themes module", "description": "Admin themes module",
"module_class": "AdminThemesModule" "module_class": "AdminThemesModule",
"routs": "routs/adminThemes.php"
} }

View File

@ -0,0 +1,20 @@
<?php
use kernel\App;
use kernel\modules\admin_themes\controllers\AdminThemeController;
use Phroute\Phroute\RouteCollector;
App::$collector->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']);
});
});
});

View File

@ -4,5 +4,6 @@
"author": "ITGuild", "author": "ITGuild",
"slug": "menu", "slug": "menu",
"description": "Menu module", "description": "Menu module",
"module_class": "MenuModule" "module_class": "MenuModule",
"routs": "routs/menu.php"
} }

View File

@ -0,0 +1,19 @@
<?php
use kernel\App;
use Phroute\Phroute\RouteCollector;
App::$collector->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']);
});
});
});

View File

@ -1,8 +1,6 @@
<?php <?php
use app\controllers\MainController;
use kernel\App; use kernel\App;
use kernel\modules\admin_themes\controllers\AdminThemeController;
use Phroute\Phroute\RouteCollector; use Phroute\Phroute\RouteCollector;

View File

@ -10,28 +10,5 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
App::$collector->group(["prefix" => "module"], function (RouteCollector $router){ App::$collector->group(["prefix" => "module"], function (RouteCollector $router){
App::$collector->get('/', [\kernel\controllers\ModuleController::class, 'actionIndex']); App::$collector->get('/', [\kernel\controllers\ModuleController::class, 'actionIndex']);
App::$collector->get('/activate', [\kernel\controllers\ModuleController::class, 'actionActivate']); 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']);
});
}); });
}); });

View File

@ -107,6 +107,7 @@ class ModuleService
{ {
$modules = []; $modules = [];
$module_paths = Option::where("key", "module_paths")->first(); $module_paths = Option::where("key", "module_paths")->first();
$active_modules = Option::where("key", "active_modules")->first();
$dirs = []; $dirs = [];
if ($module_paths) { if ($module_paths) {
$path = json_decode($module_paths->value); $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 ($dirs as $dir) {
foreach (new DirectoryIterator($dir) as $fileInfo) { 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()); $modules[] = $this->getModuleInfo($fileInfo->getPathname());
} }
} }
return $modules; return $modules;
} }