some fix
This commit is contained in:
commit
4077405296
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Tags",
|
"name": "Tags",
|
||||||
"version": "0.3",
|
"version": "0.1",
|
||||||
"author": "ITGuild",
|
"author": "ITGuild",
|
||||||
"slug": "tag",
|
"slug": "tag",
|
||||||
"description": "Tags module",
|
"description": "Tags module",
|
||||||
|
2
composer.lock
generated
2
composer.lock
generated
@ -3205,5 +3205,5 @@
|
|||||||
"ext-zip": "*"
|
"ext-zip": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.6.0"
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css">
|
||||||
<link rel="stylesheet" href="<?= $resources ?>/css/bootstrap.min.css">
|
<link rel="stylesheet" href="<?= $resources ?>/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="<?= $resources ?>/css/style.css">
|
<link rel="stylesheet" href="<?= $resources ?>/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace kernel\controllers;
|
namespace kernel\controllers;
|
||||||
|
|
||||||
use DirectoryIterator;
|
use DirectoryIterator;
|
||||||
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
use Josantonius\Session\Facades\Session;
|
use Josantonius\Session\Facades\Session;
|
||||||
use kernel\AdminController;
|
use kernel\AdminController;
|
||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
@ -53,10 +54,6 @@ 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);
|
||||||
@ -106,25 +103,11 @@ class ModuleController extends AdminController
|
|||||||
$this->cgView->render("view.php", ['data' => $mod_info]);
|
$this->cgView->render("view.php", ['data' => $mod_info]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionUpdate(): void
|
#[NoReturn] public function actionUpdate(): void
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$slug = $request->get('slug');
|
$slug = $request->get('slug');
|
||||||
if ($this->moduleService->isKernelModule($slug)) {
|
|
||||||
$active_res = $this->moduleService->updateModule($request->get("slug"));
|
|
||||||
if (!$active_res){
|
|
||||||
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);
|
$this->redirect("/admin/module_shop_client/update/?slug=" . $slug, 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->cgView->render("view.php", ['data' => $mod_info]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -44,9 +44,8 @@ class SecureController extends AdminController
|
|||||||
Flash::setMessage("error", "User not found.");
|
Flash::setMessage("error", "User not found.");
|
||||||
$this->redirect("/admin/login", code: 302);
|
$this->redirect("/admin/login", code: 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password_verify($loginForm->getItem("password"), $user->password_hash)) {
|
if (password_verify($loginForm->getItem("password"), $user->password_hash)) {
|
||||||
setcookie('user_id', $user->id, time()+60*60*24, '/', $_SERVER['SERVER_NAME'], false);
|
setcookie('user_id', $user->id, time()+60*60*24, '/', $_SERVER['HTTP_HOST'], false);
|
||||||
$this->redirect("/admin", code: 302);
|
$this->redirect("/admin", code: 302);
|
||||||
} else {
|
} else {
|
||||||
Flash::setMessage("error", "Username or password incorrect.");
|
Flash::setMessage("error", "Username or password incorrect.");
|
||||||
|
@ -347,8 +347,7 @@ class ModuleService
|
|||||||
$fileHelper->copy_folder(ROOT_DIR . $path, $tmpModuleDirFull . 'app/');
|
$fileHelper->copy_folder(ROOT_DIR . $path, $tmpModuleDirFull . 'app/');
|
||||||
if (file_exists(KERNEL_APP_MODULES_DIR . '/' . $moduleName)) {
|
if (file_exists(KERNEL_APP_MODULES_DIR . '/' . $moduleName)) {
|
||||||
$fileHelper->copy_folder(KERNEL_APP_MODULES_DIR . '/' . $moduleName, $tmpModuleDirFull . 'kernel/');
|
$fileHelper->copy_folder(KERNEL_APP_MODULES_DIR . '/' . $moduleName, $tmpModuleDirFull . 'kernel/');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mkdir($tmpModuleDirFull . 'kernel/');
|
mkdir($tmpModuleDirFull . 'kernel/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,17 +453,25 @@ class ModuleService
|
|||||||
|
|
||||||
public function isKernelModule(string $slug): bool
|
public function isKernelModule(string $slug): bool
|
||||||
{
|
{
|
||||||
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
$modules_info = $this->getKernelModules();
|
||||||
|
|
||||||
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
|
||||||
$mod_info = $this->getModuleInfoBySlug($slug);
|
|
||||||
foreach ($modules_info as $mod) {
|
foreach ($modules_info as $mod) {
|
||||||
if ($mod['slug'] === $mod_info['slug']) {
|
if ($mod['slug'] === $slug) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKernelModules(): array
|
||||||
|
{
|
||||||
|
$modules_info = [];
|
||||||
|
foreach (new DirectoryIterator(KERNEL_MODULES_DIR) as $fileInfo) {
|
||||||
|
if ($fileInfo->isDot()) continue;
|
||||||
|
$modules_info[] = $this->getModuleInfo($fileInfo->getPathname());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $modules_info;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -34,9 +34,9 @@ $table->addAction(function ($row, $url) use ($moduleService) {
|
|||||||
$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 = "<i class='fa-regular fa-circle-check'></i>";
|
||||||
$btn_type = "success";
|
$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;' >$label</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $btn;
|
return $btn;
|
||||||
@ -60,7 +60,7 @@ $table->addAction(function ($row, $url) use ($moduleService){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$table->addAction(function ($row, $url) use ($moduleService){
|
$table->addAction(function ($row) use ($moduleService){
|
||||||
$slug = $row['slug'];
|
$slug = $row['slug'];
|
||||||
if (!$moduleService->isKernelModule($slug)){
|
if (!$moduleService->isKernelModule($slug)){
|
||||||
$label = "Удалить";
|
$label = "Удалить";
|
||||||
@ -69,7 +69,6 @@ $table->addAction(function ($row, $url) use ($moduleService){
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$table->create();
|
$table->create();
|
||||||
|
|
||||||
if ($moduleService->isActive('module_shop_client')) {
|
if ($moduleService->isActive('module_shop_client')) {
|
||||||
|
9
kernel/views/widgets/admin/action_button.php
Normal file
9
kernel/views/widgets/admin/action_button.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var string $icon
|
||||||
|
* @var string $btn
|
||||||
|
* @var string $url
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
|
||||||
|
"<a class='btn btn-$btn' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$icon</a>";
|
28
kernel/views/widgets/admin/menu.php
Normal file
28
kernel/views/widgets/admin/menu.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var array $menu
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<ul class="list-unstyled components mb-5">
|
||||||
|
<?php foreach ($menu as $item):
|
||||||
|
$child = \kernel\modules\menu\service\MenuService::getChild($item->id);
|
||||||
|
if ($child): ?>
|
||||||
|
<li>
|
||||||
|
<a href="#item<?=$item->id?>" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><?= $item->label ?></a>
|
||||||
|
<ul class="collapse list-unstyled <?= \kernel\modules\menu\service\MenuService::hasActiveChild($item->id) ? "show" : "" ?>" id="item<?=$item->id?>">
|
||||||
|
<?php foreach ($child as $subitem): ?>
|
||||||
|
<li class="<?= \kernel\modules\menu\service\MenuService::isActive($subitem->url) ? "active" : "" ?>">
|
||||||
|
<a href="<?= $subitem->url ?>"><?= $subitem->label ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<?php else: ?>
|
||||||
|
<li class="<?= $item->url === \kernel\Request::getUrlPath() || $item->url . "/module_shop_client" === \kernel\Request::getUrlPath() ? "active" : "" ?>">
|
||||||
|
<a href="<?= $item->url ?>"><?= $item->label ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
</ul>
|
14
kernel/views/widgets/admin/module_tabs.php
Normal file
14
kernel/views/widgets/admin/module_tabs.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @var array $tabs
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<?php foreach ($tabs as $link => $label): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?=\kernel\Request::getUrlPath() === $link ? "active" : " "?>" href="<?= $link ?>" > <?= $label ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<br>
|
16
kernel/widgets/ActionButtonWidget.php
Normal file
16
kernel/widgets/ActionButtonWidget.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace kernel\widgets;
|
||||||
|
|
||||||
|
use kernel\Widget;
|
||||||
|
|
||||||
|
class ActionButtonWidget extends Widget
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$icon = $this->data['icon'];
|
||||||
|
$btn = $this->data['btn'];
|
||||||
|
$url = $this->data['url'];
|
||||||
|
$this->cgView->render('/admin/action_button.php', ['icon' => $icon, 'btn' => $btn, 'url' => $url]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user