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
|
|
|
|
*/
|
|
|
|
|
2024-12-02 16:25:28 +03:00
|
|
|
use kernel\Flash;
|
2024-11-20 12:45:02 +03:00
|
|
|
use kernel\widgets\IconBtn\IconBtnActivateWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnDeactivateWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnUpdateWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
2024-11-19 14:55:25 +03:00
|
|
|
use kernel\widgets\ModuleTabsWidget;
|
2024-11-19 13:41:13 +03:00
|
|
|
|
2024-09-12 16:01:04 +03:00
|
|
|
$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-11-05 13:44:08 +03:00
|
|
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
2024-09-12 16:01:04 +03:00
|
|
|
$slug = $row['slug'];
|
2024-11-05 13:44:08 +03:00
|
|
|
if ($moduleService->isActive($slug)) {
|
2024-11-20 12:45:02 +03:00
|
|
|
$url = "$url/deactivate/?slug=". $row['slug'];
|
2024-10-11 15:44:15 +03:00
|
|
|
|
2024-11-20 12:45:02 +03:00
|
|
|
return IconBtnDeactivateWidget::create(['url' => $url])->run();
|
2024-11-05 13:44:08 +03:00
|
|
|
} else {
|
2024-11-20 12:45:02 +03:00
|
|
|
$url = "$url/activate/?slug=". $row['slug'];
|
|
|
|
|
|
|
|
return IconBtnActivateWidget::create(['url' => $url])->run();
|
2024-11-19 13:41:13 +03:00
|
|
|
}
|
2024-09-12 16:01:04 +03:00
|
|
|
});
|
2024-10-11 17:02:35 +03:00
|
|
|
|
2024-11-20 12:52:26 +03:00
|
|
|
|
2024-11-05 13:44:08 +03:00
|
|
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
2024-11-20 12:45:02 +03:00
|
|
|
$url = "$url/view/?slug=". $row['slug'];
|
2024-11-19 13:41:13 +03:00
|
|
|
|
2024-11-20 12:45:02 +03:00
|
|
|
return IconBtnViewWidget::create(['url' => $url])->run();
|
2024-09-23 12:50:50 +03:00
|
|
|
});
|
2024-09-12 16:01:04 +03:00
|
|
|
|
2024-11-18 15:55:43 +03:00
|
|
|
$table->addAction(function ($row, $url) use ($moduleService){
|
2024-12-02 16:50:44 +03:00
|
|
|
if ($moduleService->isShopModule($row['slug'])){
|
2024-11-20 12:45:02 +03:00
|
|
|
if (!$moduleService->isLastVersion($row['slug'])) {
|
|
|
|
$url = "$url/update/?slug=". $row['slug'];
|
|
|
|
|
|
|
|
return IconBtnUpdateWidget::create(['url' => $url])->run();
|
2024-11-18 15:55:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2024-11-19 12:27:52 +03:00
|
|
|
$table->addAction(function ($row) use ($moduleService){
|
2024-11-18 15:55:43 +03:00
|
|
|
$slug = $row['slug'];
|
2024-11-19 14:55:25 +03:00
|
|
|
if (!$moduleService->isKernelModule($slug)) {
|
2024-11-20 12:45:02 +03:00
|
|
|
$url = "admin/module_shop_client/delete/?slug=" . $row['slug'];
|
|
|
|
|
|
|
|
return IconBtnDeleteWidget::create(['url' => $url])->run();
|
2024-11-18 15:55:43 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2024-10-14 15:52:52 +03:00
|
|
|
|
2024-12-04 15:36:11 +03:00
|
|
|
if ($moduleService->isActive('module_shop_client')) {
|
2024-11-19 14:55:25 +03:00
|
|
|
ModuleTabsWidget::create()->run();
|
2024-11-05 15:36:46 +03:00
|
|
|
}
|
2024-11-19 13:41:13 +03:00
|
|
|
|
2024-12-04 15:36:11 +03:00
|
|
|
|
|
|
|
|
2024-11-19 13:41:13 +03:00
|
|
|
$table->create();
|
2024-09-12 16:01:04 +03:00
|
|
|
$table->render();
|