2024-09-12 16:01:04 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @var array $modules_info
|
2024-10-10 22:40:09 +03:00
|
|
|
* @var int $module_count
|
|
|
|
* @var int $page_number
|
|
|
|
* @var int $per_page
|
2024-09-12 16:01:04 +03:00
|
|
|
* @var \kernel\services\ModuleService $moduleService
|
|
|
|
*/
|
|
|
|
|
|
|
|
$meta = [];
|
|
|
|
$meta['columns'] = [
|
|
|
|
"name" => "Название",
|
|
|
|
"author" => "Автор",
|
|
|
|
"version" => "Версия",
|
|
|
|
"description" => "Описание"
|
|
|
|
];
|
|
|
|
$meta['params'] = ["class" => "table table-bordered"];
|
2024-10-10 22:40:09 +03:00
|
|
|
$meta['perPage'] = $per_page;
|
2024-09-12 16:01:04 +03:00
|
|
|
$meta['baseUrl'] = "/admin/module";
|
2024-10-10 22:40:09 +03:00
|
|
|
$meta['currentPage'] = $page_number;
|
|
|
|
$meta['total'] = $module_count;
|
2024-09-12 16:01:04 +03:00
|
|
|
|
|
|
|
$info_to_table['meta'] = $meta;
|
|
|
|
$info_to_table['data'] = $modules_info;
|
|
|
|
|
|
|
|
$table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
|
|
|
2024-10-11 17:02:35 +03:00
|
|
|
|
2024-11-18 16:04:57 +03:00
|
|
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
2024-09-12 16:01:04 +03:00
|
|
|
$slug = $row['slug'];
|
2024-11-18 16:04:57 +03:00
|
|
|
if ($moduleService->isActive($slug)) {
|
2024-09-12 16:01:04 +03:00
|
|
|
$label = "Деактивировать";
|
|
|
|
$btn_type = "warning";
|
2024-10-11 15:44:15 +03:00
|
|
|
$btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
|
|
|
|
2024-11-18 16:04:57 +03:00
|
|
|
} else {
|
2024-11-19 12:31:48 +03:00
|
|
|
$label = "<i class='fa-regular fa-circle-check'></i>";
|
2024-11-18 16:04:57 +03:00
|
|
|
$btn_type = "success";
|
2024-11-19 12:31:48 +03:00
|
|
|
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px;' >$label</a>";
|
2024-09-12 16:01:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $btn;
|
|
|
|
});
|
2024-10-11 17:02:35 +03:00
|
|
|
|
2024-11-18 16:04:57 +03:00
|
|
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
2024-09-23 12:50:50 +03:00
|
|
|
$slug = $row['slug'];
|
|
|
|
return "<a class='btn btn-primary' href='$url/view/?slug=$slug' style='margin: 3px; width: 150px;' >Просмотр</a>";
|
|
|
|
});
|
2024-09-12 16:01:04 +03:00
|
|
|
|
2024-10-14 15:52:52 +03:00
|
|
|
$table->addAction(function ($row, $url) use ($moduleService){
|
|
|
|
$slug = $row['slug'];
|
2024-11-18 16:04:57 +03:00
|
|
|
if (!$moduleService->isKernelModule($slug)){
|
|
|
|
if (!$moduleService->isLastVersion($slug)) {
|
|
|
|
$label = "Обновить";
|
|
|
|
$btn_type = "info";
|
|
|
|
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2024-11-19 12:31:48 +03:00
|
|
|
$table->addAction(function ($row) use ($moduleService){
|
2024-11-18 16:04:57 +03:00
|
|
|
$slug = $row['slug'];
|
|
|
|
if (!$moduleService->isKernelModule($slug)){
|
|
|
|
$label = "Удалить";
|
|
|
|
$btn_type = "danger";
|
|
|
|
return "<a class='btn btn-$btn_type' href='admin/module_shop_client/delete/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
|
|
|
}
|
|
|
|
return false;
|
2024-10-14 15:52:52 +03:00
|
|
|
});
|
|
|
|
|
2024-09-12 16:01:04 +03:00
|
|
|
$table->create();
|
2024-11-18 16:04:57 +03:00
|
|
|
|
|
|
|
if ($moduleService->isActive('module_shop_client')) {
|
|
|
|
\kernel\widgets\ModuleTabsWidget::create()->run();
|
|
|
|
}
|
2024-09-12 16:01:04 +03:00
|
|
|
$table->render();
|