categories
This commit is contained in:
parent
e3d10e924d
commit
069fca704e
@ -5,13 +5,58 @@ final class CategoryController
|
||||
|
||||
public function defaultAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
$A_recipes = RecipeModel::getRandomRecipes(3);
|
||||
$A_vegeta = ParticularityModel::getByName("végétarien")->getRecipes();
|
||||
$A_vegan = ParticularityModel::getByName("végan")->getRecipes();
|
||||
$A_gluten = ParticularityModel::getByName("sans gluten")->getRecipes();
|
||||
$A_lactose = ParticularityModel::getByName("sans lactose")->getRecipes();
|
||||
|
||||
// TODO actually fill out by particularity instead
|
||||
$A_array_categories = array(
|
||||
"Végan" => $A_recipes,
|
||||
"Sans gluten" => $A_recipes,
|
||||
"Sans lactose" => $A_recipes
|
||||
"Végan" => $A_vegan,
|
||||
"Végétarien" => $A_vegeta,
|
||||
"Sans gluten" => $A_gluten,
|
||||
"Sans lactose" => $A_lactose
|
||||
);
|
||||
|
||||
View::show("category/view", $A_array_categories);
|
||||
}
|
||||
|
||||
public function lactoseLessAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
$A_lactose = ParticularityModel::getByName("sans lactose")->getRecipes();
|
||||
|
||||
$A_array_categories = array(
|
||||
"Sans lactose" => $A_lactose
|
||||
);
|
||||
|
||||
View::show("category/view", $A_array_categories);
|
||||
}
|
||||
public function glutenLessAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
$A_gluten = ParticularityModel::getByName("sans gluten")->getRecipes();
|
||||
|
||||
$A_array_categories = array(
|
||||
"Sans gluten" => $A_gluten
|
||||
);
|
||||
|
||||
View::show("category/view", $A_array_categories);
|
||||
}
|
||||
public function veganAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
$A_vegan = ParticularityModel::getByName("végan")->getRecipes();
|
||||
|
||||
$A_array_categories = array(
|
||||
"Végan" => $A_vegan
|
||||
);
|
||||
|
||||
View::show("category/view", $A_array_categories);
|
||||
}
|
||||
|
||||
public function vegetarianAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||
{
|
||||
$A_vegeta = ParticularityModel::getByName("végétarien")->getRecipes();
|
||||
|
||||
$A_array_categories = array(
|
||||
"Végétarien" => $A_vegeta
|
||||
);
|
||||
|
||||
View::show("category/view", $A_array_categories);
|
||||
|
@ -36,6 +36,30 @@ final class ParticularityModel
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
public static function getByName($S_name){
|
||||
$O_model = Model::get();
|
||||
$stmt = $O_model->prepare("SELECT * FROM PARTICULARITY WHERE NAME=:name");
|
||||
$stmt->bindParam("name", $S_name);
|
||||
$stmt->execute();
|
||||
|
||||
$row = $stmt->fetch();
|
||||
if ($row === false) return null;
|
||||
|
||||
$O_part = new ParticularityModel($row["NAME"],null);
|
||||
$O_part->I_PARTICULARITY_ID = $row["ID"];
|
||||
return $O_part;
|
||||
}
|
||||
public function getRecipes(){
|
||||
$O_model = Model::get();
|
||||
$stmt = $O_model->prepare("SELECT RECIPE_ID FROM RECIPE_PARTICULARITY WHERE PARTICULARITY_ID=:id");
|
||||
$stmt->bindParam("id", $this->I_PARTICULARITY_ID);
|
||||
$stmt->execute();
|
||||
$A_recipes = array();
|
||||
foreach($stmt->fetchAll() as $row){
|
||||
array_push($A_recipes, RecipeModel::getByID($row["RECIPE_ID"]));
|
||||
}
|
||||
return $A_recipes;
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$O_model = Model::get();
|
||||
|
@ -6,4 +6,4 @@ Découverte d'un MVC pas à pas avec PHP
|
||||
2 - Routage simple et Exceptions
|
||||
|
||||
3 - Modèles et connexion BDD (coming soon...)
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
<?php
|
||||
$allCategory = array(
|
||||
"Type de cuisson" => "type_de_cuisson",
|
||||
"Temps de préparation" => "temps_de_preparation",
|
||||
"Difficulté" => "difficulte",
|
||||
"Végan" => "vegan",
|
||||
"Sans gluten" => "sans_gluten",
|
||||
"Sans lactose" => "sans_lactose"
|
||||
);
|
||||
"Végétarien" => "vegetarian",
|
||||
"Sans gluten" => "glutenLess",
|
||||
"Sans lactose" => "lactoseLess");
|
||||
?>
|
||||
|
||||
<main class="hasAside">
|
||||
|
@ -1,11 +1,9 @@
|
||||
<?php
|
||||
$allCategory = array(
|
||||
"Type de cuisson" => "type_de_cuisson",
|
||||
"Temps de préparation" => "temps_de_preparation",
|
||||
"Difficulté" => "difficulte",
|
||||
"Végan" => "vegan",
|
||||
"Sans gluten" => "sans_gluten",
|
||||
"Sans lactose" => "sans_lactose");
|
||||
"Végetarien" => "vegetarian",
|
||||
"Sans gluten" => "glutenLess",
|
||||
"Sans lactose" => "lactoseLess");
|
||||
?>
|
||||
|
||||
<aside>
|
||||
@ -13,7 +11,7 @@ $allCategory = array(
|
||||
<li class="hasH3"><h3>Catégories :</h3></li>
|
||||
<?php
|
||||
foreach($allCategory as $category => $category_path) {
|
||||
echo '<li><a href="/category#' . $category_path . '">'. $category . '</a></li>';
|
||||
echo '<li><a href="/category/' . $category_path . '">'. $category . '</a></li>';
|
||||
}?>
|
||||
</ul>
|
||||
</aside>
|
||||
|
Loading…
Reference in New Issue
Block a user