From 7006ee6896b88a223e74cd614e93ac55f44f8bcb Mon Sep 17 00:00:00 2001
From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com>
Date: Thu, 26 Jan 2023 17:09:33 +0100
Subject: [PATCH 1/3] explode at \n\n instead of \n
---
Views/recipe/edit.php | 2 +-
Views/recipe/view.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php
index a2dd8f9..da1e5cc 100644
--- a/Views/recipe/edit.php
+++ b/Views/recipe/edit.php
@@ -110,7 +110,7 @@ if ($O_recipe === null) {
diff --git a/Views/recipe/view.php b/Views/recipe/view.php
index 351b93d..8e87bf3 100644
--- a/Views/recipe/view.php
+++ b/Views/recipe/view.php
@@ -29,7 +29,7 @@ $O_recipe = $A_view["RECIPE"];
Préparation
S_RECIPE) as $S_instr)
+ foreach(explode("\n\n", $O_recipe->S_RECIPE) as $S_instr)
echo "- ".$S_instr."
";
?>
From b664a38a669031af3b4d0d98c9054a0c50dac273 Mon Sep 17 00:00:00 2001
From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com>
Date: Thu, 26 Jan 2023 17:34:54 +0100
Subject: [PATCH 2/3] add method RecipeModel::getSteps()
---
Models/RecipeModel.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Models/RecipeModel.php b/Models/RecipeModel.php
index c4fad86..07c63e4 100644
--- a/Models/RecipeModel.php
+++ b/Models/RecipeModel.php
@@ -147,6 +147,10 @@ final class RecipeModel
return $this->A_APPRS;
}
+ public function getSteps(){
+ return explode("\n\n", str_replace("\r", "", $this->S_RECIPE));
+ }
+
//TODO: return array object
public static function searchRecipesByName($S_query)
{
From 272b4fae86b176acb26a96c01e94b474a7aa1dcb Mon Sep 17 00:00:00 2001
From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com>
Date: Thu, 26 Jan 2023 17:35:56 +0100
Subject: [PATCH 3/3] use getSteps() in frontend
---
Views/recipe/edit.php | 29 +++++++++++++----------------
Views/recipe/view.php | 2 +-
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php
index da1e5cc..8cb218d 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;
- $S_recipe = null;
+ $A_steps = 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;
- $S_recipe = $O_recipe->S_RECIPE;
+ $A_steps = $O_recipe->getSteps();
$S_difficultyName = $O_recipe->getDifficulty()->S_NAME;
$A_parts = array(); // TODO
$A_ingredients = $O_recipe->getIngredients();
@@ -109,28 +109,25 @@ if ($O_recipe === null) {
+
+
+
+
+ ';
+ $numberOfInstructions = 1;
+ } else {
+ foreach($A_steps as $S_step) {
echo '-
-
+
';
$i++;
}
$numberOfInstructions = $i-1;
echo '
';
- } else {
- echo '
-
-
-
-
- ';
- $numberOfIngredients = 1;
- $numberOfInstructions = 1;
}
?>
diff --git a/Views/recipe/view.php b/Views/recipe/view.php
index 8e87bf3..393c196 100644
--- a/Views/recipe/view.php
+++ b/Views/recipe/view.php
@@ -29,7 +29,7 @@ $O_recipe = $A_view["RECIPE"];
Préparation
S_RECIPE) as $S_instr)
+ foreach($O_recipe->getSteps() as $S_instr)
echo "- ".$S_instr."
";
?>