diff --git a/Source/.htaccess b/Source/.htaccess index ffd584f..374a44e 100644 --- a/Source/.htaccess +++ b/Source/.htaccess @@ -11,4 +11,7 @@ RewriteRule ^createForm$ index.php?page=createForm [L] RewriteRule ^addKeyword$ index.php?page=addKeyword [L] RewriteRule "goToAdmin" index.php?page=goToAdmin [L] RewriteRule ^goToAdminLogin$ index.php?page=goToAdminLogin [L] -RewriteRule ^login$ index.php?page=login [L] \ No newline at end of file +RewriteRule ^login$ index.php?page=login [L] +RewriteRule ^goToCategories$ index.php?page=goToCategories [L] +RewriteRule ^goToQuestions$ index.php?page=goToQuestions [L] +RewriteRule ^goToResponses$ index.php?page=goToResponses [L] \ No newline at end of file diff --git a/Source/API/script/Gateway/GatewayForm.php b/Source/API/script/Gateway/GatewayForm.php index 3a57011..dafd45b 100644 --- a/Source/API/script/Gateway/GatewayForm.php +++ b/Source/API/script/Gateway/GatewayForm.php @@ -108,4 +108,11 @@ class GatewayForm ':id' => array($form->getId(), PDO::PARAM_INT) )); } + + public function existsForm(): bool + { + $query = "SELECT * FROM Form"; + $this->connection->executeQuery($query); + return !empty($this->connection->getResults()); + } } diff --git a/Source/Controller/FrontController.php b/Source/Controller/FrontController.php index 8c0666d..ebb37d0 100644 --- a/Source/Controller/FrontController.php +++ b/Source/Controller/FrontController.php @@ -68,5 +68,9 @@ class FrontController { $this->router->map('GET','/goToAdmin',array($controller['Admin'],'goToAdmin'),'goToAdmin'); $this->router->map('GET','/goToAdminLogin',array($controller['Candidate'],'goToAdminLogin'),'goToLogin'); $this->router->map('POST','/login',array($controller['Candidate'],'login'),'login'); + $this->router->map('GET','/logout',array($controller['Admin'],'logout'),'logout'); + $this->router->map('GET','/goToCategories',array($controller['Admin'],'goToCategories'),'goToCategories'); + $this->router->map('GET','/goToQuestions',array($controller['Admin'],'goToQuestions'),'goToQuestions'); + $this->router->map('GET','/goToResponses',array($controller['Admin'],'goToResponses'),'goToResponses'); } } diff --git a/Source/Model/ModelAdmin.php b/Source/Model/ModelAdmin.php index 3216d17..f1f2618 100644 --- a/Source/Model/ModelAdmin.php +++ b/Source/Model/ModelAdmin.php @@ -113,9 +113,14 @@ class ModelAdmin */ public function getQuestions(): array { - $idForm = (new GatewayForm())->getForm()[0]["id"]; - $questionsArray = (new GatewayQuestion())->getAllQuestions($idForm); - return Factory::getBuiltObjects($questionsArray, "Question"); + if((new GatewayForm())->existsForm()) { + $idForm = (new GatewayForm())->getForm()[0]["id"]; + $questionsArray = (new GatewayQuestion())->getAllQuestions($idForm); + return Factory::getBuiltObjects($questionsArray, "Question"); + } + else { + return array(); + } } diff --git a/Source/Views/HTML/admin.php b/Source/Views/HTML/admin.php index 12a68ce..8880188 100644 --- a/Source/Views/HTML/admin.php +++ b/Source/Views/HTML/admin.php @@ -19,9 +19,9 @@

Administration

- Les catégories - Les questions - Les réponses + Les catégories + Les questions + Les réponses
diff --git a/Source/Views/HTML/categories.php b/Source/Views/HTML/categories.php index b1e7b70..ac4b254 100644 --- a/Source/Views/HTML/categories.php +++ b/Source/Views/HTML/categories.php @@ -20,9 +20,9 @@

Administration

- Les catégories - Les questions - Les réponses + Les catégories + Les questions + Les réponses

diff --git a/Source/Views/HTML/questions.php b/Source/Views/HTML/questions.php index 7137b84..36739dd 100644 --- a/Source/Views/HTML/questions.php +++ b/Source/Views/HTML/questions.php @@ -20,9 +20,9 @@

Administration

- Les catégories - Les questions - Les réponses + Les catégories + Les questions + Les réponses

diff --git a/Source/Views/HTML/responses.php b/Source/Views/HTML/responses.php index 4a3fefc..3291cab 100644 --- a/Source/Views/HTML/responses.php +++ b/Source/Views/HTML/responses.php @@ -20,9 +20,9 @@

Administration

- Les catégories - Les questions - Les réponses + Les catégories + Les questions + Les réponses