Skip to content
Snippets Groups Projects
Select Git revision
  • 3f51e9645eb61f7182c8425a976320366156eb72
  • master default protected
2 results

Hierarchy.php

Blame
  • Hierarchy.php 2.71 KiB
    <!DOCTYPE html>
    <html>
    <head>
        <title>Drinkpedia</title>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="css/Hierarchy.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
        <script type="text/javascript" src="scripts/DataQuery.js"></script>
    </head>
    
    <body id="body">
    
        <!-- PHP -->
    
        <?php
    
            // DEBUT DES ACTIONS SUR LA PAGE :
            include "scripts/Functions.php";
    
            if(!isset($_GET['element'])) {
                // Si on ouvre la Hiérachie pour la première fois, on part de 'Vin effervescent'
                $aliment = 'Aliment';
            } else {
                // Sinon on récupère l'aliment en cours 
                $aliment = $_GET['element'];
                $aliment = trim($aliment, '"');
            }
    
            $sup_cat = get_super_categories($aliment);
            $sous_cat = get_sous_categories($aliment);
            
            // Crée la disposition de la hiérarchie 
            
            echo '<div class="hierarchy_view">';
                // On affiche les Super-Catégories, s'il y'en a :
                if($sup_cat != null) { 
                    echo '<div class="category-view">';
                    echo '<h1> Super-catégories de '.$aliment.' </h1>';
                    if($sup_cat != null) foreach($sup_cat as $cat) { 
                        echo '<li><button onclick="notifyParent('."'".$cat."'".');">'.$cat.'</button></li>';
                    } 
                    echo '</div>';
                 } 
                 // On affiche les sous-catégories, s'il y'en a : 
                 if($sous_cat != null) { 
                    echo '<div class="category-view">';
                    echo '<h1> Sous-catégories de '.$aliment.' </h1>';
                    if($sous_cat != null) foreach($sous_cat as $cat) { 
                        echo '<li><button onclick="notifyParent('."'".$cat."'".');">'.$cat.'</button></li>';
                    } 
                    echo '</div>';
                 }
                 // TEST DE GETRECIPES 
                 /*$tabVide = [];
                 $recipes_with_aliment = getRecipes(get_all_aliments($aliment), $tabVide, 0, false, false);
                 echo '<div class="category-view">';
                 echo '<h1> Toutes les recettes contenant '.$aliment.' </h1>';
                 foreach($recipes_with_aliment as $recipe) {
                     echo '<li>'.$recipe['titre'].'</li>';
                 }*/
            echo '</div>';
        ?>
    
        <!-- JAVASCRIPT -->
    
        <script>
            
            function notifyParent($aliment) // Send a message to the parent window, asking to change to page $aliment
            {
                var data = {
                    event: 'hierarchyDisplay',
                    value: $aliment
                };
                window.top.postMessage(data, [data.event, data.value]);
            }
    
        </script>
    </body>
    </html>