From 7e73139acebbc50c826032121bc95999ea17fa32 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:02:45 +0100 Subject: [PATCH 1/6] make '+' button redirect to /recipe/new --- Views/common/header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Views/common/header.php b/Views/common/header.php index 2bee9e0..5d2967a 100644 --- a/Views/common/header.php +++ b/Views/common/header.php @@ -2,7 +2,7 @@ $array_header = array( 'Logo' => "/", "Recette" => "/Recipe/view/36", - "+" => "/recipe/edit", + "+" => "/recipe/new", "Rechercher" => "rechercher", '' => "/user/view" ); From 961cd27e882b6a549f62ba7a4ac32083ff23ef2d Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:03:17 +0100 Subject: [PATCH 2/6] move debug echo in recipe/edit --- Views/recipe/edit.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php index 3182faf..dabc63b 100644 --- a/Views/recipe/edit.php +++ b/Views/recipe/edit.php @@ -3,7 +3,6 @@ function getOrEmpty($A_Dict, $S_keyName) { if (isset($A_Dict[$S_keyName])) { return $A_Dict[$S_keyName]; } else { - echo "$S_keyName EMPTY"; if($S_keyName == "TYPE" || $S_keyName == "INGREDIENTS") return array(); return ""; From ff6ac2eb4976f4a6a50122c7199ad99dfc6fcb6d Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:03:23 +0100 Subject: [PATCH 3/6] add action recipe/new --- Controllers/RecipeController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index 57e62f9..70f0cdc 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -47,6 +47,11 @@ final class RecipeController View::show("recipe/edit", $A_returnArray); } + public function newAction(Array $A_urlParams = null, Array $A_postParams = null) + { + View::show("recipe/edit", array()); + } + public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null) { if (isset($A_getParams["query"])) { From 8871d9bb21df89a18da89f347b16f3de7e452fe4 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:09:53 +0100 Subject: [PATCH 4/6] modify structure sent to recipe/edit to include POST_URI --- Controllers/RecipeController.php | 10 +++++----- Views/recipe/edit.php | 29 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index 70f0cdc..51962c3 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -35,21 +35,21 @@ final class RecipeController } $O_recipeModel = new RecipeModel(); - $A_returnArray = $O_recipeModel->getFullRecipe($A_urlParams[0]); - if ($A_returnArray === null) { + $A_recipe = $O_recipeModel->getFullRecipe($A_urlParams[0]); + if ($A_recipe === null) { throw new HTTPSpecialCaseException(404); } - if ($A_returnArray["AUTHOR_ID"] !== $_SESSION["ID"]) { + if ($A_recipe["AUTHOR_ID"] !== $_SESSION["ID"]) { throw new HTTPSpecialCaseException(400, "You are not the owner of this recipe"); } - View::show("recipe/edit", $A_returnArray); + View::show("recipe/edit", array("POST_URI" => "/recipe/update", "RECIPE" => $A_recipe)); } public function newAction(Array $A_urlParams = null, Array $A_postParams = null) { - View::show("recipe/edit", array()); + View::show("recipe/edit", array("POST_URI" => "/recipe/create", "RECIPE" => array())); } public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null) diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php index dabc63b..452122c 100644 --- a/Views/recipe/edit.php +++ b/Views/recipe/edit.php @@ -1,4 +1,7 @@ -
+ " method="post"> - " required> + " required>

- +

Informations alimentaires

Type de plat : - > + > - > + > - > + >
- " required> + " required>
@@ -59,7 +62,7 @@ function getOrEmpty($A_Dict, $S_keyName) {