From b9e1a5382b713e055604708946d13dd2bf00e1d1 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Tue, 5 Nov 2024 13:24:04 +0300 Subject: [PATCH] some fix --- .../module_shop/controllers/ModuleShopController.php | 10 ++++------ kernel/helpers/Files.php | 4 ++-- kernel/modules/post/manifest.json | 2 +- kernel/services/ModuleService.php | 11 ++++++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/modules/module_shop/controllers/ModuleShopController.php b/app/modules/module_shop/controllers/ModuleShopController.php index dea7056..6316bec 100644 --- a/app/modules/module_shop/controllers/ModuleShopController.php +++ b/app/modules/module_shop/controllers/ModuleShopController.php @@ -5,7 +5,6 @@ namespace app\modules\module_shop\controllers; use app\modules\module_shop\models\forms\CreateModuleShopForm; use app\modules\module_shop\models\ModuleShop; use app\modules\module_shop\services\ModuleShopService; -use Cassandra\Date; use JetBrains\PhpStorm\NoReturn; use kernel\AdminController; use kernel\app_modules\tag\services\TagService; @@ -13,7 +12,6 @@ use kernel\FileUpload; use kernel\Flash; use kernel\helpers\Debug; use kernel\services\ModuleService; -use mysql_xdevapi\Exception; use ZipArchive; class ModuleShopController extends AdminController @@ -41,7 +39,7 @@ class ModuleShopController extends AdminController $moduleShopForm->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', 'itguild']); + $file = new FileUpload($_FILES['path_to_archive'], ['zip', 'rar', 'igm']); $file->upload(); $moduleShopForm->setItem('path_to_archive', $file->getUploadFile()); } @@ -90,7 +88,7 @@ class ModuleShopController extends AdminController $module = ModuleShop::find($id); if (!$module) { - throw new Exception("The module not found"); + throw new \Exception("The module not found"); } $this->cgView->render("view.php", ['module' => $module]); } @@ -100,7 +98,7 @@ class ModuleShopController extends AdminController { $module = ModuleShop::find($id); if (!$module) { - throw new Exception("The module not found"); + throw new \Exception("The module not found"); } $name = $module->name; @@ -113,7 +111,7 @@ class ModuleShopController extends AdminController { $module = ModuleShop::find($id); if (!$module) { - throw new Exception("The module not found"); + throw new \Exception("The module not found"); } $this->moduleShopService->packModule($module); } diff --git a/kernel/helpers/Files.php b/kernel/helpers/Files.php index 4cd710a..d140f2c 100644 --- a/kernel/helpers/Files.php +++ b/kernel/helpers/Files.php @@ -82,11 +82,11 @@ class Files if(is_dir($include)) { if ($include->getFilename() === 'app_modules') continue; - $tmpFolder = $folder . '/' . $include->getFilename() . '/'; + $tmpFolder = $folder . '/' . $include->getFilename(); $this->recursiveAddFile($zip, $include, $tmpFolder); } if (is_file($include)) { - $zip->addFile($include->getPathName(), $folder . $include->getFilename()); + $zip->addFile($include->getPathName(), $folder . "/" . $include->getFilename()); } } } diff --git a/kernel/modules/post/manifest.json b/kernel/modules/post/manifest.json index 2de6805..7ff222b 100644 --- a/kernel/modules/post/manifest.json +++ b/kernel/modules/post/manifest.json @@ -1,6 +1,6 @@ { "name": "Post", - "version": "0.1", + "version": "0.2", "author": "ITGuild", "slug": "post", "description": "Post module", diff --git a/kernel/services/ModuleService.php b/kernel/services/ModuleService.php index bf65403..646f449 100644 --- a/kernel/services/ModuleService.php +++ b/kernel/services/ModuleService.php @@ -342,15 +342,20 @@ class ModuleService $tmpModuleDirFull = RESOURCES_DIR . '/tmp/ad/' . $moduleName . "/"; $fileHelper = new Files(); - $fileHelper->copy_folder(APP_DIR . '/modules/' . $moduleName, $tmpModuleDirFull . 'app/'); - $fileHelper->copy_folder(KERNEL_APP_MODULES_DIR . '/' . $moduleName, $tmpModuleDirFull . 'kernel/'); + $fileHelper->copy_folder(ROOT_DIR . $path, $tmpModuleDirFull . 'app/'); + if (file_exists(KERNEL_APP_MODULES_DIR . '/' . $moduleName)){ + $fileHelper->copy_folder(KERNEL_APP_MODULES_DIR . '/' . $moduleName, $tmpModuleDirFull . 'kernel/'); + } + else { + mkdir($tmpModuleDirFull . 'kernel/'); + } if (!is_dir(RESOURCES_DIR . '/tmp/modules')) { mkdir(RESOURCES_DIR . '/tmp/modules', 0777, true); } $fileHelper->pack($tmpModuleDirFull, RESOURCES_DIR . '/tmp/modules/' . $moduleName . '.igm'); - $fileHelper->recursiveRemoveDir($tmpModuleDirFull); + //$fileHelper->recursiveRemoveDir($tmpModuleDirFull); } /**