From e4a3c9665a68c0fab1cfeabd44959eac668a98d7 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Thu, 26 Jan 2023 12:01:08 +0100 Subject: [PATCH] make category view use model --- Controllers/CategoryController.php | 33 ++++++------------------------ Views/category/view.php | 9 ++++---- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/Controllers/CategoryController.php b/Controllers/CategoryController.php index 85205df..a6af7d7 100644 --- a/Controllers/CategoryController.php +++ b/Controllers/CategoryController.php @@ -5,34 +5,13 @@ final class CategoryController public function defaultAction(Array $A_urlParams = null, Array $A_postParams = null) { - $A_array_recipes_Type_de_cuisson = array( //test - array( - "RECIPE_LINK" => "/recipe/view/2", - "IMG_LINK" => "/static/img/recipes/2.jpg", - "NAME" => "Croissant", - "NOTE" => "4.5" - ), - array( - "RECIPE_LINK" => "/recipe/view/2", - "IMG_LINK" => "/static/img/recipes/2.jpg", - "NAME" => "Croissant", - "NOTE" => "4.5" - ), - array( - "RECIPE_LINK" => "/recipe/view/2", - "IMG_LINK" => "/static/img/recipes/2.jpg", - "NAME" => "Croissant", - "NOTE" => "4.5" - ) - ); - + $A_recipes = RecipeModel::getRandomRecipes(3); + + // TODO actually fill out by particularity instead $A_array_categories = array( - "Type de cuisson" => $A_array_recipes_Type_de_cuisson, - "Temps de préparation" => $A_array_recipes_Type_de_cuisson, - "Difficulté" => $A_array_recipes_Type_de_cuisson, - "Végan" => $A_array_recipes_Type_de_cuisson, - "Sans gluten" => $A_array_recipes_Type_de_cuisson, - "Sans lactose" => $A_array_recipes_Type_de_cuisson + "Végan" => $A_recipes, + "Sans gluten" => $A_recipes, + "Sans lactose" => $A_recipes ); View::show("category/view", $A_array_categories); diff --git a/Views/category/view.php b/Views/category/view.php index 7ab8720..fb74aa6 100644 --- a/Views/category/view.php +++ b/Views/category/view.php @@ -5,20 +5,21 @@ $allCategory = array( "Difficulté" => "difficulte", "Végan" => "vegan", "Sans gluten" => "sans_gluten", - "Sans lactose" => "sans_lactose"); + "Sans lactose" => "sans_lactose" +); ?>
$recipes) { + foreach ($A_view as $categoryName => $A_recipes) { echo '

'.$categoryName.'

    '; - foreach ($recipes as $recipe) { + foreach ($A_recipes as $O_recipe) { echo '
  • '; - View::show("common/recipe", $recipe); + View::show("common/recipe", array("RECIPE" => $O_recipe)); echo '
  • '; } echo '