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)) {
|
$this->redirect("/admin/module_shop_client/update/?slug=" . $slug, 302);
|
||||||
$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->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.");
|
||||||
|
@ -189,8 +189,8 @@ class ModuleService
|
|||||||
*/
|
*/
|
||||||
public function runInitScript($mod_info): void
|
public function runInitScript($mod_info): void
|
||||||
{
|
{
|
||||||
if (isset($mod_info['module_class'])){
|
if (isset($mod_info['module_class'])) {
|
||||||
if (isset($mod_info['module_class_file'])){
|
if (isset($mod_info['module_class_file'])) {
|
||||||
require_once $mod_info['module_class_file'];
|
require_once $mod_info['module_class_file'];
|
||||||
}
|
}
|
||||||
$moduleClass = new $mod_info['module_class']();
|
$moduleClass = new $mod_info['module_class']();
|
||||||
@ -204,8 +204,8 @@ class ModuleService
|
|||||||
*/
|
*/
|
||||||
public function runDeactivateScript($mod_info): void
|
public function runDeactivateScript($mod_info): void
|
||||||
{
|
{
|
||||||
if (isset($mod_info['module_class'])){
|
if (isset($mod_info['module_class'])) {
|
||||||
if (isset($mod_info['module_class_file'])){
|
if (isset($mod_info['module_class_file'])) {
|
||||||
require_once $mod_info['module_class_file'];
|
require_once $mod_info['module_class_file'];
|
||||||
}
|
}
|
||||||
$moduleClass = new $mod_info['module_class']();
|
$moduleClass = new $mod_info['module_class']();
|
||||||
@ -233,7 +233,7 @@ class ModuleService
|
|||||||
|
|
||||||
foreach ($dirs as $dir) {
|
foreach ($dirs as $dir) {
|
||||||
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
||||||
if($fileInfo->isDot() or !in_array($fileInfo->getFilename(), $active_modules['modules'])) continue;
|
if ($fileInfo->isDot() or !in_array($fileInfo->getFilename(), $active_modules['modules'])) continue;
|
||||||
$modules[] = $this->getModuleInfo($fileInfo->getPathname());
|
$modules[] = $this->getModuleInfo($fileInfo->getPathname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,8 +248,8 @@ class ModuleService
|
|||||||
{
|
{
|
||||||
$routs = [];
|
$routs = [];
|
||||||
$modules = $this->getActiveModules();
|
$modules = $this->getActiveModules();
|
||||||
foreach ($modules as $module){
|
foreach ($modules as $module) {
|
||||||
if (isset($module['routs'])){
|
if (isset($module['routs'])) {
|
||||||
$routs[] = $module['path'] . "/" . $module['routs'];
|
$routs[] = $module['path'] . "/" . $module['routs'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,8 +264,8 @@ class ModuleService
|
|||||||
{
|
{
|
||||||
$migrationsPaths = [];
|
$migrationsPaths = [];
|
||||||
$modules = $this->getActiveModules();
|
$modules = $this->getActiveModules();
|
||||||
foreach ($modules as $module){
|
foreach ($modules as $module) {
|
||||||
if (isset($module['migration_path'])){
|
if (isset($module['migration_path'])) {
|
||||||
$migrationsPaths[] = $module['path'] . "/" . $module['migration_path'];
|
$migrationsPaths[] = $module['path'] . "/" . $module['migration_path'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ class ModuleService
|
|||||||
|
|
||||||
$fileHelper = new Files();
|
$fileHelper = new Files();
|
||||||
if (file_exists(APP_DIR . '/modules/' . $moduleInfo['slug'])) {
|
if (file_exists(APP_DIR . '/modules/' . $moduleInfo['slug'])) {
|
||||||
$fileHelper->recursiveRemoveDir(APP_DIR . '/modules/'. $moduleInfo['slug']);
|
$fileHelper->recursiveRemoveDir(APP_DIR . '/modules/' . $moduleInfo['slug']);
|
||||||
}
|
}
|
||||||
if (file_exists(KERNEL_APP_MODULES_DIR . '/' . $moduleInfo['slug'])) {
|
if (file_exists(KERNEL_APP_MODULES_DIR . '/' . $moduleInfo['slug'])) {
|
||||||
$fileHelper->recursiveRemoveDir(KERNEL_APP_MODULES_DIR . '/' . $moduleInfo['slug']);
|
$fileHelper->recursiveRemoveDir(KERNEL_APP_MODULES_DIR . '/' . $moduleInfo['slug']);
|
||||||
@ -345,10 +345,9 @@ class ModuleService
|
|||||||
|
|
||||||
$fileHelper = new Files();
|
$fileHelper = new Files();
|
||||||
$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/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,15 +418,15 @@ class ModuleService
|
|||||||
{
|
{
|
||||||
$module_paths = Option::where("key", "module_paths")->first();
|
$module_paths = Option::where("key", "module_paths")->first();
|
||||||
$dirs = [];
|
$dirs = [];
|
||||||
if ($module_paths){
|
if ($module_paths) {
|
||||||
$path = json_decode($module_paths->value);
|
$path = json_decode($module_paths->value);
|
||||||
foreach ($path->paths as $p){
|
foreach ($path->paths as $p) {
|
||||||
$dirs[] = getConst($p);
|
$dirs[] = getConst($p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($dirs as $dir){
|
foreach ($dirs as $dir) {
|
||||||
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
||||||
if($fileInfo->isDot()) continue;
|
if ($fileInfo->isDot()) continue;
|
||||||
if ($this->getModuleInfo($fileInfo->getPathname())['slug'] === $slug) {
|
if ($this->getModuleInfo($fileInfo->getPathname())['slug'] === $slug) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -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