backend/kernel/modules/module_shop_client/views/index.php

69 lines
1.9 KiB
PHP
Raw Normal View History

2024-10-29 14:53:52 +03:00
<?php
/**
* @var array $modules_info
* @var int $module_count
* @var int $page_number
* @var int $per_page
2024-10-31 16:12:02 +03:00
* @var \kernel\services\ModuleService $moduleService
2024-10-29 14:53:52 +03:00
*/
use Itguild\Tables\ListJsonTable;
2024-11-19 14:55:25 +03:00
use kernel\widgets\ActionButtonWidget;
2024-10-29 14:53:52 +03:00
$meta = [];
$meta['columns'] = [
"name" => "Название",
"author" => "Автор",
"version" => "Версия",
"description" => "Описание",
"installations" => "Установки",
"views" => "Просмотры"
];
$meta['params'] = ["class" => "table table-bordered"];
$meta['perPage'] = $per_page;
$meta['baseUrl'] = "/admin/module_shop_client";
$meta['currentPage'] = $page_number;
$meta['total'] = $module_count;
$info_to_table['meta'] = $meta;
$info_to_table['data'] = $modules_info;
$table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
2024-11-19 14:55:25 +03:00
$table->addAction(function ($row, $url) use ($moduleService) {
2024-11-20 12:45:02 +03:00
$url = "$url/view/" . $row['id'];
2024-11-19 14:55:25 +03:00
2024-11-20 12:45:02 +03:00
return \kernel\widgets\IconBtn\IconBtnViewWidget::create(['url' => $url])->run();
2024-11-19 14:55:25 +03:00
});
2024-10-29 14:53:52 +03:00
2024-10-31 16:12:02 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
2024-11-20 12:45:02 +03:00
if ($moduleService->isInstall($row['slug'])){
$url = "$url/delete/?slug=" . $row['slug'];
return \kernel\widgets\IconBtn\IconBtnDeleteWidget::create(['url' => $url])->run();
2024-10-31 16:12:02 +03:00
}
else {
2024-11-20 12:45:02 +03:00
$url = "$url/install/?id=" . $row['id'];
return \kernel\widgets\IconBtn\IconBtnInstallWidget::create(['url' => $url])->run();
2024-10-31 16:12:02 +03:00
}
});
2024-10-29 14:53:52 +03:00
2024-11-14 01:55:04 +03:00
$table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug'];
if ($moduleService->isInstall($slug)){
if (!$moduleService->isLastVersion($slug)) {
2024-11-20 12:45:02 +03:00
$url = "$url/update/?slug=" . $slug;
return \kernel\widgets\IconBtn\IconBtnUpdateWidget::create(['url' => $url])->run();
2024-11-14 01:55:04 +03:00
}
}
return false;
2024-11-14 01:55:04 +03:00
});
2024-11-20 12:45:02 +03:00
\kernel\widgets\ModuleTabsWidget::create()->run();
2024-10-29 14:53:52 +03:00
$table->create();
$table->render();