fixed non shown category
This commit is contained in:
		
							parent
							
								
									c0a0246e5b
								
							
						
					
					
						commit
						ee57bf0711
					
				| @ -9,12 +9,14 @@ final class CategoryController | ||||
|         $A_vegan = ParticularityModel::getByName("végan")->getRecipes(); | ||||
|         $A_gluten = ParticularityModel::getByName("sans gluten")->getRecipes(); | ||||
|         $A_lactose = ParticularityModel::getByName("sans lactose")->getRecipes(); | ||||
|         $A_recipes = RecipeModel::getUncategorizedRecipes(); | ||||
|          | ||||
|         $A_array_categories = array( | ||||
|             "Végan" => $A_vegan, | ||||
|             "Végétarien" => $A_vegeta, | ||||
|             "Sans gluten" => $A_gluten, | ||||
|             "Sans lactose" => $A_lactose | ||||
|             "Sans lactose" => $A_lactose, | ||||
|             "Non Catégorisé" => $A_recipes | ||||
|         ); | ||||
| 
 | ||||
|         View::show("category/view", $A_array_categories); | ||||
|  | ||||
| @ -71,6 +71,26 @@ final class RecipeController | ||||
|         $O_recipe->S_INSTRUCTIONS = substr($S_instructions, 2); | ||||
|     } | ||||
| 
 | ||||
|     private function handleParticularities($O_recipe, $A_postParams){ | ||||
|         // handle particularities
 | ||||
|         if(isset($A_postParams["part_Vegan"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "végan"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["part_Vegeta"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "végétarien"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["part_LactoseFree"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "sans lactose"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["part_GlutenFree"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "sans gluten"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public function createAction(Array $A_urlParams = null, Array $A_postParams = null) | ||||
|     { | ||||
|         Session::login_or_die(); | ||||
| @ -91,26 +111,8 @@ final class RecipeController | ||||
|         $A_ingredientNames = Utils::getOrDie($A_postParams, "recipeIngredientNames"); | ||||
|         $A_ingredientQuantities = Utils::getOrDie($A_postParams, "recipeIngredientQuantities"); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         // handle particularities
 | ||||
|         if(isset($A_postParams["recipeVegan"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "végan"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["recipeVegetarian"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "végétarien"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["recipeLactoseFree"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "sans lactose"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["recipeGlutenFree"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "sans gluten"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
| 
 | ||||
|         self::handleParticularities($O_recipe, $A_postParams); | ||||
| 
 | ||||
|         $A_ingredients = array(); | ||||
|         for($i=0; $i<count($A_ingredientNames); $i++) { | ||||
| @ -149,23 +151,7 @@ final class RecipeController | ||||
|         ParticularityModel::removeByRecipe($O_recipe->I_ID); | ||||
| 
 | ||||
|         // handle particularities
 | ||||
|         if(isset($A_postParams["part_Vegan"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "végan"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["part_Vegeta"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "végétarien"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["part_LactoseFree"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "sans lactose"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|         if(isset($A_postParams["part_GlutenFree"])){ | ||||
|             $O_part = new ParticularityModel($O_recipe->I_ID, "sans gluten"); | ||||
|             $O_part->insert(); | ||||
|         } | ||||
|          | ||||
|         self::handleParticularities($O_recipe, $A_postParams); | ||||
|          | ||||
|         // update img if necessary
 | ||||
|         $fp = Utils::tryProcessImg("recipeImage"); | ||||
|  | ||||
| @ -210,6 +210,19 @@ final class RecipeModel | ||||
|         return $A_recipes; | ||||
|     } | ||||
| 
 | ||||
|     public static function getUncategorizedRecipes(){ | ||||
|         $O_model = Model::get(); | ||||
|         $stmt = $O_model->prepare("SELECT * FROM RECIPE WHERE ID NOT IN (SELECT RECIPE_ID FROM RECIPE_PARTICULARITY)"); | ||||
|         $stmt->execute(); | ||||
|          | ||||
|         $A_recipes = array(); | ||||
|         foreach($stmt->fetchAll() as $row){ | ||||
|             array_push($A_recipes, self::createFromRow($row, $row["ID"])); | ||||
|         } | ||||
| 
 | ||||
|         return $A_recipes; | ||||
|     } | ||||
| 
 | ||||
|     public static function getRandomRecipes($I_n) | ||||
|     { | ||||
|         $O_model = Model::get(); | ||||
|  | ||||
| @ -3,7 +3,8 @@ $allCategory = array( | ||||
|     "Végan" => "vegan", | ||||
|     "Végétarien" => "vegetarian", | ||||
|     "Sans gluten" => "glutenLess", | ||||
|     "Sans lactose" => "lactoseLess"); | ||||
|     "Sans lactose" => "lactoseLess", | ||||
|     "Non Catégorisé" => "uncategorized"); | ||||
| ?>
 | ||||
| 
 | ||||
| <main class="hasAside"> | ||||
|  | ||||
| @ -1,9 +1,10 @@ | ||||
| <?php | ||||
| $allCategory = array( | ||||
|     "Végan" => "vegan", | ||||
|     "Végetarien" => "vegetarian", | ||||
|     "Végetérien" => "vegetarian", | ||||
|     "Sans gluten" => "glutenLess", | ||||
|     "Sans lactose" => "lactoseLess"); | ||||
|     "Sans lactose" => "lactoseLess", | ||||
|     "Non Catégorisé" => "uncategorized"); | ||||
| ?>
 | ||||
| 
 | ||||
| <aside> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user