42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* @var array $modules_info
|
||
|
* @var \kernel\services\ModuleService $moduleService
|
||
|
*/
|
||
|
|
||
|
$meta = [];
|
||
|
$meta['columns'] = [
|
||
|
"name" => "Название",
|
||
|
"author" => "Автор",
|
||
|
"version" => "Версия",
|
||
|
"description" => "Описание"
|
||
|
];
|
||
|
$meta['params'] = ["class" => "table table-bordered"];
|
||
|
$meta['perPage'] = 10;
|
||
|
$meta['baseUrl'] = "/admin/module";
|
||
|
$meta['currentPage'] = 1;
|
||
|
$meta['total'] = count($modules_info);
|
||
|
|
||
|
$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));
|
||
|
|
||
|
$table->addAction(function ($row, $url) use ($moduleService){
|
||
|
$slug = $row['slug'];
|
||
|
if ($moduleService->isActive($slug)){
|
||
|
$label = "Деактивировать";
|
||
|
$btn_type = "warning";
|
||
|
}
|
||
|
else {
|
||
|
$label = "Активировать";
|
||
|
$btn_type = "primary";
|
||
|
}
|
||
|
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||
|
|
||
|
return $btn;
|
||
|
});
|
||
|
|
||
|
$table->create();
|
||
|
$table->render();
|