From 85f9d94f1b202e09fa90023a79e7c784a9572a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 10 Oct 2022 06:54:45 -0300 Subject: [PATCH] Add basic routing system for setup pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/src/setup/scripts.js | 4 +-- .../Controllers/Setup/MainController.php | 2 +- .../Setup/ShowConfigController.php | 6 +++-- libraries/classes/Setup/FormProcessing.php | 4 +-- setup/config.php | 20 --------------- setup/index.php | 25 ++++++++++++++++++- setup/validate.php | 20 --------------- templates/setup/base.twig | 4 +-- templates/setup/config/index.twig | 2 +- templates/setup/error.twig | 6 ++--- templates/setup/home/index.twig | 12 ++++----- test/classes/Setup/FormProcessingTest.php | 4 +-- 12 files changed, 47 insertions(+), 62 deletions(-) delete mode 100644 setup/config.php delete mode 100644 setup/validate.php diff --git a/js/src/setup/scripts.js b/js/src/setup/scripts.js index fa1a58f94a..85895744bc 100644 --- a/js/src/setup/scripts.js +++ b/js/src/setup/scripts.js @@ -83,7 +83,7 @@ function ajaxValidate (parent, id, values) { } $parent.data('ajax', $.ajax({ - url: 'validate.php', + url: '../setup/index.php?route=/setup/validate', cache: false, type: 'POST', data: { @@ -235,7 +235,7 @@ $(function () { e.preventDefault(); var $this = $(this); $.post($this.attr('href'), $this.attr('data-post'), function () { - window.location.replace('index.php'); + window.location.replace('../setup/index.php?route=/setup'); }); }); }); diff --git a/libraries/classes/Controllers/Setup/MainController.php b/libraries/classes/Controllers/Setup/MainController.php index f765f1a7c6..19315baa12 100644 --- a/libraries/classes/Controllers/Setup/MainController.php +++ b/libraries/classes/Controllers/Setup/MainController.php @@ -58,7 +58,7 @@ final class MainController $controller->destroy([ 'id' => $params['id'] ?? null, ]); - header('Location: index.php' . Url::getCommonRaw()); + header('Location: ../setup/index.php' . Url::getCommonRaw(['route' => '/setup'])); return; } diff --git a/libraries/classes/Controllers/Setup/ShowConfigController.php b/libraries/classes/Controllers/Setup/ShowConfigController.php index 9b7d6b5400..31ce72612d 100644 --- a/libraries/classes/Controllers/Setup/ShowConfigController.php +++ b/libraries/classes/Controllers/Setup/ShowConfigController.php @@ -35,7 +35,7 @@ final class ShowConfigController // Clear current config and return to main page $GLOBALS['ConfigFile']->resetConfigData(); // drop post data - $response->generateHeader303('index.php' . Url::getCommonRaw()); + $response->generateHeader303('../setup/index.php' . Url::getCommonRaw(['route' => '/setup'])); return; } @@ -52,6 +52,8 @@ final class ShowConfigController } // Show generated config file in a