From d6cf92b7dad02aee07e6547033558159bedd9cd3 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Thu, 26 Jan 2023 22:34:13 +0100 Subject: [PATCH] rename 'recipe' to 'instructions' --- Controllers/RecipeController.php | 6 +++--- Models/RecipeModel.php | 18 +++++++++--------- Views/recipe/edit.php | 10 +++++----- Views/recipe/view.php | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index 521e1b7..ca88f03 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -65,13 +65,13 @@ final class RecipeController $O_recipe->I_DIFFICULTY_ID = $O_difficulty->I_ID; $O_recipe->I_AUTHOR_ID = $_SESSION["ID"]; - $S_recipe = ""; + $S_instructions = ""; $i = 0; foreach(Utils::getOrDie($A_postParams, "recipeInstructions") as $S_instr) { - $S_recipe.= "\n\n".$S_instr; + $S_instructions.= "\n\n".$S_instr; $i++; } - $O_recipe->S_RECIPE = substr($S_recipe, 2); + $O_recipe->S_INSTRUCTIONS = substr($S_instructions, 2); } public function createAction(Array $A_urlParams = null, Array $A_postParams = null) diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php index 80aa718..9cb3d86 100644 --- a/Models/RecipeModel.php +++ b/Models/RecipeModel.php @@ -6,7 +6,7 @@ final class RecipeModel public $S_NAME = null; public $I_TIME = null; public $S_DESCR = null; - public $S_RECIPE = null; + public $S_INSTRUCTIONS = null; public $I_DIFFICULTY_ID = null; public $I_AUTHOR_ID = null; @@ -22,13 +22,13 @@ final class RecipeModel return new RecipeModel(); } - public static function createFull($S_NAME, $I_TIME, $S_DESCR, $S_RECIPE, $I_DIFFICULTY_ID, $I_AUTHOR_ID) + public static function createFull($S_NAME, $I_TIME, $S_DESCR, $S_INSTRUCTIONS, $I_DIFFICULTY_ID, $I_AUTHOR_ID) { $O_recipe = new RecipeModel(); $O_recipe->S_NAME = $S_NAME; $O_recipe->I_TIME = $I_TIME; $O_recipe->S_DESCR = $S_DESCR; - $O_recipe->S_RECIPE = $S_RECIPE; + $O_recipe->S_INSTRUCTIONS = $S_INSTRUCTIONS; $O_recipe->I_DIFFICULTY_ID = $I_DIFFICULTY_ID; $O_recipe->I_AUTHOR_ID = $I_AUTHOR_ID; return $O_recipe; @@ -37,11 +37,11 @@ final class RecipeModel public function insert() { $O_model = Model::get(); - $stmt = $O_model->prepare("INSERT INTO RECIPE (NAME, TIME, DESCR, RECIPE ,DIFFICULTY_ID, AUTHOR_ID) VALUES(:name, :time, :descr, :recipe, :difficulty_id, :author_id)"); + $stmt = $O_model->prepare("INSERT INTO RECIPE (NAME, TIME, DESCR, INSTRUCTIONS ,DIFFICULTY_ID, AUTHOR_ID) VALUES(:name, :time, :descr, :instructions, :difficulty_id, :author_id)"); $stmt->bindParam("name", $this->S_NAME); $stmt->bindParam("time", $this->I_TIME); $stmt->bindParam("descr", $this->S_DESCR); - $stmt->bindParam("recipe", $this->S_RECIPE); + $stmt->bindParam("instructions", $this->S_INSTRUCTIONS); $stmt->bindParam("difficulty_id", $this->I_DIFFICULTY_ID); $stmt->bindParam("author_id", $this->I_AUTHOR_ID); $stmt->execute(); @@ -51,12 +51,12 @@ final class RecipeModel public function update() { $O_model = Model::get(); - $stmt = $O_model->prepare("UPDATE RECIPE SET NAME=:name, TIME=:time, DESCR=:descr, RECIPE=:recipe, DIFFICULTY_ID=:difficulty_id, AUTHOR_ID=:author_id WHERE ID=:id"); + $stmt = $O_model->prepare("UPDATE RECIPE SET NAME=:name, TIME=:time, DESCR=:descr, INSTRUCTIONS=:instructions, DIFFICULTY_ID=:difficulty_id, AUTHOR_ID=:author_id WHERE ID=:id"); $stmt->bindParam("id", $this->I_ID); $stmt->bindParam("name", $this->S_NAME); $stmt->bindParam("time", $this->I_TIME); $stmt->bindParam("descr", $this->S_DESCR); - $stmt->bindParam("recipe", $this->S_RECIPE); + $stmt->bindParam("instructions", $this->S_INSTRUCTIONS); $stmt->bindParam("difficulty_id", $this->I_DIFFICULTY_ID); $stmt->bindParam("author_id", $this->I_AUTHOR_ID); $stmt->execute(); @@ -166,8 +166,8 @@ final class RecipeModel return $this->A_APPRS; } - public function getSteps(){ - return explode("\n\n", str_replace("\r", "", $this->S_RECIPE)); + public function getSplitInstructions(){ + return explode("\n\n", str_replace("\r", "", $this->S_INSTRUCTIONS)); } //TODO: return array object diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php index 7cc025e..6e2dccf 100644 --- a/Views/recipe/edit.php +++ b/Views/recipe/edit.php @@ -5,7 +5,7 @@ if ($O_recipe === null) { $S_name = null; $I_time = null; $S_descr = null; - $A_steps = array(); + $A_instructions = array(); $S_difficultyName = null; $A_parts = array(); $A_ingredients = array(); @@ -13,7 +13,7 @@ if ($O_recipe === null) { $S_name = $O_recipe->S_NAME; $I_time = $O_recipe->I_TIME; $S_descr = $O_recipe->S_DESCR; - $A_steps = $O_recipe->getSteps(); + $A_instructions = $O_recipe->getSplitInstructions(); $S_difficultyName = $O_recipe->getDifficulty()->S_NAME; $A_parts = array(); // TODO $A_ingredients = $O_recipe->getIngredients(); @@ -110,7 +110,7 @@ if ($O_recipe === null) {
    @@ -120,10 +120,10 @@ if ($O_recipe === null) { $numberOfInstructions = 1; } else { $i = 1; - foreach($A_steps as $S_step) { + foreach($A_instructions as $S_instr) { echo '
  1. - +
  2. '; $i++; } diff --git a/Views/recipe/view.php b/Views/recipe/view.php index 1d2571a..29b6981 100644 --- a/Views/recipe/view.php +++ b/Views/recipe/view.php @@ -29,7 +29,7 @@ $O_recipe = $A_view["RECIPE"];

    Préparation

      getSteps() as $S_instr) + foreach($O_recipe->getSplitInstructions() as $S_instr) echo "
    1. ".$S_instr."
    2. "; ?>