MicroFrameWork/kernel/views/module/index.php

93 lines
2.6 KiB
PHP
Raw Normal View History

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-11-19 13:41:13 +03:00
use kernel\widgets\ActionButtonWidget;
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-10-11 17:02:35 +03:00
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-19 14:55:25 +03:00
return ActionButtonWidget::create([
2024-11-19 13:41:13 +03:00
'btn_type' => "warning",
'label' => "<i class='fa-regular fa-circle-xmark'></i>",
'url' => "$url/deactivate/?slug=$slug",
2024-11-19 14:55:25 +03:00
])->run();
2024-10-11 15:44:15 +03:00
2024-11-05 13:44:08 +03:00
} else {
2024-11-19 14:08:43 +03:00
return ActionButtonWidget::create([
2024-11-19 13:41:13 +03:00
'label' => "<i class='fa-regular fa-circle-check'></i>",
'url' => "$url/deactivate/?slug=$slug",
'btn_type' => "success"
])->run();
}
2024-09-12 16:01:04 +03:00
});
2024-10-11 17:02:35 +03:00
2024-11-05 13:44:08 +03:00
$table->addAction(function ($row, $url) use ($moduleService) {
$slug = $row['slug'];
2024-11-19 13:41:13 +03:00
2024-11-19 14:55:25 +03:00
return ActionButtonWidget::create([
2024-11-19 13:41:13 +03:00
'btn_type' => "primary",
'label' => "<i class='fa-regular fa-eye'></i>",
'url' => "$url/view/?slug=$slug",
2024-11-19 14:55:25 +03:00
])->run();
});
2024-09-12 16:01:04 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug'];
if (!$moduleService->isKernelModule($slug)){
if (!$moduleService->isLastVersion($slug)) {
2024-11-19 14:55:25 +03:00
return ActionButtonWidget::create([
'btn_type' => "info",
'label' => "<i class='fa-regular fa-pen-to-square'></i>",
'url' => "$url/view/?slug=$slug",
])->run();
}
}
return false;
});
2024-11-19 12:27:52 +03:00
$table->addAction(function ($row) use ($moduleService){
$slug = $row['slug'];
2024-11-19 14:55:25 +03:00
if (!$moduleService->isKernelModule($slug)) {
return ActionButtonWidget::create([
2024-11-19 13:41:13 +03:00
'btn_type' => "danger",
'label' => "<i class='fa-regular fa-trash-can'></i>",
'url' => "admin/module_shop_client/delete/?slug=$slug",
2024-11-19 14:55:25 +03:00
])->run();
}
return false;
});
2024-10-14 15:52:52 +03:00
2024-11-05 15:36:46 +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
$table->create();
2024-09-12 16:01:04 +03:00
$table->render();