kernel update
This commit is contained in:
parent
10605e17e7
commit
2af9ea876d
@ -17,7 +17,8 @@
|
|||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"josantonius/session": "^2.0",
|
"josantonius/session": "^2.0",
|
||||||
"firebase/php-jwt": "^6.10",
|
"firebase/php-jwt": "^6.10",
|
||||||
"k-adam/env-editor": "^2.0"
|
"k-adam/env-editor": "^2.0",
|
||||||
|
"guzzlehttp/guzzle": "^7.9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
17
kernel/IGTabel/action_column/InstallActionColumn.php
Normal file
17
kernel/IGTabel/action_column/InstallActionColumn.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace kernel\IGTabel\action_column;
|
||||||
|
|
||||||
|
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||||
|
|
||||||
|
class InstallActionColumn extends ActionColumn
|
||||||
|
{
|
||||||
|
|
||||||
|
protected string $prefix = '/install/';
|
||||||
|
|
||||||
|
public function fetch()
|
||||||
|
{
|
||||||
|
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||||
|
return " <a href='$link' class='btn btn-warning'>Установить</a> ";
|
||||||
|
}
|
||||||
|
}
|
@ -3,10 +3,11 @@
|
|||||||
namespace kernel\IGTabel\action_column;
|
namespace kernel\IGTabel\action_column;
|
||||||
|
|
||||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||||
|
use kernel\helpers\Debug;
|
||||||
|
|
||||||
class ViewActionColumn extends ActionColumn
|
class ViewActionColumn extends ActionColumn
|
||||||
{
|
{
|
||||||
protected string $prefix = '/';
|
protected string $prefix = '/view/';
|
||||||
|
|
||||||
public function fetch(): string
|
public function fetch(): string
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ use Josantonius\Session\Facades\Session;
|
|||||||
use kernel\AdminController;
|
use kernel\AdminController;
|
||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
use kernel\models\Option;
|
use kernel\models\Option;
|
||||||
|
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
||||||
use kernel\modules\user\service\UserService;
|
use kernel\modules\user\service\UserService;
|
||||||
use kernel\Request;
|
use kernel\Request;
|
||||||
use kernel\services\ModuleService;
|
use kernel\services\ModuleService;
|
||||||
@ -52,6 +53,11 @@ class ModuleController extends AdminController
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// foreach (ModuleShopClientService::getModuleShopClientInfo() as $module) {
|
||||||
|
// $module->id = $i++;
|
||||||
|
// $modules_info[] = $module;
|
||||||
|
// }
|
||||||
|
|
||||||
$module_count = count($modules_info);
|
$module_count = count($modules_info);
|
||||||
$modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page);
|
$modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page);
|
||||||
$this->cgView->render("index.php", [
|
$this->cgView->render("index.php", [
|
||||||
@ -61,13 +67,14 @@ class ModuleController extends AdminController
|
|||||||
'module_count' => $module_count,
|
'module_count' => $module_count,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionActivate(): void
|
public function actionActivate(): void
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$active_res = $this->moduleService->setActiveModule($request->get("slug"));
|
$active_res = $this->moduleService->setActiveModule($request->get("slug"));
|
||||||
if (!$active_res){
|
if (!$active_res) {
|
||||||
Session::start();
|
Session::start();
|
||||||
Session::set("error", implode(";", $this->moduleService->getErrors()));
|
Session::set("error", implode(";", $this->moduleService->getErrors()));
|
||||||
$this->redirect("/admin", 302);
|
$this->redirect("/admin", 302);
|
||||||
@ -102,13 +109,20 @@ class ModuleController extends AdminController
|
|||||||
public function actionUpdate(): void
|
public function actionUpdate(): void
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$active_res = $this->moduleService->updateModule($request->get("slug"));
|
$slug = $request->get('slug');
|
||||||
if (!$active_res){
|
if ($this->moduleService->isKernelModule($slug)) {
|
||||||
Session::start();
|
$active_res = $this->moduleService->updateModule($request->get("slug"));
|
||||||
Session::set("error", implode(";", $this->moduleService->getErrors()));
|
if (!$active_res){
|
||||||
$this->redirect("/admin", 302);
|
Session::start();
|
||||||
|
Session::set("error", implode(";", $this->moduleService->getErrors()));
|
||||||
|
$this->redirect("/admin", 302);
|
||||||
|
}
|
||||||
|
$mod_info = $this->moduleService->getModuleInfoBySlug($request->get('slug'));
|
||||||
|
} else {
|
||||||
|
$this->redirect("/admin/module_shop_client/update/?slug=" . $slug, 302);
|
||||||
}
|
}
|
||||||
$mod_info = $this->moduleService->getModuleInfoBySlug($request->get('slug'));
|
|
||||||
|
|
||||||
|
|
||||||
$this->cgView->render("view.php", ['data' => $mod_info]);
|
$this->cgView->render("view.php", ['data' => $mod_info]);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class Files
|
|||||||
{
|
{
|
||||||
if (is_dir($d1)) {
|
if (is_dir($d1)) {
|
||||||
if (!file_exists($d2)){
|
if (!file_exists($d2)){
|
||||||
$_d2 = mkdir($d2, permissions: 0755, recursive: true);
|
$_d2 = mkdir($d2, permissions: 0774, recursive: true);
|
||||||
if (!$_d2) {
|
if (!$_d2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -74,6 +74,12 @@ class Files
|
|||||||
$zip->close();
|
$zip->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function uploadByUrl(string $url, string $uploadDir = RESOURCES_DIR . "/upload"): void
|
||||||
|
{
|
||||||
|
$file_name = basename($url);
|
||||||
|
file_put_contents($uploadDir . '/' . $file_name, file_get_contents($url));
|
||||||
|
}
|
||||||
|
|
||||||
private function recursiveAddFile(ZipArchive $zip, string $dir, string $folder = ''): void
|
private function recursiveAddFile(ZipArchive $zip, string $dir, string $folder = ''): void
|
||||||
{
|
{
|
||||||
$includes = new FilesystemIterator($dir);
|
$includes = new FilesystemIterator($dir);
|
||||||
|
21
kernel/helpers/RESTClient.php
Normal file
21
kernel/helpers/RESTClient.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace kernel\helpers;
|
||||||
|
|
||||||
|
use http\Client;
|
||||||
|
|
||||||
|
class RESTClient
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public static function request(string $url, string $method = 'GET')
|
||||||
|
{
|
||||||
|
$client = new \GuzzleHttp\Client();
|
||||||
|
return $client->request($method, $url, [
|
||||||
|
'headers' => [
|
||||||
|
'Authorization' => 'Bearer ' . $_ENV['MODULE_SHOP_TOKEN']
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -43,7 +43,7 @@ class MenuController extends AdminController
|
|||||||
if ($menuForm->validate()){
|
if ($menuForm->validate()){
|
||||||
$menuItem = $this->menuService->create($menuForm);
|
$menuItem = $this->menuService->create($menuForm);
|
||||||
if ($menuItem){
|
if ($menuItem){
|
||||||
$this->redirect("/admin/settings/menu/" . $menuItem->id, code: 302);
|
$this->redirect("/admin/settings/menu/view/" . $menuItem->id, code: 302);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->redirect("/admin/settings/menu/create", code: 302);
|
$this->redirect("/admin/settings/menu/create", code: 302);
|
||||||
@ -107,7 +107,7 @@ class MenuController extends AdminController
|
|||||||
if ($menuForm->validate()){
|
if ($menuForm->validate()){
|
||||||
$menuItem = $this->menuService->update($menuForm, $menuItem);
|
$menuItem = $this->menuService->update($menuForm, $menuItem);
|
||||||
if ($menuItem){
|
if ($menuItem){
|
||||||
$this->redirect("/admin/settings/menu/" . $menuItem->id, code: 302);
|
$this->redirect("/admin/settings/menu/view/" . $menuItem->id, code: 302);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->redirect("/admin/settings/menu/update/" . $id, code: 302);
|
$this->redirect("/admin/settings/menu/update/" . $id, code: 302);
|
||||||
|
@ -14,7 +14,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router)
|
|||||||
App::$collector->get('/page/{page_number}', [\kernel\modules\menu\controllers\MenuController::class, 'actionIndex']);
|
App::$collector->get('/page/{page_number}', [\kernel\modules\menu\controllers\MenuController::class, 'actionIndex']);
|
||||||
App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']);
|
App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']);
|
||||||
App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']);
|
App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']);
|
||||||
App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']);
|
App::$collector->get('/view/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']);
|
||||||
App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']);
|
App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']);
|
||||||
App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']);
|
App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']);
|
||||||
App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']);
|
App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']);
|
||||||
|
@ -105,9 +105,6 @@ class MenuService
|
|||||||
$child = self::getChild($id);
|
$child = self::getChild($id);
|
||||||
if (!$child->isEmpty()){
|
if (!$child->isEmpty()){
|
||||||
foreach ($child as $item){
|
foreach ($child as $item){
|
||||||
// if ($item->url === \kernel\Request::getUrlPath()){
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
if (strripos(Request::getUrlPath(), $item->url) !== false) {
|
if (strripos(Request::getUrlPath(), $item->url) !== false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace kernel\modules\module_shop_client\controllers;
|
||||||
|
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
|
use kernel\AdminController;
|
||||||
|
use kernel\Flash;
|
||||||
|
use kernel\helpers\Debug;
|
||||||
|
use kernel\helpers\Files;
|
||||||
|
use kernel\helpers\RESTClient;
|
||||||
|
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
||||||
|
use kernel\Request;
|
||||||
|
use kernel\services\ModuleService;
|
||||||
|
|
||||||
|
class ModuleShopClientController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected Client $client;
|
||||||
|
protected ModuleService $moduleService;
|
||||||
|
|
||||||
|
protected function init(): void
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
$this->cgView->viewPath = KERNEL_MODULES_DIR . "/module_shop_client/views/";
|
||||||
|
|
||||||
|
$this->client = new Client();
|
||||||
|
$this->moduleService = new ModuleService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function actionIndex(int $page_number = 1): void
|
||||||
|
{
|
||||||
|
$per_page = 8;
|
||||||
|
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||||
|
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||||
|
$module_count = count($modules_info);
|
||||||
|
$modules_info = array_slice($modules_info, $per_page*($page_number-1), $per_page);
|
||||||
|
$this->cgView->render("index.php", [
|
||||||
|
'modules_info' => $modules_info,
|
||||||
|
'moduleService' => $this->moduleService,
|
||||||
|
'page_number' => $page_number,
|
||||||
|
'module_count' => $module_count,
|
||||||
|
'per_page' => $per_page,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actionView(int $id): void
|
||||||
|
{
|
||||||
|
$module_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/' . $id);
|
||||||
|
$module_info = json_decode($module_info->getBody()->getContents(), true);
|
||||||
|
$this->cgView->render("view.php", ['data' => $module_info]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
#[NoReturn] public function actionInstall(): void
|
||||||
|
{
|
||||||
|
$request = new Request();
|
||||||
|
$id = $request->get("id");
|
||||||
|
$module_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/install/' . $id);
|
||||||
|
|
||||||
|
$module_info = json_decode($module_info->getBody()->getContents(), true);
|
||||||
|
Files::uploadByUrl($_ENV['MODULE_SHOP_URL'] . $module_info['path_to_archive'], RESOURCES_DIR . "/tmp/modules");
|
||||||
|
$this->moduleService->installModule('/resources/tmp/modules/' . basename($module_info['path_to_archive']));
|
||||||
|
|
||||||
|
Flash::setMessage("success", "Модуль успешно установлен.");
|
||||||
|
$this->redirect('/admin/module_shop_client', 302);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[NoReturn] public function actionUpdate(): void
|
||||||
|
{
|
||||||
|
$request = new Request();
|
||||||
|
$slug = $request->get("slug");
|
||||||
|
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||||
|
|
||||||
|
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||||
|
foreach ($modules_info as $module) {
|
||||||
|
if ($module['slug'] === $slug) {
|
||||||
|
$path = $module['path_to_archive'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($path)) {
|
||||||
|
Files::uploadByUrl($_ENV['MODULE_SHOP_URL'] . $path, RESOURCES_DIR . "/tmp/modules");
|
||||||
|
$this->moduleService->updateModule('/resources/tmp/modules/' . basename($path));
|
||||||
|
Flash::setMessage("success", "Модуль успешно обновлен.");
|
||||||
|
} else {
|
||||||
|
Flash::setMessage("error", "Ошибка обновления модуля.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->redirect('/admin/module_shop_client', 302);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[NoReturn] public function actionDelete(): void
|
||||||
|
{
|
||||||
|
$request = new Request();
|
||||||
|
$slug = $request->get("slug");
|
||||||
|
$module_info = $this->moduleService->getModuleInfoBySlug($slug);
|
||||||
|
$this->moduleService->uninstallModule($module_info['app_module_path']);
|
||||||
|
|
||||||
|
Flash::setMessage("success", "Модуль успешно удален.");
|
||||||
|
$this->redirect('/admin/module_shop_client', 302);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
kernel/modules/module_shop_client/manifest.json
Normal file
10
kernel/modules/module_shop_client/manifest.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "Module shop client",
|
||||||
|
"version": "0.1",
|
||||||
|
"author": "ITGuild",
|
||||||
|
"slug": "module_shop_client",
|
||||||
|
"description": "Module shop client module",
|
||||||
|
"routs": "routs/module_shop_client.php",
|
||||||
|
"migration_path": "migrations",
|
||||||
|
"dependence": "menu"
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use kernel\App;
|
||||||
|
use kernel\CgRouteCollector;
|
||||||
|
use Phroute\Phroute\RouteCollector;
|
||||||
|
|
||||||
|
App::$collector->filter('bearer', [\kernel\modules\secure\middlewares\BearerAuthMiddleware::class, "handler"]);
|
||||||
|
|
||||||
|
App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
||||||
|
App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
|
||||||
|
App::$collector->group(["prefix" => "module_shop_client"], function (RouteCollector $router) {
|
||||||
|
App::$collector->get('/', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionIndex']);
|
||||||
|
App::$collector->get('/page/{page_number}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionIndex']);
|
||||||
|
App::$collector->get('/install', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionInstall']);
|
||||||
|
App::$collector->get('/view/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionView']);
|
||||||
|
App::$collector->get('/delete', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionDelete']);
|
||||||
|
App::$collector->get('/update', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionUpdate']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
68
kernel/modules/module_shop_client/views/index.php
Normal file
68
kernel/modules/module_shop_client/views/index.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var array $modules_info
|
||||||
|
* @var int $module_count
|
||||||
|
* @var int $page_number
|
||||||
|
* @var int $per_page
|
||||||
|
* @var \kernel\services\ModuleService $moduleService
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Itguild\Tables\ListJsonTable;
|
||||||
|
|
||||||
|
$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));
|
||||||
|
|
||||||
|
$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
|
||||||
|
|
||||||
|
$table->addAction(function ($row, $url) use ($moduleService){
|
||||||
|
$slug = $row['slug'];
|
||||||
|
$id = $row['id'];
|
||||||
|
if ($moduleService->isInstall($slug)){
|
||||||
|
$label = "Удалить";
|
||||||
|
$btn_type = "danger";
|
||||||
|
$btn = "<a class='btn btn-$btn_type' href='$url/delete/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$label = "Установить";
|
||||||
|
$btn_type = "success";
|
||||||
|
$btn = "<a class='btn btn-$btn_type' href='$url/install/?id=$id' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
});
|
||||||
|
|
||||||
|
$table->addAction(function ($row, $url) use ($moduleService){
|
||||||
|
$slug = $row['slug'];
|
||||||
|
if ($moduleService->isInstall($slug)){
|
||||||
|
if (!$moduleService->isLastVersion($slug)) {
|
||||||
|
$label = "Обновить";
|
||||||
|
$btn_type = "info";
|
||||||
|
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$table->create();
|
||||||
|
|
||||||
|
\kernel\widgets\ModuleTabsWidget::create()->run();
|
||||||
|
$table->render();
|
32
kernel/modules/module_shop_client/views/view.php
Normal file
32
kernel/modules/module_shop_client/views/view.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var array $data
|
||||||
|
*/
|
||||||
|
|
||||||
|
use kernel\IGTabel\btn\DangerBtn;
|
||||||
|
use kernel\IGTabel\btn\PrimaryBtn;
|
||||||
|
use kernel\IGTabel\btn\SuccessBtn;
|
||||||
|
|
||||||
|
$table_info = [
|
||||||
|
"meta" => [
|
||||||
|
"rows" => [
|
||||||
|
"name" => "Название",
|
||||||
|
"author" => "Автор",
|
||||||
|
"version" => "Версия",
|
||||||
|
"description" => "Описание",
|
||||||
|
"installations" => "Установки",
|
||||||
|
"views" => "Просмотры"
|
||||||
|
],
|
||||||
|
"params" => ["class" => "table table-bordered"],
|
||||||
|
"baseUrl" => "/admin/module_shop_client",
|
||||||
|
],
|
||||||
|
"data" => $data
|
||||||
|
];
|
||||||
|
$table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
$table->beforePrint(function () {
|
||||||
|
$btn = PrimaryBtn::create("Список", "/admin/module_shop_client")->fetch();
|
||||||
|
return $btn;
|
||||||
|
});
|
||||||
|
$table->create();
|
||||||
|
$table->render();
|
@ -88,7 +88,7 @@ class OptionController extends AdminController
|
|||||||
if ($optionForm->validate()) {
|
if ($optionForm->validate()) {
|
||||||
$option = $this->optionService->update($optionForm, $option);
|
$option = $this->optionService->update($optionForm, $option);
|
||||||
if ($option) {
|
if ($option) {
|
||||||
$this->redirect('/admin/option/' . $option->id);
|
$this->redirect('/admin/option/view/' . $option->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router)
|
|||||||
App::$collector->get('/page/{page_number}', [\kernel\modules\option\controllers\OptionController::class, 'actionIndex']);
|
App::$collector->get('/page/{page_number}', [\kernel\modules\option\controllers\OptionController::class, 'actionIndex']);
|
||||||
App::$collector->get('/create', [\kernel\modules\option\controllers\OptionController::class, 'actionCreate']);
|
App::$collector->get('/create', [\kernel\modules\option\controllers\OptionController::class, 'actionCreate']);
|
||||||
App::$collector->post("/", [\kernel\modules\option\controllers\OptionController::class, 'actionAdd']);
|
App::$collector->post("/", [\kernel\modules\option\controllers\OptionController::class, 'actionAdd']);
|
||||||
App::$collector->get('/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionView']);
|
App::$collector->get('/view/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionView']);
|
||||||
App::$collector->any('/update/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionUpdate']);
|
App::$collector->any('/update/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionUpdate']);
|
||||||
App::$collector->any("/edit/{id}", [\kernel\modules\option\controllers\OptionController::class, 'actionEdit']);
|
App::$collector->any("/edit/{id}", [\kernel\modules\option\controllers\OptionController::class, 'actionEdit']);
|
||||||
App::$collector->get('/delete/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionDelete']);
|
App::$collector->get('/delete/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionDelete']);
|
||||||
|
@ -32,7 +32,7 @@ class PostController extends AdminController
|
|||||||
if ($postForm->validate()) {
|
if ($postForm->validate()) {
|
||||||
$post = $this->postService->create($postForm);
|
$post = $this->postService->create($postForm);
|
||||||
if ($post) {
|
if ($post) {
|
||||||
$this->redirect("/admin/post/" . $post->id);
|
$this->redirect("/admin/post/view/" . $post->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->redirect("/admin/post/create");
|
$this->redirect("/admin/post/create");
|
||||||
@ -87,7 +87,7 @@ class PostController extends AdminController
|
|||||||
if ($postForm->validate()) {
|
if ($postForm->validate()) {
|
||||||
$post = $this->postService->update($postForm, $post);
|
$post = $this->postService->update($postForm, $post);
|
||||||
if ($post) {
|
if ($post) {
|
||||||
$this->redirect("/admin/post/" . $post->id);
|
$this->redirect("/admin/post/view/" . $post->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->redirect("/admin/post/update/" . $id);
|
$this->redirect("/admin/post/update/" . $id);
|
||||||
|
@ -13,7 +13,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
|||||||
App::$collector->get('/page/{page_number}', [\kernel\modules\post\controllers\PostController::class, 'actionIndex']);
|
App::$collector->get('/page/{page_number}', [\kernel\modules\post\controllers\PostController::class, 'actionIndex']);
|
||||||
App::$collector->get('/create', [\kernel\modules\post\controllers\PostController::class, 'actionCreate']);
|
App::$collector->get('/create', [\kernel\modules\post\controllers\PostController::class, 'actionCreate']);
|
||||||
App::$collector->post("/", [\kernel\modules\post\controllers\PostController::class, 'actionAdd']);
|
App::$collector->post("/", [\kernel\modules\post\controllers\PostController::class, 'actionAdd']);
|
||||||
App::$collector->get('/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionView']);
|
App::$collector->get('/view/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionView']);
|
||||||
App::$collector->any('/update/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionUpdate']);
|
App::$collector->any('/update/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionUpdate']);
|
||||||
App::$collector->any("/edit/{id}", [\kernel\modules\post\controllers\PostController::class, 'actionEdit']);
|
App::$collector->any("/edit/{id}", [\kernel\modules\post\controllers\PostController::class, 'actionEdit']);
|
||||||
App::$collector->get('/delete/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionDelete']);
|
App::$collector->get('/delete/{id}', [\kernel\modules\post\controllers\PostController::class, 'actionDelete']);
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace kernel\modules\post\table\columns;
|
|
||||||
|
|
||||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
|
||||||
|
|
||||||
class PostDeleteActionColumn extends ActionColumn
|
|
||||||
{
|
|
||||||
protected string $prefix = "/delete/";
|
|
||||||
|
|
||||||
public function fetch(): string
|
|
||||||
{
|
|
||||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
|
||||||
return " <a href='$link' class='btn btn-danger'>Удалить</a> ";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace kernel\modules\post\table\columns;
|
|
||||||
|
|
||||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
|
||||||
|
|
||||||
class PostEditActionColumn extends ActionColumn
|
|
||||||
{
|
|
||||||
protected string $prefix = "/update/";
|
|
||||||
|
|
||||||
public function fetch(): string
|
|
||||||
{
|
|
||||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
|
||||||
return " <a href='$link' class='btn btn-success'>Редактировать</a> ";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace kernel\modules\post\table\columns;
|
|
||||||
|
|
||||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
|
||||||
|
|
||||||
class PostViewActionColumn extends actionColumn
|
|
||||||
{
|
|
||||||
protected string $prefix = "/";
|
|
||||||
|
|
||||||
public function fetch(): string
|
|
||||||
{
|
|
||||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
|
||||||
return " <a href='$link' class='btn btn-primary'>Просмотр</a> ";
|
|
||||||
}
|
|
||||||
}
|
|
@ -36,7 +36,7 @@ class UserController extends AdminController
|
|||||||
if ($userForm->validate()){
|
if ($userForm->validate()){
|
||||||
$user = $this->userService->create($userForm);
|
$user = $this->userService->create($userForm);
|
||||||
if ($user){
|
if ($user){
|
||||||
$this->redirect("/admin/user/" . $user->id);
|
$this->redirect("/admin/user/view/" . $user->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->redirect("/admin/user/create");
|
$this->redirect("/admin/user/create");
|
||||||
@ -94,7 +94,7 @@ class UserController extends AdminController
|
|||||||
if ($userForm->validate()){
|
if ($userForm->validate()){
|
||||||
$user = $userService->update($userForm, $user);
|
$user = $userService->update($userForm, $user);
|
||||||
if ($user){
|
if ($user){
|
||||||
$this->redirect("/admin/user/" . $user->id);
|
$this->redirect("/admin/user/view/" . $user->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->redirect("/admin/user/update/" . $id);
|
$this->redirect("/admin/user/update/" . $id);
|
||||||
|
@ -13,7 +13,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
|||||||
App::$collector->get('/page/{page_number}', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
App::$collector->get('/page/{page_number}', [\kernel\modules\user\controllers\UserController::class, 'actionIndex']);
|
||||||
App::$collector->get('/create', [\kernel\modules\user\controllers\UserController::class, 'actionCreate']);
|
App::$collector->get('/create', [\kernel\modules\user\controllers\UserController::class, 'actionCreate']);
|
||||||
App::$collector->post("/", [\kernel\modules\user\controllers\UserController::class, 'actionAdd']);
|
App::$collector->post("/", [\kernel\modules\user\controllers\UserController::class, 'actionAdd']);
|
||||||
App::$collector->get('/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionView']);
|
App::$collector->get('/view/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionView']);
|
||||||
App::$collector->any('/update/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionUpdate']);
|
App::$collector->any('/update/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionUpdate']);
|
||||||
App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
|
App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
|
||||||
App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']);
|
App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']);
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
namespace kernel\services;
|
namespace kernel\services;
|
||||||
|
|
||||||
use DirectoryIterator;
|
use DirectoryIterator;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
use kernel\helpers\Files;
|
use kernel\helpers\Files;
|
||||||
use kernel\helpers\Manifest;
|
use kernel\helpers\Manifest;
|
||||||
|
use kernel\helpers\RESTClient;
|
||||||
use kernel\models\Option;
|
use kernel\models\Option;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
||||||
@ -281,7 +283,7 @@ class ModuleService
|
|||||||
$tmpModuleDir = md5(time());
|
$tmpModuleDir = md5(time());
|
||||||
$res = $zip->open(ROOT_DIR . $path);
|
$res = $zip->open(ROOT_DIR . $path);
|
||||||
if ($res === TRUE) {
|
if ($res === TRUE) {
|
||||||
$tmpModuleDirFull = RESOURCES_DIR . '/tmp/ad/' . $tmpModuleDir . "/";
|
$tmpModuleDirFull = RESOURCES_DIR . '/tmp/modules/' . $tmpModuleDir . "/";
|
||||||
$zip->extractTo($tmpModuleDirFull);
|
$zip->extractTo($tmpModuleDirFull);
|
||||||
$zip->close();
|
$zip->close();
|
||||||
} else {
|
} else {
|
||||||
@ -289,20 +291,20 @@ class ModuleService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($tmpModuleDirFull . "/app/manifest.json")) {
|
if (!file_exists($tmpModuleDirFull . "app/manifest.json")) {
|
||||||
$this->addError('manifest.json not found');
|
$this->addError('manifest.json not found');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "/app/manifest.json"));
|
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "app/manifest.json"));
|
||||||
$manifest = Manifest::getWithVars($manifestJson);
|
$manifest = Manifest::getWithVars($manifestJson);
|
||||||
|
|
||||||
$fileHelper = new Files();
|
$fileHelper = new Files();
|
||||||
$fileHelper->copy_folder($tmpModuleDirFull . '/app', $manifest['app_module_path']);
|
$fileHelper->copy_folder($tmpModuleDirFull . 'app', $manifest['app_module_path']);
|
||||||
if (isset($manifest['kernel_module_path'])) {
|
if (isset($manifest['kernel_module_path'])) {
|
||||||
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', $manifest['kernel_module_path']);
|
$fileHelper->copy_folder($tmpModuleDirFull . 'kernel', $manifest['kernel_module_path']);
|
||||||
} else {
|
} else {
|
||||||
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', KERNEL_APP_MODULES_DIR . '/' . $manifest['slug']);
|
$fileHelper->copy_folder($tmpModuleDirFull . 'kernel', KERNEL_APP_MODULES_DIR . '/' . $manifest['slug']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
||||||
@ -368,7 +370,7 @@ class ModuleService
|
|||||||
$tmpModuleDir = md5(time());
|
$tmpModuleDir = md5(time());
|
||||||
$res = $zip->open(ROOT_DIR . $path);
|
$res = $zip->open(ROOT_DIR . $path);
|
||||||
if ($res === TRUE) {
|
if ($res === TRUE) {
|
||||||
$tmpModuleDirFull = RESOURCES_DIR . '/tmp/ad/' . $tmpModuleDir . "/";
|
$tmpModuleDirFull = RESOURCES_DIR . '/tmp/modules/' . $tmpModuleDir . "/";
|
||||||
$zip->extractTo($tmpModuleDirFull);
|
$zip->extractTo($tmpModuleDirFull);
|
||||||
$zip->close();
|
$zip->close();
|
||||||
} else {
|
} else {
|
||||||
@ -376,19 +378,21 @@ class ModuleService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($tmpModuleDirFull . "/app/manifest.json")) {
|
if (!file_exists($tmpModuleDirFull . "app/manifest.json")) {
|
||||||
$this->addError('manifest.json not found');
|
$this->addError('manifest.json not found');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "/app/manifest.json"));
|
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "app/manifest.json"));
|
||||||
$manifest = Manifest::getWithVars($manifestJson);
|
$manifest = Manifest::getWithVars($manifestJson);
|
||||||
|
|
||||||
$fileHelper = new Files();
|
$fileHelper = new Files();
|
||||||
|
|
||||||
|
$fileHelper->copy_folder($tmpModuleDirFull . 'app/manifest.json', $manifest['app_module_path'] . '/manifest.json');
|
||||||
if (isset($manifest['kernel_module_path'])) {
|
if (isset($manifest['kernel_module_path'])) {
|
||||||
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', $manifest['kernel_module_path']);
|
$fileHelper->copy_folder($tmpModuleDirFull . 'kernel', $manifest['kernel_module_path']);
|
||||||
} else {
|
} else {
|
||||||
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', KERNEL_APP_MODULES_DIR . '/' . $manifest['slug']);
|
$fileHelper->copy_folder($tmpModuleDirFull . 'kernel', KERNEL_APP_MODULES_DIR . '/' . $manifest['slug']);
|
||||||
}
|
}
|
||||||
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
||||||
|
|
||||||
@ -411,4 +415,56 @@ class ModuleService
|
|||||||
return $dependence_array;
|
return $dependence_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isInstall(string $slug): bool
|
||||||
|
{
|
||||||
|
$module_paths = Option::where("key", "module_paths")->first();
|
||||||
|
$dirs = [];
|
||||||
|
if ($module_paths){
|
||||||
|
$path = json_decode($module_paths->value);
|
||||||
|
foreach ($path->paths as $p){
|
||||||
|
$dirs[] = getConst($p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($dirs as $dir){
|
||||||
|
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
||||||
|
if($fileInfo->isDot()) continue;
|
||||||
|
if ($this->getModuleInfo($fileInfo->getPathname())['slug'] === $slug) {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isLastVersion(string $slug): bool
|
||||||
|
{
|
||||||
|
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||||
|
|
||||||
|
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||||
|
$mod_info = $this->getModuleInfoBySlug($slug);
|
||||||
|
foreach ($modules_info as $mod) {
|
||||||
|
if ($mod['slug'] === $mod_info['slug'] && $mod['version'] === $mod_info['version']) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isKernelModule(string $slug): bool
|
||||||
|
{
|
||||||
|
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||||
|
|
||||||
|
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||||
|
$mod_info = $this->getModuleInfoBySlug($slug);
|
||||||
|
foreach ($modules_info as $mod) {
|
||||||
|
if ($mod['slug'] === $mod_info['slug']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -26,32 +26,53 @@ $info_to_table['data'] = $modules_info;
|
|||||||
$table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
$table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
|
||||||
$table->addAction(function ($row, $url) use ($moduleService){
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||||
$slug = $row['slug'];
|
$slug = $row['slug'];
|
||||||
if ($moduleService->isActive($slug)){
|
if ($moduleService->isActive($slug)) {
|
||||||
$label = "Деактивировать";
|
$label = "Деактивировать";
|
||||||
$btn_type = "warning";
|
$btn_type = "warning";
|
||||||
$btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
$btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$label = "Активировать";
|
$label = "Активировать";
|
||||||
$btn_type = "primary";
|
$btn_type = "success";
|
||||||
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $btn;
|
return $btn;
|
||||||
});
|
});
|
||||||
|
|
||||||
$table->addAction(function ($row, $url) use ($moduleService){
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||||
$slug = $row['slug'];
|
$slug = $row['slug'];
|
||||||
return "<a class='btn btn-primary' href='$url/view/?slug=$slug' style='margin: 3px; width: 150px;' >Просмотр</a>";
|
return "<a class='btn btn-primary' href='$url/view/?slug=$slug' style='margin: 3px; width: 150px;' >Просмотр</a>";
|
||||||
});
|
});
|
||||||
|
|
||||||
$table->addAction(function ($row, $url) use ($moduleService){
|
$table->addAction(function ($row, $url) use ($moduleService){
|
||||||
$slug = $row['slug'];
|
$slug = $row['slug'];
|
||||||
return "<a class='btn btn-primary' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >Обновить</a>";
|
if (!$moduleService->isKernelModule($slug)){
|
||||||
|
if (!$moduleService->isLastVersion($slug)) {
|
||||||
|
$label = "Обновить";
|
||||||
|
$btn_type = "info";
|
||||||
|
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$table->addAction(function ($row, $url) use ($moduleService){
|
||||||
|
$slug = $row['slug'];
|
||||||
|
if (!$moduleService->isKernelModule($slug)){
|
||||||
|
$label = "Удалить";
|
||||||
|
$btn_type = "danger";
|
||||||
|
return "<a class='btn btn-$btn_type' href='admin/module_shop_client/delete/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$table->create();
|
$table->create();
|
||||||
|
|
||||||
|
if ($moduleService->isActive('module_shop_client')) {
|
||||||
|
\kernel\widgets\ModuleTabsWidget::create()->run();
|
||||||
|
}
|
||||||
$table->render();
|
$table->render();
|
||||||
|
@ -23,7 +23,7 @@ $table_info = [
|
|||||||
$table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
$table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
$table->beforePrint(function () {
|
$table->beforePrint(function () {
|
||||||
$btn = PrimaryBtn::create("Список", "/admin/module")->fetch();
|
$btn = PrimaryBtn::create("Список", "/admin")->fetch();
|
||||||
return $btn;
|
return $btn;
|
||||||
});
|
});
|
||||||
$table->create();
|
$table->create();
|
||||||
|
18
kernel/widgets/ModuleTabsWidget.php
Normal file
18
kernel/widgets/ModuleTabsWidget.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace kernel\widgets;
|
||||||
|
|
||||||
|
use kernel\helpers\Debug;
|
||||||
|
use kernel\Widget;
|
||||||
|
|
||||||
|
class ModuleTabsWidget extends Widget
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$tabs = [
|
||||||
|
'/admin' => 'Локальные',
|
||||||
|
'/admin/module_shop_client' => 'Каталог'
|
||||||
|
];
|
||||||
|
$this->cgView->render('/admin/module_tabs.php', ['tabs' => $tabs]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user