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)
|
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(
|
$A_array_categories = array(
|
||||||
"Végan" => $A_recipes,
|
"Végan" => $A_vegan,
|
||||||
"Sans gluten" => $A_recipes,
|
"Végétarien" => $A_vegeta,
|
||||||
"Sans lactose" => $A_recipes
|
"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);
|
View::show("category/view", $A_array_categories);
|
||||||
|
|||||||
@ -36,6 +36,30 @@ final class ParticularityModel
|
|||||||
$stmt->execute();
|
$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(){
|
public function delete(){
|
||||||
$O_model = Model::get();
|
$O_model = Model::get();
|
||||||
|
|||||||
@ -6,4 +6,4 @@ Découverte d'un MVC pas à pas avec PHP
|
|||||||
2 - Routage simple et Exceptions
|
2 - Routage simple et Exceptions
|
||||||
|
|
||||||
3 - Modèles et connexion BDD (coming soon...)
|
3 - Modèles et connexion BDD (coming soon...)
|
||||||
|
|
||||||
@ -1,12 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
$allCategory = array(
|
$allCategory = array(
|
||||||
"Type de cuisson" => "type_de_cuisson",
|
|
||||||
"Temps de préparation" => "temps_de_preparation",
|
|
||||||
"Difficulté" => "difficulte",
|
|
||||||
"Végan" => "vegan",
|
"Végan" => "vegan",
|
||||||
"Sans gluten" => "sans_gluten",
|
"Végétarien" => "vegetarian",
|
||||||
"Sans lactose" => "sans_lactose"
|
"Sans gluten" => "glutenLess",
|
||||||
);
|
"Sans lactose" => "lactoseLess");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<main class="hasAside">
|
<main class="hasAside">
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
$allCategory = array(
|
$allCategory = array(
|
||||||
"Type de cuisson" => "type_de_cuisson",
|
|
||||||
"Temps de préparation" => "temps_de_preparation",
|
|
||||||
"Difficulté" => "difficulte",
|
|
||||||
"Végan" => "vegan",
|
"Végan" => "vegan",
|
||||||
"Sans gluten" => "sans_gluten",
|
"Végetarien" => "vegetarian",
|
||||||
"Sans lactose" => "sans_lactose");
|
"Sans gluten" => "glutenLess",
|
||||||
|
"Sans lactose" => "lactoseLess");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<aside>
|
<aside>
|
||||||
@ -13,7 +11,7 @@ $allCategory = array(
|
|||||||
<li class="hasH3"><h3>Catégories :</h3></li>
|
<li class="hasH3"><h3>Catégories :</h3></li>
|
||||||
<?php
|
<?php
|
||||||
foreach($allCategory as $category => $category_path) {
|
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>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user