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) { diff --git a/Views/recipe/edit.php b/Views/recipe/edit.php index a2dd8f9..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 351b93d..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 "
    1. ".$S_instr."
    2. "; ?>