diff --git a/Home.php b/Home.php index 51fae8c05d4d49c1107c6cf1da8b8790806ec424..c7f3b8f4defd49d252747780a86311818f53acd1 100644 --- a/Home.php +++ b/Home.php @@ -12,7 +12,7 @@ <div class="topnav"> <button id="tabBtnI" class="active" value="Hierarchy.php" onclick="tabButtonClicked(this)">Hiérarchie</button> <button id="tabBtnA" value="AdvancedSearch.php" onclick="tabButtonClicked(this)">Avancé</button> - <button id="tabBtnC" value="Cocktails.php" onclick="tabButtonClicked(this)">Cocktails</button> + <button id="tabBtnR" value="Recipes.php" onclick="tabButtonClicked(this)">Recettes</button> <button id="tabBtnMA" class="right" value="MyAccount.php" onclick="tabButtonClicked(this)">Mon Compte</button> <button id="tabBtnF" class="right" value="MyFavouriteRecipes.php" onclick="tabButtonClicked(this)">Favoris</button> </div> @@ -52,6 +52,10 @@ { showRecipe(m_value); } + else if(m_event == 'hierarchyDisplay') + { + switchView('Hierarchy.php?element="' + m_value + '"'); + } } function hideRecipe() diff --git a/RecipeList.php b/RecipeList.php new file mode 100644 index 0000000000000000000000000000000000000000..eeafa9de04bfba0ab42fbd048309c312959c5962 --- /dev/null +++ b/RecipeList.php @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html> +<head> + <title>Drinkpedia</title> + <meta charset="UTF-8"> + <link rel="stylesheet" type="text/css" href="css/RecipeList.css"> +</head> + +<body> + + <ul> + + <?php + + include "Donnees.inc.php"; + + $recipesIds = explode('|', $_GET['ids']); + + foreach($recipesIds as $id) + { + echo '<li>'; + echo '<div>'; + + $recipe = $Recettes[(int)$id]; + echo $recipe['titre']; + + echo '</div>'; + echo '</li>'; + } + + ?> + + </ul> + +</body> + +</html> \ No newline at end of file diff --git a/css/RecipeList.css b/css/RecipeList.css new file mode 100644 index 0000000000000000000000000000000000000000..3fae952a6123b4cb7bad80a3ac44f17b5fc8b196 --- /dev/null +++ b/css/RecipeList.css @@ -0,0 +1,4 @@ +table, td, tr, th { + border-width: 1px; + border-color: 1px; +} \ No newline at end of file diff --git a/scripts/DataQuery.js b/scripts/DataQuery.js index 2fa11fd73049b3050a3b15b8eab9a57cb5b89d94..47f42c3bec7ba1d309cbd6f657f6c713bc3db02e 100644 --- a/scripts/DataQuery.js +++ b/scripts/DataQuery.js @@ -1,9 +1,23 @@ +var scripts_location = "scripts/DataQuery.php"; +var arg_name_func = "functionname"; +var arg_name_args = "arguments"; + +function query(func_name, args, callback) +{ + $.post(scripts_location, {arg_name_func: func_name, arg_name_args: args}, callback); +} + function getRecipes(wanted_ingredients = [], unwanted_ingredients = [], max_unsatisfied = 0, allow_missing = true, allow_unwanted = true, callback) { - $.post("scripts/DataQuery.php", {'functionname': 'getRecipe', 'arguments': [wanted_ingredients, unwanted_ingredients, max_unsatisfied, allow_missing, allow_unwanted]}, callback); + query('getRecipe', [wanted_ingredients, unwanted_ingredients, max_unsatisfied, allow_missing, allow_unwanted], callback); } function getIngredients(parent_category = 'Aliment', callback) { - $.post("scripts/DataQuery.php", {'functionname': 'getIngredients', 'arguments': [parent_category]}, callback); + query('getIngredients', [parent_category], callback); +} + +function getRecipeImage(id, callback) +{ + query('getRecipeImage', [id], callback); } \ No newline at end of file diff --git a/scripts/DataQuery.php b/scripts/DataQuery.php index fa0ba7a3763682018687e5fe437a3987242901c7..d7edbd3d1d2df9a1a896acfdd1684ab655d7067a 100644 --- a/scripts/DataQuery.php +++ b/scripts/DataQuery.php @@ -16,6 +16,10 @@ { echo getIngredients($_POST['arguments'][0]); } + else if($funcName == 'getRecipeImage') + { + echo getRecipeImage($_POST['arguments'][0]); + } else { echo 'error - unknown func'; diff --git a/scripts/Functions.php b/scripts/Functions.php index efde0974766fe66a2f1807d40d490b4d4a93fc7a..d6b59c26e72d8ffe4b6b58a4c63df6f13d240b2a 100644 --- a/scripts/Functions.php +++ b/scripts/Functions.php @@ -74,4 +74,16 @@ function getIngredients($parent_category) return $res; } +function getRecipeImage($id) +{ + include "../Donnees.inc.php"; + + $name = $Recettes[$id]; + + $formatted_name = implode('_', explode(' ', $name)) . '.jpg'; + + if(file_exists('../Photos/' . $formatted_name)) return $formatted_name; + else return ''; +} + ?> \ No newline at end of file