/** * Fonction qui récupère des agruments et lance une requête SQL * permet d'afficher les produits * @param $recept * @param $name */ function testarg($recept, $name) { require_once '../../control/gestion/Secure.php'; include_once '../../model/front/ReqFront.php'; $idprod = Secure::bdd($recept); $namcat = Secure::bdd($name); if (is_numeric($idprod)) { $aff = new ReqFront(); $aff->presenterProds($idprod, $namcat); } else { echo "Requete non conforme -> vérifier le type de l'id."; } }
/** * Fonction récursive qui affiche les catégories en arborescence. * (arborescence récursive) * @param $parent * @param $niveau * @param $array * @return string */ private static function afficher($parent, $niveau, $array) { $html = ""; $niveau_precedent = 0; if (!$niveau && !$niveau_precedent) { $html .= "\n<ul id='main-menu' class='sm sm-clean'>\n"; } foreach ($array as $noeud) { if ($parent == $noeud['par_id'] and $noeud['liste'] == 0) { if ($niveau_precedent < $niveau) { $html .= "\n<ul>\n"; } $html .= "<li><a href=''>" . $noeud['nom_cat'] . "</a>"; $niveau_precedent = $niveau; $html .= ReqFront::afficher($noeud['cat_id'], $niveau + 1, $array); } // fin if if ($parent == $noeud['par_id'] and $noeud['liste'] == 1) { if ($niveau_precedent < $niveau) { $html .= "\n<ul>\n"; } $html .= "<li><a href='../../control/front/affprod.php?categorie=" . $noeud['cat_id'] . "&name=" . $noeud['nom_cat'] . "'>" . $noeud['nom_cat'] . "</a>"; $niveau_precedent = $niveau; $html .= ReqFront::afficher($noeud['cat_id'], $niveau + 1, $array); } // fin if } // fin foreach if ($niveau_precedent == $niveau && $niveau_precedent != 0) { $html .= "</ul>\n</li>\n"; } else { if ($niveau_precedent == $niveau) { $html .= "</ul>\n"; } else { $html .= "</li>\n"; } } return $html; }
<?php /** * Created by Nicolas DUPUIS. * ---- LPSIL 2015-2016 ---- * Date: 06/01/16 * Time: 13:07 */ $aff = new ReqFront(); ?> <!DOCTYPE> <html> <head lang="en"> <meta charset="UTF-8"> <!-- <link rel="stylesheet" href="../../lib/jquery-ui/jquery-ui.min.css"> --> <!-- <link rel="stylesheet" href="../../lib/jquery-ui/jquery-ui.theme.min.css"> --> <link href="../../lib/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="../../lib/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <script src="../../lib/jquery/jquery-2.1.4.min.js"></script> <!-- <script src="../../lib/jquery-ui/jquery-ui.min.js"></script> --> <script src="../../lib/bootstrap/js/bootstrap.min.js"></script> <!-- SmartMenus jQuery plugin --> <script src="../../lib/smartmenus/jquery.smartmenus.min.js" type="text/javascript"></script> <!-- SmartMenus core CSS (required) -->