From e3f93e5b42721c19828d047f5cf8dea929d3ca9c Mon Sep 17 00:00:00 2001 From: Juzaweb Date: Sat, 5 Aug 2023 13:58:56 +0700 Subject: [PATCH] :+1: Test Disabled frontend support --- .../Backend/Appearance/EditorController.php | 31 ++++++++++++++----- .../backend/appearance/editor/index.blade.php | 4 ++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/modules/Backend/Http/Controllers/Backend/Appearance/EditorController.php b/modules/Backend/Http/Controllers/Backend/Appearance/EditorController.php index ec525ee09..c7fe2ac42 100644 --- a/modules/Backend/Http/Controllers/Backend/Appearance/EditorController.php +++ b/modules/Backend/Http/Controllers/Backend/Appearance/EditorController.php @@ -38,11 +38,12 @@ public function index(Request $request, string $theme = null): View $themes = $this->themeRepository->all(); $directories = $this->getThemeTree("{$themePath}/views", convert_linux_path($themePath)); - $file = $this->getCurrentFile($request); - $path = Crypt::decryptString($file); - if (!file_exists("{$themePath}/{$path}")) { - return abort(404); - } + $file = $this->getCurrentFile($request, $themePath); + //$path = Crypt::decryptString($file); + + /*if (!file_exists("{$themePath}/{$path}")) { + abort(404, "Cannot find file {$path}"); + }*/ return view( 'cms::backend.appearance.editor.index', @@ -178,11 +179,27 @@ protected function getLanguageFile(string $file): string }; } - protected function getCurrentFile(Request $request): string + protected function getCurrentFile(Request $request, string $themePath): string { return $request->get( 'file', - Crypt::encryptString('views/index.twig') + Crypt::encryptString($this->findIndexFile($themePath)) ); } + + protected function findIndexFile(string $themePath): ?string + { + // Twig theme + if (File::exists("{$themePath}/views/index.twig")) { + return 'views/index.twig'; + } + + // Blade theme + if (File::exists("{$themePath}/views/index.blade.php")) { + return 'views/index.blade.php'; + } + + // Inertia theme + return 'views/index.tsx'; + } } diff --git a/modules/Backend/resources/views/backend/appearance/editor/index.blade.php b/modules/Backend/resources/views/backend/appearance/editor/index.blade.php index 7ee2da764..73110df78 100644 --- a/modules/Backend/resources/views/backend/appearance/editor/index.blade.php +++ b/modules/Backend/resources/views/backend/appearance/editor/index.blade.php @@ -26,7 +26,9 @@