Merge pull request #132 from ThomasRubini/getsteps
This commit is contained in:
commit
e3d10e924d
@ -147,6 +147,10 @@ final class RecipeModel
|
|||||||
return $this->A_APPRS;
|
return $this->A_APPRS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSteps(){
|
||||||
|
return explode("\n\n", str_replace("\r", "", $this->S_RECIPE));
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: return array object
|
//TODO: return array object
|
||||||
public static function searchRecipesByName($S_query)
|
public static function searchRecipesByName($S_query)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ if ($O_recipe === null) {
|
|||||||
$S_name = null;
|
$S_name = null;
|
||||||
$I_time = null;
|
$I_time = null;
|
||||||
$S_descr = null;
|
$S_descr = null;
|
||||||
$S_recipe = null;
|
$A_steps = array();
|
||||||
$S_difficultyName = null;
|
$S_difficultyName = null;
|
||||||
$A_parts = array();
|
$A_parts = array();
|
||||||
$A_ingredients = array();
|
$A_ingredients = array();
|
||||||
@ -13,7 +13,7 @@ if ($O_recipe === null) {
|
|||||||
$S_name = $O_recipe->S_NAME;
|
$S_name = $O_recipe->S_NAME;
|
||||||
$I_time = $O_recipe->I_TIME;
|
$I_time = $O_recipe->I_TIME;
|
||||||
$S_descr = $O_recipe->S_DESCR;
|
$S_descr = $O_recipe->S_DESCR;
|
||||||
$S_recipe = $O_recipe->S_RECIPE;
|
$A_steps = $O_recipe->getSteps();
|
||||||
$S_difficultyName = $O_recipe->getDifficulty()->S_NAME;
|
$S_difficultyName = $O_recipe->getDifficulty()->S_NAME;
|
||||||
$A_parts = array(); // TODO
|
$A_parts = array(); // TODO
|
||||||
$A_ingredients = $O_recipe->getIngredients();
|
$A_ingredients = $O_recipe->getIngredients();
|
||||||
@ -109,28 +109,25 @@ if ($O_recipe === null) {
|
|||||||
|
|
||||||
<ol class="recipeInstructions">
|
<ol class="recipeInstructions">
|
||||||
<?php
|
<?php
|
||||||
if(!empty($S_recipe)) {
|
if (count($A_steps) === 0) {
|
||||||
$steps = explode("\n", $S_recipe);
|
echo '<li>
|
||||||
$i = 1;
|
<label for="recipeInstruction1">Étape 1 :</label>
|
||||||
foreach($steps as $step) {
|
<input type="text" name="recipeInstruction1" id="recipeInstruction1" placeholder="Battre les oeufs et la farine dans un grand saladier.">
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<button type="button" disabled="disabled" id="recipeButtonInstructionLess">-</button>';
|
||||||
|
$numberOfInstructions = 1;
|
||||||
|
} else {
|
||||||
|
foreach($A_steps as $S_step) {
|
||||||
echo '<li>
|
echo '<li>
|
||||||
<label for="recipeInstruction'.$i.'">Étape '.$i.' :</label>
|
<label for="recipeInstruction'.$i.'">Étape '.$i.' :</label>
|
||||||
<input type="text" name="recipeInstruction'.$i.'" id="recipeInstruction'.$i.'" placeholder="Battre les oeufs et la farine dans un grand saladier." value="'.$step.'">
|
<input type="text" name="recipeInstruction'.$i.'" id="recipeInstruction'.$i.'" placeholder="Battre les oeufs et la farine dans un grand saladier." value="'.$S_step.'">
|
||||||
</li>';
|
</li>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$numberOfInstructions = $i-1;
|
$numberOfInstructions = $i-1;
|
||||||
echo '</ol>
|
echo '</ol>
|
||||||
<button type="button" id="recipeButtonInstructionLess">-</button>';
|
<button type="button" id="recipeButtonInstructionLess">-</button>';
|
||||||
} else {
|
|
||||||
echo '<li>
|
|
||||||
<label for="recipeInstruction1">Étape 1 :</label>
|
|
||||||
<input type="text" name="recipeInstruction1" id="recipeInstruction1" placeholder="Battre les oeufs et la farine dans un grand saladier.">
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
<button type="button" disabled="disabled" id="recipeButtonInstructionLess">-</button>';
|
|
||||||
$numberOfIngredients = 1;
|
|
||||||
$numberOfInstructions = 1;
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<button type="button" id="recipeButtonInstructionPlus">+</button>
|
<button type="button" id="recipeButtonInstructionPlus">+</button>
|
||||||
|
@ -29,7 +29,7 @@ $O_recipe = $A_view["RECIPE"];
|
|||||||
<h2>Préparation</h2>
|
<h2>Préparation</h2>
|
||||||
<ol>
|
<ol>
|
||||||
<?php
|
<?php
|
||||||
foreach(explode("\n", $O_recipe->S_RECIPE) as $S_instr)
|
foreach($O_recipe->getSteps() as $S_instr)
|
||||||
echo "<li>".$S_instr."</li>";
|
echo "<li>".$S_instr."</li>";
|
||||||
?>
|
?>
|
||||||
</ol>
|
</ol>
|
||||||
|
Loading…
Reference in New Issue
Block a user