themes add and some fix
This commit is contained in:
parent
219ca30608
commit
a943b960ad
84
app/modules/module_shop/controllers/ThemeShopController.php
Normal file
84
app/modules/module_shop/controllers/ThemeShopController.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\controllers;
|
||||
|
||||
use app\modules\module_shop\models\forms\CreateAdminThemeShopForm;
|
||||
use app\modules\module_shop\services\ModuleShopService;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use kernel\AdminController;
|
||||
use kernel\FileUpload;
|
||||
use kernel\Flash;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\helpers\Files;
|
||||
use ZipArchive;
|
||||
|
||||
class ThemeShopController extends AdminController
|
||||
{
|
||||
protected ModuleShopService $moduleShopService;
|
||||
protected Files $files;
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = APP_DIR . "/modules/module_shop/views/theme/";
|
||||
$this->moduleShopService = new ModuleShopService();
|
||||
$this->files = new Files();
|
||||
}
|
||||
|
||||
public function actionCreate(): void
|
||||
{
|
||||
$this->cgView->render("form.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
#[NoReturn] public function actionAdd(): void
|
||||
{
|
||||
$themeShopForm = new CreateThemeShopForm();
|
||||
$themeShopForm->load($_REQUEST);
|
||||
|
||||
if (isset($_FILES['path_to_archive']) && $_FILES['path_to_archive']['error'] === UPLOAD_ERR_OK) {
|
||||
$file = new FileUpload($_FILES['path_to_archive'], ['zip', 'rar', 'igt']);
|
||||
$file->upload();
|
||||
$themeShopForm->setItem('path_to_archive', $file->getUploadFile());
|
||||
}
|
||||
|
||||
$tmpThemeDir = md5(time());
|
||||
$zip = new ZipArchive;
|
||||
$res = $zip->open(ROOT_DIR . $themeShopForm->getItem('path_to_archive'));
|
||||
if ($res === TRUE) {
|
||||
if (!is_dir(RESOURCES_DIR . '/tmp/ms/')) {
|
||||
$oldMask = umask(0);
|
||||
mkdir(RESOURCES_DIR . '/tmp/ms/', 0775, true);
|
||||
umask($oldMask);
|
||||
}
|
||||
$tmpModuleShopDirFull = RESOURCES_DIR . '/tmp/ms/' . $tmpThemeDir . "/";
|
||||
$zip->extractTo($tmpModuleShopDirFull);
|
||||
$zip->close();
|
||||
|
||||
if (file_exists($tmpModuleShopDirFull . "meta/manifest.json")){
|
||||
$themeInfo = $this->moduleShopService->getModuleInfo($tmpModuleShopDirFull . "meta");
|
||||
$themeShopForm->load($themeInfo);
|
||||
}
|
||||
else {
|
||||
throw new \Exception("Manifest.json file not found");
|
||||
}
|
||||
$this->files->recursiveRemoveDir($tmpModuleShopDirFull);
|
||||
|
||||
}
|
||||
else {
|
||||
throw new \Exception("zip not found");
|
||||
}
|
||||
|
||||
if ($themeShopForm->validate()) {
|
||||
$theme = $this->moduleShopService->create($themeShopForm);
|
||||
if ($theme) {
|
||||
Flash::setMessage("success", "Тема сайта добавлена.");
|
||||
$this->redirect("/admin/module_shop/view/" . $theme->id);
|
||||
}
|
||||
}
|
||||
Flash::setMessage("error", "Ошибка добавления темы сайта: <br>" . $themeShopForm->getErrorsStr());
|
||||
$this->redirect("/admin/module_shop/theme/create");
|
||||
}
|
||||
}
|
22
app/modules/module_shop/models/forms/CreateThemeShopForm.php
Normal file
22
app/modules/module_shop/models/forms/CreateThemeShopForm.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\models\forms;
|
||||
|
||||
use kernel\FormModel;
|
||||
|
||||
class CreateThemeShopForm extends FormModel
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|min-str-len:3',
|
||||
'version' => 'required',
|
||||
'description' => '',
|
||||
'author' => 'required',
|
||||
'status' => 'required',
|
||||
'slug' => 'required',
|
||||
'type' => 'required',
|
||||
'path_to_archive' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
51
app/modules/module_shop/views/theme/form.php
Normal file
51
app/modules/module_shop/views/theme/form.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @var ModuleShop $model
|
||||
*/
|
||||
|
||||
use app\modules\module_shop\models\ModuleShop;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm("/admin/module_shop/theme", enctype: 'multipart/form-data');
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\File::class, name: "path_to_archive", params: [
|
||||
'class' => "form-control",
|
||||
'placeholder' => 'Путь к файлу темы сайта',
|
||||
'value' => $model->path_to_archive ?? ''
|
||||
])
|
||||
->setLabel("Путь к файлу темы сайта")
|
||||
->render();
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\Select::class, name: "status", params: [
|
||||
'class' => "form-control",
|
||||
'value' => $model->status ?? ''
|
||||
])
|
||||
->setLabel("Статус")
|
||||
->setOptions(ModuleShop::getStatus())
|
||||
->render();
|
||||
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
|
||||
'class' => "btn btn-primary ",
|
||||
'value' => 'Отправить',
|
||||
'typeInput' => 'submit'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<?php
|
||||
$form->field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
|
||||
'class' => "btn btn-warning",
|
||||
'value' => 'Сбросить',
|
||||
'typeInput' => 'reset'
|
||||
])
|
||||
->render();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$form->endForm();
|
0
bootstrap/db.php
Normal file → Executable file
0
bootstrap/db.php
Normal file → Executable file
0
bootstrap/header.php
Normal file → Executable file
0
bootstrap/header.php
Normal file → Executable file
0
bootstrap/secure.php
Normal file → Executable file
0
bootstrap/secure.php
Normal file → Executable file
0
kernel/AdminController.php
Normal file → Executable file
0
kernel/AdminController.php
Normal file → Executable file
0
kernel/App.php
Normal file → Executable file
0
kernel/App.php
Normal file → Executable file
0
kernel/CgRouteCollector.php
Normal file → Executable file
0
kernel/CgRouteCollector.php
Normal file → Executable file
0
kernel/CgView.php
Normal file → Executable file
0
kernel/CgView.php
Normal file → Executable file
0
kernel/Controller.php
Normal file → Executable file
0
kernel/Controller.php
Normal file → Executable file
0
kernel/Database.php
Normal file → Executable file
0
kernel/Database.php
Normal file → Executable file
0
kernel/EntityRelation.php
Normal file → Executable file
0
kernel/EntityRelation.php
Normal file → Executable file
8
kernel/FileUpload.php
Normal file → Executable file
8
kernel/FileUpload.php
Normal file → Executable file
@ -36,7 +36,9 @@ class FileUpload
|
||||
$newFileName = md5(time() . $this->fileName) . '.' . $this->fileExtension;
|
||||
if (in_array($this->fileExtension, $this->allowedFileExtensions)) {
|
||||
$this->uploadDir = $uploadDir . mb_substr($newFileName, 0, 2) . '/' . mb_substr($newFileName, 2, 2) . '/';
|
||||
mkdir(ROOT_DIR . $this->uploadDir, 0777, true);
|
||||
$oldMask = umask(0);
|
||||
mkdir(ROOT_DIR . $this->uploadDir, 0775, true);
|
||||
umask($oldMask);
|
||||
$uploadFileDir = ROOT_DIR . $this->uploadDir;
|
||||
$this->destPath = $uploadFileDir . $newFileName;
|
||||
$this->uploadFile = $this->uploadDir . $newFileName;
|
||||
@ -49,7 +51,9 @@ class FileUpload
|
||||
} else {
|
||||
if (in_array($this->fileExtension, $this->allowedFileExtensions)) {
|
||||
$this->uploadDir = $uploadDir;
|
||||
mkdir(ROOT_DIR . $this->uploadDir, 0777, true);
|
||||
$oldMask = umask(0);
|
||||
mkdir(ROOT_DIR . $this->uploadDir, 0775, true);
|
||||
umask($oldMask);
|
||||
$uploadFileDir = ROOT_DIR . $this->uploadDir;
|
||||
$this->destPath = $uploadFileDir . $this->fileName;
|
||||
$this->uploadFile = $this->uploadDir . $this->fileName;
|
||||
|
0
kernel/Flash.php
Normal file → Executable file
0
kernel/Flash.php
Normal file → Executable file
0
kernel/FormModel.php
Normal file → Executable file
0
kernel/FormModel.php
Normal file → Executable file
0
kernel/Header.php
Normal file → Executable file
0
kernel/Header.php
Normal file → Executable file
0
kernel/IGTabel/action_column/DeleteActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/DeleteActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/EditActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/EditActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/InstallActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/InstallActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/ViewActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/action_column/ViewActionColumn.php
Normal file → Executable file
0
kernel/IGTabel/btn/DangerBtn.php
Normal file → Executable file
0
kernel/IGTabel/btn/DangerBtn.php
Normal file → Executable file
2
kernel/IGTabel/btn/PrimaryBtn.php
Normal file → Executable file
2
kernel/IGTabel/btn/PrimaryBtn.php
Normal file → Executable file
@ -8,7 +8,7 @@ class PrimaryBtn
|
||||
|
||||
public function __construct(string $title, string $url, $width)
|
||||
{
|
||||
$this->btn = "<a class='btn btn-primary' href='$url' style='margin: 3px; width: $width;' >$title</a>";
|
||||
$this->btn = "<a class='btn btn-primary' href='$url' style='margin: 3px; width: '$width >$title</a>";
|
||||
}
|
||||
|
||||
public function fetch(): string
|
||||
|
0
kernel/IGTabel/btn/SuccessBtn.php
Normal file → Executable file
0
kernel/IGTabel/btn/SuccessBtn.php
Normal file → Executable file
0
kernel/Mailing.php
Normal file → Executable file
0
kernel/Mailing.php
Normal file → Executable file
0
kernel/Middleware.php
Normal file → Executable file
0
kernel/Middleware.php
Normal file → Executable file
0
kernel/Module.php
Normal file → Executable file
0
kernel/Module.php
Normal file → Executable file
0
kernel/Request.php
Normal file → Executable file
0
kernel/Request.php
Normal file → Executable file
0
kernel/ResponseType.php
Normal file → Executable file
0
kernel/ResponseType.php
Normal file → Executable file
4
kernel/RestController.php
Normal file → Executable file
4
kernel/RestController.php
Normal file → Executable file
@ -94,7 +94,9 @@ class RestController
|
||||
$model = $this->model->where('id', $id)->first();
|
||||
|
||||
foreach ($model->getFillable() as $item){
|
||||
$model->{$item} = $data[$item] ?? null;
|
||||
if (!empty($data[$item])){
|
||||
$model->{$item} = $data[$item] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
$model->save();
|
||||
|
0
kernel/Widget.php
Normal file → Executable file
0
kernel/Widget.php
Normal file → Executable file
0
kernel/admin_themes/default/layout/login.php
Normal file → Executable file
0
kernel/admin_themes/default/layout/login.php
Normal file → Executable file
19
kernel/admin_themes/default/layout/main.php
Normal file → Executable file
19
kernel/admin_themes/default/layout/main.php
Normal file → Executable file
@ -26,10 +26,13 @@
|
||||
<div class="wrapper d-flex align-items-stretch">
|
||||
<nav id="sidebar">
|
||||
<div class="p-4 pt-5">
|
||||
<a href="#" class="img logo rounded-circle mb-5"
|
||||
style="background-image: url(/resources/admin_theme/images/logo.jpg);"></a>
|
||||
<a href="<?= '/admin/user/profile' ?>" class="img logo rounded-circle mb-5"
|
||||
style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/default_user_photo/noPhoto.png' ?>);">
|
||||
</a>
|
||||
<p>
|
||||
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
|
||||
<a href="<?= '/admin/user/profile' ?>">
|
||||
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
|
||||
</a>
|
||||
</p>
|
||||
<?php \kernel\widgets\MenuWidget::create()->run(); ?>
|
||||
<div class="footer">
|
||||
@ -74,15 +77,15 @@
|
||||
</div>
|
||||
</nav>
|
||||
<?php if (\kernel\Flash::hasMessage("error")): ?>
|
||||
<div class="alert alert-danger alert-dismissible mainAlert">
|
||||
<?= \kernel\Flash::getMessage("error"); ?>
|
||||
<button type="button" class="btn-close closeAlertBtn"></button>
|
||||
</div>
|
||||
<div class="alert alert-danger alert-dismissible mainAlert">
|
||||
<?= \kernel\Flash::getMessage("error"); ?>
|
||||
<button type="button" class="btn-close closeAlertBtn"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (\kernel\Flash::hasMessage("success")): ?>
|
||||
<div class="alert alert-success alert-dismissible">
|
||||
<?= \kernel\Flash::getMessage("success"); ?>
|
||||
<button type="button" class="btn-close closeAlertBtn" ></button>
|
||||
<button type="button" class="btn-close closeAlertBtn"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?= $content ?>
|
||||
|
0
kernel/admin_themes/default/manifest.json
Normal file → Executable file
0
kernel/admin_themes/default/manifest.json
Normal file → Executable file
0
kernel/admin_themes/simple/layout/main.php
Normal file → Executable file
0
kernel/admin_themes/simple/layout/main.php
Normal file → Executable file
0
kernel/admin_themes/simple/manifest.json
Normal file → Executable file
0
kernel/admin_themes/simple/manifest.json
Normal file → Executable file
0
kernel/console/CgMigrationCreator.php
Normal file → Executable file
0
kernel/console/CgMigrationCreator.php
Normal file → Executable file
0
kernel/console/ConsoleApp.php
Normal file → Executable file
0
kernel/console/ConsoleApp.php
Normal file → Executable file
0
kernel/console/ConsoleController.php
Normal file → Executable file
0
kernel/console/ConsoleController.php
Normal file → Executable file
0
kernel/console/Out.php
Normal file → Executable file
0
kernel/console/Out.php
Normal file → Executable file
0
kernel/console/controllers/AdminConsoleController.php
Normal file → Executable file
0
kernel/console/controllers/AdminConsoleController.php
Normal file → Executable file
66
kernel/console/controllers/AdminThemeController.php
Normal file → Executable file
66
kernel/console/controllers/AdminThemeController.php
Normal file → Executable file
@ -18,31 +18,15 @@ class AdminThemeController extends ConsoleController
|
||||
throw new \Exception('Missing admin theme path "--path" specified');
|
||||
}
|
||||
|
||||
$zip = new ZipArchive;
|
||||
$tmpThemeDir = md5(time());
|
||||
$res = $zip->open(ROOT_DIR . $this->argv['path']);
|
||||
if ($res === TRUE) {
|
||||
$tmpThemeDirFull = RESOURCES_DIR . '/tmp/ad/' . $tmpThemeDir . "/";
|
||||
$zip->extractTo($tmpThemeDirFull);
|
||||
$zip->close();
|
||||
$this->out->r('Архив распакован', 'green');
|
||||
if (file_exists(ROOT_DIR . $this->argv['path'])) {
|
||||
$adminThemeService = new AdminThemeService();
|
||||
if ($adminThemeService->install($this->argv['path'])) {
|
||||
$this->out->r("Тема админ-панели установлена", 'green');
|
||||
} else {
|
||||
$this->out->r("Ошибка установки темы админ-панели", 'red');
|
||||
}
|
||||
} else {
|
||||
$this->out->r('Message: Ошибка чтения архива', 'red');
|
||||
}
|
||||
|
||||
if (file_exists($tmpThemeDirFull . "meta/manifest.json")){
|
||||
$manifestJson = getConst(file_get_contents($tmpThemeDirFull . "meta/manifest.json"));
|
||||
$manifest = Manifest::getWithVars($manifestJson);
|
||||
$this->out->r('manifest.json инициализирован', 'green');
|
||||
|
||||
$fileHelper = new Files();
|
||||
$fileHelper->copy_folder($tmpThemeDirFull . "meta", $manifest['theme_path']);
|
||||
$fileHelper->copy_folder($tmpThemeDirFull . "resources", $manifest['resource_path']);
|
||||
|
||||
$this->out->r("Удаляем временные файлы", 'green');
|
||||
$fileHelper->recursiveRemoveDir($tmpThemeDirFull);
|
||||
|
||||
$this->out->r("Тема " . $manifest['name'] . " установлена", 'green');
|
||||
$this->out->r("Тема админ-панели не найдена", 'red');
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,17 +37,11 @@ class AdminThemeController extends ConsoleController
|
||||
}
|
||||
|
||||
if (file_exists(ROOT_DIR . $this->argv['path'])) {
|
||||
$themeName = basename($this->argv['path']);
|
||||
$active_admin_theme = Option::where("key", "active_admin_theme")->first();
|
||||
if ($active_admin_theme->value === ROOT_DIR . $this->argv['path']) {
|
||||
$this->out->r("Меняем тему на базовую", 'green');
|
||||
$adminThemeService = new AdminThemeService();
|
||||
$adminThemeService->setActiveAdminTheme(KERNEL_ADMIN_THEMES_DIR . '/default');
|
||||
$this->out->r("Тема изменена", 'green');
|
||||
}
|
||||
$fileHelper = new Files();
|
||||
$fileHelper->recursiveRemoveDir(ROOT_DIR . $this->argv['path']);
|
||||
$fileHelper->recursiveRemoveDir(RESOURCES_DIR . '/' . $themeName);
|
||||
$adminThemeService = new AdminThemeService();
|
||||
$adminThemeService->uninstall($this->argv['path']);
|
||||
|
||||
|
||||
|
||||
|
||||
$this->out->r("Тема удалена", 'green');
|
||||
} else {
|
||||
@ -71,4 +49,22 @@ class AdminThemeController extends ConsoleController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function actionPackTheme(): void
|
||||
{
|
||||
if (!isset($this->argv['path'])) {
|
||||
throw new \Exception('Missing admin theme path "--path" specified');
|
||||
}
|
||||
|
||||
if (file_exists(ROOT_DIR . $this->argv['path'])) {
|
||||
$adminThemeService = new AdminThemeService();
|
||||
$adminThemeService->pack($this->argv['path']);
|
||||
$this->out->r("Тема админ-панели заархивирована", 'green');
|
||||
} else {
|
||||
$this->out->r("Тема админ-панели не найдена", 'red');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
0
kernel/console/controllers/KernelController.php
Normal file → Executable file
0
kernel/console/controllers/KernelController.php
Normal file → Executable file
0
kernel/console/controllers/MainController.php
Normal file → Executable file
0
kernel/console/controllers/MainController.php
Normal file → Executable file
0
kernel/console/controllers/MigrationController.php
Normal file → Executable file
0
kernel/console/controllers/MigrationController.php
Normal file → Executable file
0
kernel/console/controllers/ModuleController.php
Normal file → Executable file
0
kernel/console/controllers/ModuleController.php
Normal file → Executable file
0
kernel/console/controllers/SecureController.php
Normal file → Executable file
0
kernel/console/controllers/SecureController.php
Normal file → Executable file
0
kernel/console/migrations/stubs/blank.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/blank.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/create.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/create.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/migration.create.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/migration.create.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/migration.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/migration.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/migration.update.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/migration.update.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/update.stub
Normal file → Executable file
0
kernel/console/migrations/stubs/update.stub
Normal file → Executable file
4
kernel/console/routs/cli.php
Normal file → Executable file
4
kernel/console/routs/cli.php
Normal file → Executable file
@ -35,6 +35,10 @@ App::$collector->group(["prefix" => "admin-theme"], callback: function (RouteCol
|
||||
[\kernel\console\controllers\AdminThemeController::class, 'actionUninstallTheme'],
|
||||
additionalInfo: ['description' => 'Удалить тему админ-панели', 'params' => ['--path' => 'Путь к удаляемой теме']]
|
||||
);
|
||||
App::$collector->console('pack',
|
||||
[\kernel\console\controllers\AdminThemeController::class, 'actionPackTheme'],
|
||||
additionalInfo: ['description' => 'Заархивировать тему админ-панели', 'params' => ['--path' => 'Путь к теме, которую нужно заархивировать']]
|
||||
);
|
||||
});
|
||||
|
||||
App::$collector->group(["prefix" => "secure"], callback: function (RouteCollector $router){
|
||||
|
0
kernel/controllers/ModuleController.php
Normal file → Executable file
0
kernel/controllers/ModuleController.php
Normal file → Executable file
23
kernel/filters/BootstrapSelectFilter.php
Executable file
23
kernel/filters/BootstrapSelectFilter.php
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\filters;
|
||||
|
||||
use itguild\forms\builders\SelectBuilder;
|
||||
use Itguild\Tables\Filter\Filter;
|
||||
use kernel\helpers\Debug;
|
||||
|
||||
class BootstrapSelectFilter extends Filter
|
||||
{
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
$select = SelectBuilder::build($this->name, [
|
||||
'class' => 'form-control',
|
||||
'options' => $this->params['options'],
|
||||
'value' => $this->value,
|
||||
'prompt' => $this->params['prompt'] ?? null,
|
||||
]);
|
||||
|
||||
return "<td>" . $select->create()->fetch() . "</td>";
|
||||
}
|
||||
}
|
21
kernel/filters/BootstrapTextFilter.php
Executable file
21
kernel/filters/BootstrapTextFilter.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\filters;
|
||||
|
||||
use itguild\forms\builders\TextInputBuilder;
|
||||
use Itguild\Tables\Filter\Filter;
|
||||
|
||||
class BootstrapTextFilter extends Filter
|
||||
{
|
||||
|
||||
public function fetch()
|
||||
{
|
||||
$textInput = TextInputBuilder::build($this->name, [
|
||||
'value' => $this->value,
|
||||
'class' => "form-control"
|
||||
]);
|
||||
|
||||
return "<td>" . $textInput->create()->fetch() . "</td>";
|
||||
|
||||
}
|
||||
}
|
0
kernel/helpers/Debug.php
Normal file → Executable file
0
kernel/helpers/Debug.php
Normal file → Executable file
0
kernel/helpers/Files.php
Normal file → Executable file
0
kernel/helpers/Files.php
Normal file → Executable file
0
kernel/helpers/Html.php
Normal file → Executable file
0
kernel/helpers/Html.php
Normal file → Executable file
0
kernel/helpers/Manifest.php
Normal file → Executable file
0
kernel/helpers/Manifest.php
Normal file → Executable file
0
kernel/helpers/RESTClient.php
Normal file → Executable file
0
kernel/helpers/RESTClient.php
Normal file → Executable file
0
kernel/helpers/SMTP.php
Normal file → Executable file
0
kernel/helpers/SMTP.php
Normal file → Executable file
0
kernel/helpers/Slug.php
Normal file → Executable file
0
kernel/helpers/Slug.php
Normal file → Executable file
0
kernel/helpers/Version.php
Normal file → Executable file
0
kernel/helpers/Version.php
Normal file → Executable file
0
kernel/manifest.json
Normal file → Executable file
0
kernel/manifest.json
Normal file → Executable file
0
kernel/middlewares/AuthMiddleware.php
Normal file → Executable file
0
kernel/middlewares/AuthMiddleware.php
Normal file → Executable file
0
kernel/models/Menu.php
Normal file → Executable file
0
kernel/models/Menu.php
Normal file → Executable file
0
kernel/models/Option.php
Normal file → Executable file
0
kernel/models/Option.php
Normal file → Executable file
0
kernel/modules/admin_themes/AdminThemesModule.php
Normal file → Executable file
0
kernel/modules/admin_themes/AdminThemesModule.php
Normal file → Executable file
0
kernel/modules/admin_themes/controllers/AdminThemeController.php
Normal file → Executable file
0
kernel/modules/admin_themes/controllers/AdminThemeController.php
Normal file → Executable file
0
kernel/modules/admin_themes/manifest.json
Normal file → Executable file
0
kernel/modules/admin_themes/manifest.json
Normal file → Executable file
0
kernel/modules/admin_themes/routs/adminThemes.php
Normal file → Executable file
0
kernel/modules/admin_themes/routs/adminThemes.php
Normal file → Executable file
0
kernel/modules/admin_themes/views/index.php
Normal file → Executable file
0
kernel/modules/admin_themes/views/index.php
Normal file → Executable file
0
kernel/modules/admin_themes/views/view.php
Normal file → Executable file
0
kernel/modules/admin_themes/views/view.php
Normal file → Executable file
0
kernel/modules/menu/MenuModule.php
Normal file → Executable file
0
kernel/modules/menu/MenuModule.php
Normal file → Executable file
0
kernel/modules/menu/controllers/MenuController.php
Normal file → Executable file
0
kernel/modules/menu/controllers/MenuController.php
Normal file → Executable file
0
kernel/modules/menu/controllers/MenuRestController.php
Normal file → Executable file
0
kernel/modules/menu/controllers/MenuRestController.php
Normal file → Executable file
0
kernel/modules/menu/manifest.json
Normal file → Executable file
0
kernel/modules/menu/manifest.json
Normal file → Executable file
0
kernel/modules/menu/migrations/2024_09_23_125545_create_menu_table.php
Normal file → Executable file
0
kernel/modules/menu/migrations/2024_09_23_125545_create_menu_table.php
Normal file → Executable file
0
kernel/modules/menu/models/Menu.php
Normal file → Executable file
0
kernel/modules/menu/models/Menu.php
Normal file → Executable file
0
kernel/modules/menu/models/forms/CreateMenuForm.php
Normal file → Executable file
0
kernel/modules/menu/models/forms/CreateMenuForm.php
Normal file → Executable file
0
kernel/modules/menu/routs/menu.php
Normal file → Executable file
0
kernel/modules/menu/routs/menu.php
Normal file → Executable file
0
kernel/modules/menu/service/MenuService.php
Normal file → Executable file
0
kernel/modules/menu/service/MenuService.php
Normal file → Executable file
0
kernel/modules/menu/table/columns/MenuDeleteActionColumn.php
Normal file → Executable file
0
kernel/modules/menu/table/columns/MenuDeleteActionColumn.php
Normal file → Executable file
0
kernel/modules/menu/table/columns/MenuEditActionColumn.php
Normal file → Executable file
0
kernel/modules/menu/table/columns/MenuEditActionColumn.php
Normal file → Executable file
0
kernel/modules/menu/table/columns/MenuViewActionColumn.php
Normal file → Executable file
0
kernel/modules/menu/table/columns/MenuViewActionColumn.php
Normal file → Executable file
0
kernel/modules/menu/views/form.php
Normal file → Executable file
0
kernel/modules/menu/views/form.php
Normal file → Executable file
7
kernel/modules/menu/views/index.php
Normal file → Executable file
7
kernel/modules/menu/views/index.php
Normal file → Executable file
@ -19,12 +19,15 @@ $table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [
|
||||
'baseUrl' => "/admin/settings/menu",
|
||||
]));
|
||||
$table->columns([
|
||||
'parent_id' => (function ($data) {
|
||||
'parent_id' => function ($data) {
|
||||
if ($data == 0) return null;
|
||||
return Menu::find($data)->label;
|
||||
}),
|
||||
},
|
||||
'icon_file' => function ($data) {
|
||||
return $data ? "<img src='$data' width='150px'>" : "";
|
||||
},
|
||||
'status' => function ($data) {
|
||||
return Menu::getStatus()[$data];
|
||||
}
|
||||
]);
|
||||
$table->beforePrint(function () {
|
||||
|
0
kernel/modules/menu/views/view.php
Normal file → Executable file
0
kernel/modules/menu/views/view.php
Normal file → Executable file
77
kernel/modules/module_shop_client/controllers/ModuleShopClientController.php
Normal file → Executable file
77
kernel/modules/module_shop_client/controllers/ModuleShopClientController.php
Normal file → Executable file
@ -10,14 +10,12 @@ use kernel\Flash;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\helpers\Files;
|
||||
use kernel\helpers\RESTClient;
|
||||
use kernel\helpers\SMTP;
|
||||
use kernel\Mailing;
|
||||
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
||||
use kernel\Request;
|
||||
use kernel\services\AdminThemeService;
|
||||
use kernel\services\KernelService;
|
||||
use kernel\services\ModuleService;
|
||||
use kernel\services\ModuleShopService;
|
||||
use kernel\services\TokenService;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
class ModuleShopClientController extends AdminController
|
||||
@ -26,6 +24,7 @@ class ModuleShopClientController extends AdminController
|
||||
protected Client $client;
|
||||
protected ModuleService $moduleService;
|
||||
protected KernelService $kernelService;
|
||||
protected ModuleShopClientService $moduleShopClientService;
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
@ -35,6 +34,7 @@ class ModuleShopClientController extends AdminController
|
||||
$this->client = new Client();
|
||||
$this->moduleService = new ModuleService();
|
||||
$this->kernelService = new KernelService();
|
||||
$this->moduleShopClientService = new ModuleShopClientService();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +42,6 @@ class ModuleShopClientController extends AdminController
|
||||
*/
|
||||
public function actionIndex(int $page_number = 1): void
|
||||
{
|
||||
|
||||
if ($this->moduleService->issetModuleShopToken()) {
|
||||
if ($this->moduleService->isServerAvailable()) {
|
||||
|
||||
@ -157,24 +156,71 @@ class ModuleShopClientController extends AdminController
|
||||
$this->redirect('/admin/module_shop_client', 302);
|
||||
}
|
||||
|
||||
// public function actionSearch(int $page_number = 1): void
|
||||
// {
|
||||
// $request = new Request();
|
||||
// $filters = $request->get();
|
||||
//// Debug::dd($filters);
|
||||
// if ($this->moduleService->issetModuleShopToken()) {
|
||||
// if ($this->moduleService->isServerAvailable()) {
|
||||
// $modules_info = [];
|
||||
// $per_page = 8;
|
||||
// $modules = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||
// $modules = json_decode($modules->getBody()->getContents(), true);
|
||||
// foreach ($modules as $module) {
|
||||
// foreach ($filters as $key => $value) {
|
||||
// if ($value === '') continue;
|
||||
// if ($module[$key] !== $value) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// $modules_info[] = $module;
|
||||
// }
|
||||
// }
|
||||
// $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,
|
||||
// 'kernelService' => new KernelService(),
|
||||
// 'adminThemeService' => new AdminThemeService(),
|
||||
// 'filterValues' => $filters
|
||||
// ]);
|
||||
// } else {
|
||||
// $this->cgView->render("module_shop_error_connection.php");
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// $this->cgView->render("login_at_module_shop.php");
|
||||
// }
|
||||
// }
|
||||
|
||||
public function actionSearch(int $page_number = 1): void
|
||||
{
|
||||
$request = new Request();
|
||||
$filters = $request->get();
|
||||
if ($this->moduleService->issetModuleShopToken()) {
|
||||
if ($this->moduleService->isServerAvailable()) {
|
||||
$modules_info = [];
|
||||
// $modules_info = [];
|
||||
$per_page = 8;
|
||||
$modules = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||
$modules = json_decode($modules->getBody()->getContents(), true);
|
||||
foreach ($modules as $module) {
|
||||
foreach ($filters as $key => $value) {
|
||||
$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 $key => $module) {
|
||||
foreach ($filters as $column => $value) {
|
||||
if ($value === '') continue;
|
||||
if ($module[$key] !== $value) {
|
||||
break;
|
||||
if (is_numeric($value)) {
|
||||
if ($module[$column] !== $value) {
|
||||
unset($modules_info[$key]);
|
||||
}
|
||||
} elseif (is_string($value)) {
|
||||
if (!str_contains($module[$column], $value)) {
|
||||
unset($modules_info[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$modules_info[] = $module;
|
||||
}
|
||||
}
|
||||
$module_count = count($modules_info);
|
||||
@ -188,6 +234,7 @@ class ModuleShopClientController extends AdminController
|
||||
'per_page' => $per_page,
|
||||
'kernelService' => new KernelService(),
|
||||
'adminThemeService' => new AdminThemeService(),
|
||||
'filterValues' => $filters
|
||||
]);
|
||||
} else {
|
||||
$this->cgView->render("module_shop_error_connection.php");
|
||||
@ -209,7 +256,7 @@ class ModuleShopClientController extends AdminController
|
||||
$moduleShopService = new ModuleShopService();
|
||||
$result = $moduleShopService->email_auth($address);
|
||||
|
||||
if ($result['status'] == 'success'){
|
||||
if ($result['status'] == 'success') {
|
||||
$this->cgView->render('enter_code.php', ['email' => $address]);
|
||||
}
|
||||
|
||||
@ -224,7 +271,7 @@ class ModuleShopClientController extends AdminController
|
||||
$moduleShopService = new ModuleShopService();
|
||||
$result = $moduleShopService->code_check($code);
|
||||
|
||||
if (isset($result['access_token'])){
|
||||
if (isset($result['access_token'])) {
|
||||
|
||||
$envFile = \EnvEditor\EnvFile::loadFrom(ROOT_DIR . "/.env");
|
||||
|
||||
|
0
kernel/modules/module_shop_client/manifest.json
Normal file → Executable file
0
kernel/modules/module_shop_client/manifest.json
Normal file → Executable file
0
kernel/modules/module_shop_client/routs/module_shop_client.php
Normal file → Executable file
0
kernel/modules/module_shop_client/routs/module_shop_client.php
Normal file → Executable file
22
kernel/modules/module_shop_client/services/ModuleShopClientService.php
Executable file
22
kernel/modules/module_shop_client/services/ModuleShopClientService.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\modules\module_shop_client\services;
|
||||
|
||||
use kernel\helpers\RESTClient;
|
||||
|
||||
class ModuleShopClientService
|
||||
{
|
||||
// public function getModulesInfo(string $url, int $perPage, int $pageNumber): \Psr\Http\Message\ResponseInterface
|
||||
// {
|
||||
// $modules_info = RESTClient::request($url);
|
||||
// $modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||
// return array_slice($modules_info, $perPage * ($pageNumber - 1), $perPage);
|
||||
// }
|
||||
//
|
||||
// public function getModulesInfoWithFilters(string $url, int $perPage, int $pageNumber): \Psr\Http\Message\ResponseInterface
|
||||
// {
|
||||
// $modules_info = RESTClient::request($url);
|
||||
// $modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||
// return array_slice($modules_info, $perPage * ($pageNumber - 1), $perPage);
|
||||
// }
|
||||
}
|
0
kernel/modules/module_shop_client/views/enter_code.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/enter_code.php
Normal file → Executable file
45
kernel/modules/module_shop_client/views/index.php
Normal file → Executable file
45
kernel/modules/module_shop_client/views/index.php
Normal file → Executable file
@ -7,6 +7,7 @@
|
||||
* @var \kernel\services\ModuleService $moduleService
|
||||
* @var \kernel\services\KernelService $kernelService
|
||||
* @var \kernel\services\AdminThemeService $adminThemeService
|
||||
* @var array $filterValues
|
||||
*/
|
||||
|
||||
use Itguild\Tables\ListJsonTable;
|
||||
@ -30,7 +31,6 @@ $meta['total'] = $module_count;
|
||||
|
||||
$info_to_table['meta'] = $meta;
|
||||
$info_to_table['data'] = $modules_info;
|
||||
$info_to_table['filters'] = ['type'];
|
||||
|
||||
$table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
|
||||
@ -40,8 +40,24 @@ $table->addAction(function ($row, $url) use ($moduleService) {
|
||||
return \kernel\widgets\IconBtn\IconBtnViewWidget::create(['url' => $url])->run();
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService){
|
||||
if ($row['slug'] !== 'kernel') {
|
||||
$table->columns([
|
||||
'type' => [
|
||||
'filter' => [
|
||||
'class' => \kernel\filters\BootstrapSelectFilter::class,
|
||||
'params' => [
|
||||
'options' => [
|
||||
'kernel' => 'kernel',
|
||||
'entity' => 'entity',
|
||||
],
|
||||
'prompt' => 'Не выбрано'
|
||||
],
|
||||
'value' => $filterValues['type'] ?? ''
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||
if ($row['type'] === 'entity' || $row['type'] === 'additional_property') {
|
||||
if ($moduleService->isInstall($row['slug'])) {
|
||||
$url = "$url/delete/?slug=" . $row['slug'];
|
||||
|
||||
@ -52,16 +68,19 @@ $table->addAction(function ($row, $url) use ($moduleService){
|
||||
return \kernel\widgets\IconBtn\IconBtnInstallWidget::create(['url' => $url])->run();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||
$slug = $row['slug'];
|
||||
if ($moduleService->isInstall($slug)) {
|
||||
if (!$moduleService->isLastVersion($slug)) {
|
||||
$url = "$url/update/?slug=" . $slug;
|
||||
if ($row['type'] === 'entity' || $row['type'] === 'additional_property') {
|
||||
$slug = $row['slug'];
|
||||
if ($moduleService->isInstall($slug)) {
|
||||
if (!$moduleService->isLastVersion($slug)) {
|
||||
$url = "$url/update/?slug=" . $slug;
|
||||
|
||||
return \kernel\widgets\IconBtn\IconBtnUpdateWidget::create(['url' => $url])->run();
|
||||
return \kernel\widgets\IconBtn\IconBtnUpdateWidget::create(['url' => $url])->run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +88,7 @@ $table->addAction(function ($row, $url) use ($moduleService) {
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($kernelService) {
|
||||
$slug = $row['slug'];
|
||||
if ($slug === 'kernel') {
|
||||
if ($row['type'] === 'kernel') {
|
||||
if (!$kernelService->isLastVersion()) {
|
||||
$url = "$url/kernel/update_form/";
|
||||
|
||||
@ -82,9 +100,8 @@ $table->addAction(function ($row, $url) use ($kernelService) {
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($adminThemeService) {
|
||||
$type = $row['type'];
|
||||
$slug = $row['slug'];
|
||||
if ($type === 'admin_theme') {
|
||||
if ($row['type'] === 'admin_theme') {
|
||||
$slug = $row['slug'];
|
||||
if ($adminThemeService->isInstall($slug)) {
|
||||
if (!$adminThemeService->isLastVersion($slug)) {
|
||||
$url = "$url/admin_theme/update/";
|
||||
|
0
kernel/modules/module_shop_client/views/kernel_update.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/kernel_update.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/login_at_module_shop.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/login_at_module_shop.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/module_shop_error_connection.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/module_shop_error_connection.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/success_login.php
Normal file → Executable file
0
kernel/modules/module_shop_client/views/success_login.php
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user