} elseif (isset($_GET['idecrivain'])) { // require all links in menu $periode_m = new PeriodeManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $menu = $periode_m->recupTous(); // récupération de l'écrivain en question $id = (int) $_GET['idecrivain']; $ecrivain_a_m = new EcrivainAdminManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $ecrivain = $ecrivain_a_m->recupJointure($id); $ids = explode('||', $ecrivain['ids']); $titres = explode('||', $ecrivain['titres']); $descriptions = explode('||', $ecrivain['descriptions']); include 'view/ecrivain.php'; } elseif (isset($_GET['idlivre'])) { // require all links in menu $periode_m = new PeriodeManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $menu = $periode_m->recupTous(); // récupération du livre $id = (int) $_GET['idlivre']; $livre_m = new LivreManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $livre = $livre_m->recupUn($id); include 'view/livre.php'; } else { // accueil // require all links in menu $periode_m = new PeriodeManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $menu = $periode_m->recupTous(); // random writer $ecrivain_m = new EcrivainManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $ecrivain_random = $ecrivain_m->recupUnRandom(); include 'view/accueil.php'; }
<?php // Contrôleur de l'affichage hors connexion // dependencies require 'model/MaPDOClass.php'; require 'model/Periode.php'; require 'model/Livre.php'; require 'model/Ecrivain.php'; // managers require 'model/PeriodeManager.php'; require 'model/LivreManager.php'; require 'model/EcrivainManager.php'; $periode_m = new PeriodeManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $ecrivain_m = new EcrivainManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $livre_m = new LivreManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $obj = $periode_m->recupUn(1); var_dump($obj); $obj = $ecrivain_m->recupUn(1); var_dump($obj); $obj = $livre_m->recupUn(1); var_dump($obj); header('Content-Type: text/html; charset=utf-8');
<?php require 'model/maPDOClass.php'; require 'Model/UserClass.php'; require 'Model/UserManagerClass.php'; require 'model/Ecrivain.php'; require 'model/EcrivainManager.php'; require 'model/Periode.php'; require 'model/PeriodeManager.php'; require 'model/Livre.php'; require 'model/LivreManager.php'; $menu = new PeriodeManager(DB_SELECT, DB_USER, DB_PWD, true); $bonjour = new UserManagerClass(DB_SELECT, DB_USER, DB_PWD, true); $salut = $bonjour->recupUser(); $recup_menu = $menu->recupTousPeriode(); $auteur = new EcrivainManager(DB_SELECT, DB_USER, DB_PWD, true); $hasardecrivain = $auteur->hasardEcrivain(); $epoque = new PeriodeManager(DB_SELECT, DB_USER, DB_PWD, true); $recup_periode = $menu->recupTousPeriode(); $bouquin = new LivreManager(DB_SELECT, DB_USER, DB_PWD, true); if (isset($_GET['idperiode'])) { $periode = $_GET['idperiode']; $ere = $epoque->recupUnPeriode($periode); require_once 'view/PeriodeVue.php'; } if (isset($_GET['idecrivain'])) { $numauteur = $_GET['idecrivain']; $recupauteur = $auteur->detailEcrivain($numauteur); require_once 'view/EcrivainVue.php'; } if (isset($_GET['idlivre'])) {
require 'Model/UserClass.php'; require 'Model/UserManagerClass.php'; require 'model/Ecrivain.php'; require 'model/EcrivainManager.php'; require 'model/EcrivainAdminManager.php'; require 'model/Periode.php'; require 'model/PeriodeManager.php'; require 'model/Livre.php'; require 'model/LivreManager.php'; require 'model/LivreAdminManager.php'; $manager = new EcrivainAdminManager(DB_SELECT, DB_USER, DB_PWD, true); $menu = new PeriodeManager(DB_SELECT, DB_USER, DB_PWD, true); $bonjour = new UserManagerClass(DB_SELECT, DB_USER, DB_PWD, true); $salut = $bonjour->recupUser(); $recup_menu = $menu->recupTousPeriode(); $auteur = new EcrivainManager(DB_SELECT, DB_USER, DB_PWD, true); $hasardecrivain = $auteur->hasardEcrivain(); $epoque = new PeriodeManager(DB_SELECT, DB_USER, DB_PWD, true); $bouquin = new LivreManager(DB_SELECT, DB_USER, DB_PWD, true); if (isset($_GET['idperiode'])) { $periode = $_GET['idperiode']; $ere = $epoque->recupUnPeriode($periode); require_once 'view/PeriodeVue.php'; } if (isset($_GET['idecrivain'])) { $numauteur = $_GET['idecrivain']; $recupauteur = $manager->detailEcrivain($numauteur); require_once 'view/EcrivainVue.php'; } if (isset($_GET['idlivre'])) { $id = $_GET['idlivre'];
// affichage de la liste $ecrivain_m = new EcrivainAdminManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $ecrivains = $ecrivain_m->recupTous(); $livre_m = new LivreManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $livres = $livre_m->recupTous(); include 'view/manage.php'; } else { // treat add writer and add book if (isset($_POST['submitajouterecrivain'])) { $lenom = htmlentities(strip_tags($_POST['lenom']), ENT_QUOTES, "UTF-8"); $labio = htmlentities(strip_tags($_POST['labio']), ENT_QUOTES, "UTF-8"); $siecle = (int) htmlentities(strip_tags($_POST['siecle']), ENT_QUOTES, "UTF-8"); // traitement ajout écrivain $ecrivain_a_m = new EcrivainAdminManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $ecrivain_a_m->insertWriter($lenom, $labio, $siecle); } elseif (isset($_POST['submitajouterlivre'])) { $letitre = htmlentities(strip_tags($_POST['letitre']), ENT_QUOTES, "UTF-8"); $ladescription = htmlentities(strip_tags($_POST['ladescription']), ENT_QUOTES, "UTF-8"); $lasortie = htmlentities(strip_tags($_POST['lasortie']), ENT_QUOTES, "UTF-8"); $lecrivain = (int) htmlentities(strip_tags($_POST['lecrivain']), ENT_QUOTES, "UTF-8"); // traitement ajout livres $livre_a_m = new LivreAdminManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $livre_a_m->insertBook($letitre, $ladescription, $lasortie, $lecrivain); } // to show form select fields $periode_m = new PeriodeManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $siecles = $periode_m->recupTous(); $ecrivain_m = new EcrivainManager(MaPDO::getConnection(DB_SELECT, DB_USER, DB_PWD, TRUE)); $ecrivains = $ecrivain_m->recupTous(); include 'view/admin.php'; }