ms client update
This commit is contained in:
parent
9d243b5b35
commit
a02c55e16e
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Tags",
|
"name": "Tags",
|
||||||
"version": "0.2",
|
"version": "0.1",
|
||||||
"author": "ITGuild",
|
"author": "ITGuild",
|
||||||
"slug": "tag",
|
"slug": "tag",
|
||||||
"description": "Tags module",
|
"description": "Tags module",
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ class ModuleController extends AdminController
|
|||||||
{
|
{
|
||||||
$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);
|
||||||
|
@ -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']);
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
namespace kernel\modules\module_shop_client\controllers;
|
namespace kernel\modules\module_shop_client\controllers;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
use kernel\AdminController;
|
use kernel\AdminController;
|
||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
||||||
|
use kernel\Request;
|
||||||
use kernel\services\ModuleService;
|
use kernel\services\ModuleService;
|
||||||
|
|
||||||
class ModuleShopClientController extends AdminController
|
class ModuleShopClientController extends AdminController
|
||||||
@ -37,6 +39,7 @@ class ModuleShopClientController extends AdminController
|
|||||||
$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", [
|
||||||
'modules_info' => $modules_info,
|
'modules_info' => $modules_info,
|
||||||
|
'moduleService' => $this->moduleService,
|
||||||
'page_number' => $page_number,
|
'page_number' => $page_number,
|
||||||
'module_count' => $module_count,
|
'module_count' => $module_count,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
@ -55,8 +58,10 @@ class ModuleShopClientController extends AdminController
|
|||||||
$this->cgView->render("view.php", ['data' => $module_info]);
|
$this->cgView->render("view.php", ['data' => $module_info]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionInstall(int $id): void
|
public function actionInstall(): void
|
||||||
{
|
{
|
||||||
|
$request = new Request();
|
||||||
|
$id = $request->get("id");
|
||||||
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU';
|
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU';
|
||||||
$module_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/' . $id, [
|
$module_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/' . $id, [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
@ -69,4 +74,13 @@ class ModuleShopClientController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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']);
|
||||||
|
$this->redirect('/admin/module_shop_client', 302);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -11,13 +11,13 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
|||||||
App::$collector->group(["prefix" => "module_shop_client"], 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('/', [\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('/page/{page_number}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionIndex']);
|
||||||
App::$collector->get('/install/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionInstall']);
|
App::$collector->get('/install', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionInstall']);
|
||||||
// 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\module_shop_client\controllers\ModuleShopClientController::class, 'actionView']);
|
App::$collector->get('/view/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::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', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionDelete']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace kernel\modules\module_shop_client\services;
|
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use Itguild\Tables\ListJsonTable;
|
|
||||||
use kernel\services\ModuleService;
|
|
||||||
|
|
||||||
class ModuleShopClientService extends ModuleService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static function getModuleShopClientInfo()
|
|
||||||
{
|
|
||||||
$client = new Client();
|
|
||||||
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU';
|
|
||||||
$res = $client->request('GET', 'http://igfs.loc/api/module_shop/gb_slug', [
|
|
||||||
'headers' => [
|
|
||||||
'Authorization' => 'Bearer ' . $token,
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
return json_decode($res->getBody()->getContents());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
// public static function getModuleShopClientTable(): ListJsonTable
|
|
||||||
// {
|
|
||||||
// $modules_info = json_decode(ModuleShopClientService::getModuleShopClientInfo());
|
|
||||||
//
|
|
||||||
// $meta = [];
|
|
||||||
// $meta['columns'] = [
|
|
||||||
// "name" => "Название",
|
|
||||||
// "author" => "Автор",
|
|
||||||
// "version" => "Версия",
|
|
||||||
// "description" => "Описание",
|
|
||||||
// "installations" => 'Установки',
|
|
||||||
// "views" => 'Просмотры'
|
|
||||||
// ];
|
|
||||||
// $meta['params'] = ["class" => "table table-bordered"];
|
|
||||||
// $meta['perPage'] = 3;
|
|
||||||
// $meta['baseUrl'] = "/admin/module_shop_client";
|
|
||||||
// $meta['currentPage'] = 1;
|
|
||||||
// $meta['total'] = count($modules_info);
|
|
||||||
//
|
|
||||||
// $info_to_table['meta'] = $meta;
|
|
||||||
// $info_to_table['data'] = $modules_info;
|
|
||||||
//
|
|
||||||
// $table = new ListJsonTable(json_encode($info_to_table, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
|
||||||
//
|
|
||||||
// $table->create();
|
|
||||||
// return $table;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
@ -4,6 +4,7 @@
|
|||||||
* @var int $module_count
|
* @var int $module_count
|
||||||
* @var int $page_number
|
* @var int $page_number
|
||||||
* @var int $per_page
|
* @var int $per_page
|
||||||
|
* @var \kernel\services\ModuleService $moduleService
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Itguild\Tables\ListJsonTable;
|
use Itguild\Tables\ListJsonTable;
|
||||||
@ -28,26 +29,25 @@ $info_to_table['data'] = $modules_info;
|
|||||||
|
|
||||||
$table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
$table = new 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";
|
|
||||||
// $btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// 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->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
|
$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
|
||||||
$table->addAction(\kernel\IGTabel\action_column\InstallActionColumn::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 = "warning";
|
||||||
|
$btn = "<a class='btn btn-$btn_type' href='$url/install/?id=$id' style='margin: 3px; width: 150px;' >$label</a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $btn;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$table->create();
|
$table->create();
|
||||||
$table->render();
|
$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']);
|
||||||
|
@ -411,4 +411,27 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user