MicroFrameWork/kernel/views/module/index.php

53 lines
1.5 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
*/
$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-09-12 16:01:04 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug'];
if ($moduleService->isActive($slug)){
$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-09-12 16:01:04 +03:00
}
else {
$label = "Активировать";
$btn_type = "primary";
2024-10-11 15:44:15 +03:00
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
2024-09-12 16:01:04 +03:00
}
return $btn;
});
2024-10-11 17:02:35 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
$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
$table->create();
$table->render();