themes add and some fix

This commit is contained in:
2025-01-19 20:50:25 +03:00
parent 219ca30608
commit a943b960ad
200 changed files with 796 additions and 106 deletions

0
kernel/console/CgMigrationCreator.php Normal file → Executable file
View File

0
kernel/console/ConsoleApp.php Normal file → Executable file
View File

0
kernel/console/ConsoleController.php Normal file → Executable file
View File

0
kernel/console/Out.php Normal file → Executable file
View File

0
kernel/console/controllers/AdminConsoleController.php Normal file → Executable file
View File

66
kernel/console/controllers/AdminThemeController.php Normal file → Executable file
View 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
View File

0
kernel/console/controllers/MainController.php Normal file → Executable file
View File

0
kernel/console/controllers/MigrationController.php Normal file → Executable file
View File

0
kernel/console/controllers/ModuleController.php Normal file → Executable file
View File

0
kernel/console/controllers/SecureController.php Normal file → Executable file
View File

0
kernel/console/migrations/stubs/blank.stub Normal file → Executable file
View File

0
kernel/console/migrations/stubs/create.stub Normal file → Executable file
View File

0
kernel/console/migrations/stubs/migration.create.stub Normal file → Executable file
View File

0
kernel/console/migrations/stubs/migration.stub Normal file → Executable file
View File

0
kernel/console/migrations/stubs/migration.update.stub Normal file → Executable file
View File

0
kernel/console/migrations/stubs/update.stub Normal file → Executable file
View File

4
kernel/console/routs/cli.php Normal file → Executable file
View 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){