module fix
This commit is contained in:
parent
94496910d7
commit
d9c4cecd48
@ -84,7 +84,7 @@ class AdminConsoleController extends ConsoleController
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Настройки",
|
||||
"url" => "/admin/settings",
|
||||
"url" => "#",
|
||||
"slug" => "settings",
|
||||
]);
|
||||
$this->out->r("create item menu settings", "green");
|
||||
|
@ -22,8 +22,9 @@ class ModuleController extends AdminController
|
||||
$this->moduleService = new ModuleService();
|
||||
}
|
||||
|
||||
public function actionIndex(): void
|
||||
public function actionIndex($page_number = 1): void
|
||||
{
|
||||
$per_page = 8;
|
||||
$module_paths = Option::where("key", "module_paths")->first();
|
||||
$dirs = [];
|
||||
if ($module_paths){
|
||||
@ -34,8 +35,8 @@ class ModuleController extends AdminController
|
||||
}
|
||||
|
||||
$modules_info = [];
|
||||
$i = 1;
|
||||
foreach ($dirs as $dir){
|
||||
$i = 1;
|
||||
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
||||
$info = [];
|
||||
if($fileInfo->isDot()) continue;
|
||||
@ -44,8 +45,15 @@ class ModuleController extends AdminController
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cgView->render("index.php", ['modules_info' => $modules_info, 'moduleService' => $this->moduleService]);
|
||||
$module_count = count($modules_info);
|
||||
$modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page);
|
||||
$this->cgView->render("index.php", [
|
||||
'modules_info' => $modules_info,
|
||||
'moduleService' => $this->moduleService,
|
||||
'page_number' => $page_number,
|
||||
'module_count' => $module_count,
|
||||
'per_page' => $per_page,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionActivate(): void
|
||||
|
@ -8,6 +8,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||
App::$collector->group(["before" => "auth"], function (RouteCollector $router){
|
||||
App::$collector->group(["prefix" => "module"], function (RouteCollector $router){
|
||||
App::$collector->get('/', [\kernel\controllers\ModuleController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\kernel\controllers\ModuleController::class, 'actionIndex']);
|
||||
App::$collector->get('/activate', [\kernel\controllers\ModuleController::class, 'actionActivate']);
|
||||
App::$collector->get('/view', [\kernel\controllers\ModuleController::class, 'actionView']);
|
||||
});
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @var array $modules_info
|
||||
* @var int $module_count
|
||||
* @var int $page_number
|
||||
* @var int $per_page
|
||||
* @var \kernel\services\ModuleService $moduleService
|
||||
*/
|
||||
|
||||
@ -12,10 +15,10 @@ $meta['columns'] = [
|
||||
"description" => "Описание"
|
||||
];
|
||||
$meta['params'] = ["class" => "table table-bordered"];
|
||||
$meta['perPage'] = 10;
|
||||
$meta['perPage'] = $per_page;
|
||||
$meta['baseUrl'] = "/admin/module";
|
||||
$meta['currentPage'] = 1;
|
||||
$meta['total'] = count($modules_info);
|
||||
$meta['currentPage'] = $page_number;
|
||||
$meta['total'] = $module_count;
|
||||
|
||||
$info_to_table['meta'] = $meta;
|
||||
$info_to_table['data'] = $modules_info;
|
||||
|
Loading…
Reference in New Issue
Block a user