diff --git a/app/modules/tag/manifest.json b/app/modules/tag/manifest.json index 7372b40..3cbfdda 100644 --- a/app/modules/tag/manifest.json +++ b/app/modules/tag/manifest.json @@ -4,6 +4,7 @@ "author": "ITGuild", "slug": "tag", "description": "Tags module", + "module_path": "{APP}/modules/{slug}", "module_class": "app\\modules\\tag\\TagModule", "module_class_file": "{APP}/modules/tag/TagModule.php" } \ No newline at end of file diff --git a/app/tables/columns/menu/MenuDeleteActionColumn.php b/app/tables/columns/menu/MenuDeleteActionColumn.php deleted file mode 100644 index 8b70f7d..0000000 --- a/app/tables/columns/menu/MenuDeleteActionColumn.php +++ /dev/null @@ -1,17 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Удалить "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/menu/MenuEditActionColumn.php b/app/tables/columns/menu/MenuEditActionColumn.php deleted file mode 100644 index 33cded5..0000000 --- a/app/tables/columns/menu/MenuEditActionColumn.php +++ /dev/null @@ -1,17 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Редактировать "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/menu/MenuViewActionColumn.php b/app/tables/columns/menu/MenuViewActionColumn.php deleted file mode 100644 index b6b8831..0000000 --- a/app/tables/columns/menu/MenuViewActionColumn.php +++ /dev/null @@ -1,17 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Просмотр "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/post/PostDeleteActionColumn.php b/app/tables/columns/post/PostDeleteActionColumn.php deleted file mode 100644 index 3512308..0000000 --- a/app/tables/columns/post/PostDeleteActionColumn.php +++ /dev/null @@ -1,16 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Удалить "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/post/PostEditActionColumn.php b/app/tables/columns/post/PostEditActionColumn.php deleted file mode 100644 index 2d057ac..0000000 --- a/app/tables/columns/post/PostEditActionColumn.php +++ /dev/null @@ -1,16 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Редактировать "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/post/PostViewActionColumn.php b/app/tables/columns/post/PostViewActionColumn.php deleted file mode 100644 index 565856c..0000000 --- a/app/tables/columns/post/PostViewActionColumn.php +++ /dev/null @@ -1,16 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Просмотр "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/user/UserDeleteActionColumn.php b/app/tables/columns/user/UserDeleteActionColumn.php deleted file mode 100644 index 5d3f411..0000000 --- a/app/tables/columns/user/UserDeleteActionColumn.php +++ /dev/null @@ -1,16 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Удалить "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/user/UserEditActionColumn.php b/app/tables/columns/user/UserEditActionColumn.php deleted file mode 100644 index 16dc87d..0000000 --- a/app/tables/columns/user/UserEditActionColumn.php +++ /dev/null @@ -1,16 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Редактировать "; -// } -//} \ No newline at end of file diff --git a/app/tables/columns/user/UserViewActionColumn.php b/app/tables/columns/user/UserViewActionColumn.php deleted file mode 100644 index 60f7bae..0000000 --- a/app/tables/columns/user/UserViewActionColumn.php +++ /dev/null @@ -1,16 +0,0 @@ -baseUrl . $this->prefix . $this->id; -// return " Просмотр "; -// } -//} \ No newline at end of file diff --git a/kernel/console/controllers/ModuleController.php b/kernel/console/controllers/ModuleController.php new file mode 100644 index 0000000..4201f5f --- /dev/null +++ b/kernel/console/controllers/ModuleController.php @@ -0,0 +1,78 @@ +argv['path'])) { + throw new \Exception('Missing module path "--path" specified'); + } + + $zip = new ZipArchive; + $tmpModuleDir = md5(time()); + $res = $zip->open(ROOT_DIR . $this->argv['path']); + if ($res === TRUE) { + $tmpModuleDirFull = RESOURCES_DIR . '/tmp/ad/' . $tmpModuleDir . "/"; + $zip->extractTo($tmpModuleDirFull); + $zip->close(); + $this->out->r('Архив распакован', 'green'); + } else { + $this->out->r('Message: Ошибка чтения архива', 'red'); + } + + if (file_exists($tmpModuleDirFull . "manifest.json")){ + $manifestJson = getConst(file_get_contents($tmpModuleDirFull . "manifest.json")); + $manifest = Manifest::getWithVars($manifestJson); + $this->out->r('manifest.json инициализирован', 'green'); + + $fileHelper = new Files(); + $fileHelper->copy_folder($tmpModuleDirFull, $manifest['module_path']); + + $this->out->r("Удаляем временные файлы", 'green'); + $fileHelper->recursiveRemoveDir($tmpModuleDirFull); + + $this->out->r("Модуль " . $manifest['name'] . " установлен", 'green'); + } + } + + /** + * @throws \Exception + */ + public function actionUninstallModule(): void + { + if (!isset($this->argv['path'])) { + throw new \Exception('Missing module path "--path" specified'); + } + + if (file_exists(ROOT_DIR . $this->argv['path'])) { + $moduleService = new ModuleService(); + $moduleInfo = $moduleService->getModuleInfo(ROOT_DIR . $this->argv['path']); + + if ($moduleService->isActive($moduleInfo['slug'])) { + $moduleService->setActiveModule($moduleInfo['slug']); + } + + $fileHelper = new Files(); + $fileHelper->recursiveRemoveDir(ROOT_DIR . $this->argv['path']); + + $this->out->r("Модуль удален", 'green'); + } else { + var_dump($this->argv['path']); + $this->out->r("Модуль не найден", 'red'); + } + } + +} \ No newline at end of file diff --git a/kernel/console/routs/cli.php b/kernel/console/routs/cli.php index 4c6caa2..5976755 100644 --- a/kernel/console/routs/cli.php +++ b/kernel/console/routs/cli.php @@ -21,3 +21,8 @@ App::$collector->group(["prefix" => "admin"], callback: function (RouteCollector App::$collector->console('init', [\kernel\console\controllers\AdminConsoleController::class, 'actionInit']); }); +App::$collector->group(["prefix" => "module"], callback: function (RouteCollector $router){ + App::$collector->console('install', [\kernel\console\controllers\ModuleController::class, 'actionInstallModule']); + App::$collector->console('uninstall', [\kernel\console\controllers\ModuleController::class, 'actionUninstallModule']); +}); + diff --git a/kernel/modules/menu/controllers/MenuController.php b/kernel/modules/menu/controllers/MenuController.php index 2c8daf0..3d36d5d 100644 --- a/kernel/modules/menu/controllers/MenuController.php +++ b/kernel/modules/menu/controllers/MenuController.php @@ -97,7 +97,6 @@ class MenuController extends AdminController $menuForm = new CreateMenuForm(); $menuForm->load($_REQUEST); -// Debug::dd($_REQUEST); if (isset($_FILES['icon_file']) && $_FILES['icon_file']['error'] === UPLOAD_ERR_OK) { $file = new FileUpload($_FILES['icon_file'], ['jpg', 'jpeg', 'png'], $_REQUEST['hashing'] ?? true); diff --git a/resources/tmp/modules/tag.zip b/resources/tmp/modules/tag.zip new file mode 100644 index 0000000..940a046 Binary files /dev/null and b/resources/tmp/modules/tag.zip differ diff --git a/resources/tmp/modules/tag/TagModule.php b/resources/tmp/modules/tag/TagModule.php new file mode 100644 index 0000000..ee01d77 --- /dev/null +++ b/resources/tmp/modules/tag/TagModule.php @@ -0,0 +1,33 @@ +menuService = new MenuService(); + } + + /** + * @throws \Exception + */ + public function init(): void + { + $this->menuService->createItem([ + "label" => "Тэги", + "url" => "/admin/tag", + "slug" => "tag", + ]); + } + + public function deactivate(): void + { + $this->menuService->removeItemBySlug("tag"); + } +} \ No newline at end of file diff --git a/resources/tmp/modules/tag/manifest.json b/resources/tmp/modules/tag/manifest.json new file mode 100644 index 0000000..3cbfdda --- /dev/null +++ b/resources/tmp/modules/tag/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "Tags", + "version": "0.1", + "author": "ITGuild", + "slug": "tag", + "description": "Tags module", + "module_path": "{APP}/modules/{slug}", + "module_class": "app\\modules\\tag\\TagModule", + "module_class_file": "{APP}/modules/tag/TagModule.php" +} \ No newline at end of file