add recipe/create action
This commit is contained in:
parent
4e033bfe37
commit
cba3f90657
@ -47,10 +47,26 @@ final class RecipeController
|
|||||||
public function newAction(Array $A_urlParams = null, Array $A_postParams = null)
|
public function newAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||||
{
|
{
|
||||||
Session::login_or_die();
|
Session::login_or_die();
|
||||||
|
|
||||||
View::show("recipe/edit", array("POST_URI" => "/recipe/create", "RECIPE" => array()));
|
View::show("recipe/edit", array("POST_URI" => "/recipe/create", "RECIPE" => array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||||
|
{
|
||||||
|
Session::login_or_die();
|
||||||
|
|
||||||
|
$O_difficulty = DifficultyModel::getByName($A_postParams["recipeDifficulty"]);
|
||||||
|
if($O_difficulty === null){
|
||||||
|
throw new HTTPSpecialCaseException(400, "Invalid difficulty");
|
||||||
|
}
|
||||||
|
|
||||||
|
$O_recipe = new RecipeModel(
|
||||||
|
$A_postParams["recipeName"], $A_postParams["recipeTime"], $A_postParams["recipeDescription"],
|
||||||
|
null, $O_difficulty->I_ID, $_SESSION["ID"]
|
||||||
|
);
|
||||||
|
$O_recipe->insert();
|
||||||
|
}
|
||||||
|
|
||||||
public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
public function searchAction(Array $A_urlParams = null, Array $A_postParams = null, Array $A_getParams = null)
|
||||||
{
|
{
|
||||||
if (isset($A_getParams["query"])) {
|
if (isset($A_getParams["query"])) {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ function getOrEmpty($A_Dict, $S_keyName) {
|
|||||||
<h1>Informations alimentaires</h1>
|
<h1>Informations alimentaires</h1>
|
||||||
|
|
||||||
<label for="recipeFifficulte">Niveau de difficulé :</label>
|
<label for="recipeFifficulte">Niveau de difficulé :</label>
|
||||||
<select name="recipeDifficulte" id="recipeDifficulte" required>
|
<select name="recipeDifficulty" id="recipeDifficulte" required>
|
||||||
<option value="tresFacile" <?= getOrEmpty($A_recipe, "DIFFICULTY_NAME")=="Très facile"? 'selected="selected"' : "" ?> >Très facile</option>
|
<option value="tresFacile" <?= getOrEmpty($A_recipe, "DIFFICULTY_NAME")=="Très facile"? 'selected="selected"' : "" ?> >Très facile</option>
|
||||||
<option value="facile" <?= getOrEmpty($A_recipe, "DIFFICULTY_NAME")=="Facile"? 'selected="selected"' : "" ?>>Facile</option>
|
<option value="facile" <?= getOrEmpty($A_recipe, "DIFFICULTY_NAME")=="Facile"? 'selected="selected"' : "" ?>>Facile</option>
|
||||||
<option value="moyen" <?= getOrEmpty($A_recipe, "DIFFICULTY_NAME")=="Moyen"? 'selected="selected"' : "" ?>>Moyen</option>
|
<option value="moyen" <?= getOrEmpty($A_recipe, "DIFFICULTY_NAME")=="Moyen"? 'selected="selected"' : "" ?>>Moyen</option>
|
||||||
@ -39,12 +39,12 @@ function getOrEmpty($A_Dict, $S_keyName) {
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<legend>Type de plat :</legend>
|
<legend>Particularités du plat :</legend>
|
||||||
<input type="checkbox" name="recipeVegan" id="recipeVegan" <?= in_array("Végan", getOrEmpty($A_recipe, "TYPE"))? "checked":"" ?> >
|
<input type="checkbox" name="part_Vegan" id="recipeVegan" <?= in_array("Végan", getOrEmpty($A_recipe, "TYPE"))? "checked":"" ?> >
|
||||||
<label for="recipeVegan">Végan</label>
|
<label for="recipeVegan">Végan</label>
|
||||||
<input type="checkbox" name="recipeLactoseFree" id="recipeLactoseFree" <?= in_array("Sans lactose", getOrEmpty($A_recipe, "TYPE"))? "checked":"" ?> >
|
<input type="checkbox" name="part_LactoseFree" id="recipeLactoseFree" <?= in_array("Sans lactose", getOrEmpty($A_recipe, "TYPE"))? "checked":"" ?> >
|
||||||
<label for="recipeLactoseFree">Sans lactose</label>
|
<label for="recipeLactoseFree">Sans lactose</label>
|
||||||
<input type="checkbox" name="recipeGlutenFree" id="recipeGlutenFree" <?= in_array("Sans gluten", getOrEmpty($A_recipe, "TYPE"))? "checked":"" ?> >
|
<input type="checkbox" name="part_GlutenFree" id="recipeGlutenFree" <?= in_array("Sans gluten", getOrEmpty($A_recipe, "TYPE"))? "checked":"" ?> >
|
||||||
<label for="recipeGlutenFree">Sans gluten</label>
|
<label for="recipeGlutenFree">Sans gluten</label>
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user