diff --git a/app/modules/module_shop/controllers/ThemeShopController.php b/app/modules/module_shop/controllers/ThemeShopController.php
new file mode 100644
index 0000000..4ec7325
--- /dev/null
+++ b/app/modules/module_shop/controllers/ThemeShopController.php
@@ -0,0 +1,84 @@
+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", "Ошибка добавления темы сайта:
" . $themeShopForm->getErrorsStr());
+ $this->redirect("/admin/module_shop/theme/create");
+ }
+}
\ No newline at end of file
diff --git a/app/modules/module_shop/models/forms/CreateThemeShopForm.php b/app/modules/module_shop/models/forms/CreateThemeShopForm.php
new file mode 100644
index 0000000..1b478e3
--- /dev/null
+++ b/app/modules/module_shop/models/forms/CreateThemeShopForm.php
@@ -0,0 +1,22 @@
+ 'required|min-str-len:3',
+ 'version' => 'required',
+ 'description' => '',
+ 'author' => 'required',
+ 'status' => 'required',
+ 'slug' => 'required',
+ 'type' => 'required',
+ 'path_to_archive' => 'required',
+ ];
+ }
+}
\ No newline at end of file
diff --git a/app/modules/module_shop/views/theme/form.php b/app/modules/module_shop/views/theme/form.php
new file mode 100644
index 0000000..ad51235
--- /dev/null
+++ b/app/modules/module_shop/views/theme/form.php
@@ -0,0 +1,51 @@
+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();
+
+?>
+
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [
+ 'class' => "btn btn-primary ",
+ 'value' => 'Отправить',
+ 'typeInput' => 'submit'
+ ])
+ ->render();
+ ?>
+
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [
+ 'class' => "btn btn-warning",
+ 'value' => 'Сбросить',
+ 'typeInput' => 'reset'
+ ])
+ ->render();
+ ?>
+
+
+endForm();
diff --git a/bootstrap/db.php b/bootstrap/db.php
old mode 100644
new mode 100755
diff --git a/bootstrap/header.php b/bootstrap/header.php
old mode 100644
new mode 100755
diff --git a/bootstrap/secure.php b/bootstrap/secure.php
old mode 100644
new mode 100755
diff --git a/kernel/AdminController.php b/kernel/AdminController.php
old mode 100644
new mode 100755
diff --git a/kernel/App.php b/kernel/App.php
old mode 100644
new mode 100755
diff --git a/kernel/CgRouteCollector.php b/kernel/CgRouteCollector.php
old mode 100644
new mode 100755
diff --git a/kernel/CgView.php b/kernel/CgView.php
old mode 100644
new mode 100755
diff --git a/kernel/Controller.php b/kernel/Controller.php
old mode 100644
new mode 100755
diff --git a/kernel/Database.php b/kernel/Database.php
old mode 100644
new mode 100755
diff --git a/kernel/EntityRelation.php b/kernel/EntityRelation.php
old mode 100644
new mode 100755
diff --git a/kernel/FileUpload.php b/kernel/FileUpload.php
old mode 100644
new mode 100755
index 7a1705b..a61893c
--- a/kernel/FileUpload.php
+++ b/kernel/FileUpload.php
@@ -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;
diff --git a/kernel/Flash.php b/kernel/Flash.php
old mode 100644
new mode 100755
diff --git a/kernel/FormModel.php b/kernel/FormModel.php
old mode 100644
new mode 100755
diff --git a/kernel/Header.php b/kernel/Header.php
old mode 100644
new mode 100755
diff --git a/kernel/IGTabel/action_column/DeleteActionColumn.php b/kernel/IGTabel/action_column/DeleteActionColumn.php
old mode 100644
new mode 100755
diff --git a/kernel/IGTabel/action_column/EditActionColumn.php b/kernel/IGTabel/action_column/EditActionColumn.php
old mode 100644
new mode 100755
diff --git a/kernel/IGTabel/action_column/InstallActionColumn.php b/kernel/IGTabel/action_column/InstallActionColumn.php
old mode 100644
new mode 100755
diff --git a/kernel/IGTabel/action_column/ViewActionColumn.php b/kernel/IGTabel/action_column/ViewActionColumn.php
old mode 100644
new mode 100755
diff --git a/kernel/IGTabel/btn/DangerBtn.php b/kernel/IGTabel/btn/DangerBtn.php
old mode 100644
new mode 100755
diff --git a/kernel/IGTabel/btn/PrimaryBtn.php b/kernel/IGTabel/btn/PrimaryBtn.php
old mode 100644
new mode 100755
index 2abe09e..b389401
--- a/kernel/IGTabel/btn/PrimaryBtn.php
+++ b/kernel/IGTabel/btn/PrimaryBtn.php
@@ -8,7 +8,7 @@ class PrimaryBtn
public function __construct(string $title, string $url, $width)
{
- $this->btn = "$title";
+ $this->btn = "$title";
}
public function fetch(): string
diff --git a/kernel/IGTabel/btn/SuccessBtn.php b/kernel/IGTabel/btn/SuccessBtn.php
old mode 100644
new mode 100755
diff --git a/kernel/Mailing.php b/kernel/Mailing.php
old mode 100644
new mode 100755
diff --git a/kernel/Middleware.php b/kernel/Middleware.php
old mode 100644
new mode 100755
diff --git a/kernel/Module.php b/kernel/Module.php
old mode 100644
new mode 100755
diff --git a/kernel/Request.php b/kernel/Request.php
old mode 100644
new mode 100755
diff --git a/kernel/ResponseType.php b/kernel/ResponseType.php
old mode 100644
new mode 100755
diff --git a/kernel/RestController.php b/kernel/RestController.php
old mode 100644
new mode 100755
index 0da92ff..2d7596d
--- a/kernel/RestController.php
+++ b/kernel/RestController.php
@@ -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();
diff --git a/kernel/Widget.php b/kernel/Widget.php
old mode 100644
new mode 100755
diff --git a/kernel/admin_themes/default/layout/login.php b/kernel/admin_themes/default/layout/login.php
old mode 100644
new mode 100755
diff --git a/kernel/admin_themes/default/layout/main.php b/kernel/admin_themes/default/layout/main.php
old mode 100644
new mode 100755
index db00106..98be7fb
--- a/kernel/admin_themes/default/layout/main.php
+++ b/kernel/admin_themes/default/layout/main.php
@@ -26,10 +26,13 @@