RecipeView.php 1.64 KB
Newer Older
ALGLAVE Ivan's avatar
ALGLAVE Ivan committed
1
2
3
4
5
6
7
8
<!-- HTML Fragment to display a recipe -->
<head>
    <link rel="stylesheet" type="text/css" href="css/RecipeView.css">
</head>

<body>

    <?php
9
        include "scripts/Functions.php";
ALGLAVE Ivan's avatar
ALGLAVE Ivan committed
10
11
12
13
14
15
16
17
        include "Donnees.inc.php";

        $id_recipe = $_GET['id_recipe'];
        $recipe = $Recettes[$id_recipe];

        $r_name = $recipe['titre'];
        $r_ingredients = $recipe['ingredients'];
        $r_recipe = $recipe['preparation'];
18

19
20
21
        $image_url = getRecipeImage($r_name);
        $image_url = '' . 'Photos/' . $image_url;
        if(!file_exists($image_url)) $image_url = 'images/missing.jfif';
ALGLAVE Ivan's avatar
ALGLAVE Ivan committed
22
23
24
    ?>

    <div>
25
        <img src=<?php echo "\"" . $image_url . "\"" ?> width="128" height="128"; ?>
ALGLAVE Ivan's avatar
ALGLAVE Ivan committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        <span>
            <h1>
                <?php echo $r_name; ?>
            </h1>
            <h2>Ingrédients :</h2>
            <ul>
                <?php
                    $ingredients = explode('|', $r_ingredients);
                    foreach($ingredients as $ing)
                    {
                        echo '<li>' . $ing . '</li>';
                    }
                ?>
            </ul>
            <h2>Préparation :</h2>
            <p>
                <?php echo $r_recipe ?>
            </p>
        </span>

    </div>

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    <script>
        
        document.addEventListener('keyup', function (e)
            {
                if(e.keyCode == 27)
                {
                    var data = {
                        event: 'keyup',
                        value: e.keyCode
                    };
                    window.top.postMessage(data, [data.event, data.value]);
                }
            });
    </script>

ALGLAVE Ivan's avatar
ALGLAVE Ivan committed
63
</body>