コード例 #1
0
 function __construct()
 {
     if (!isset(self::$database)) {
         //Connection à la BDD si pas déjà connecté
         self::$database = BaseDeDonnees::getInstance();
     }
 }
コード例 #2
0
ファイル: ajaxControler.php プロジェクト: MontreArt/origin
/**
* @brief Fonction qui affiche le 2e select de la barre de recherche mobile en fonction du choix de l'utilisateur
* @access public
* @author David Lachambre
* @return void
*/
function afficherSelectRechercheMobile()
{
    if (isset($_GET["typeRechercheMobile"]) && $_GET["typeRechercheMobile"] != "") {
        $nomServeur = $_SERVER["HTTP_HOST"];
        if ($_GET["typeRechercheMobile"] == "artiste") {
            echo '<input class="text" type="text" placeholder="Entrez le nom de l\'artiste" id="keywordMobile" name="inputArtisteMobile" onkeyup="autoCompleteMobile(\'artiste\', \'' . $nomServeur . '\')">';
            echo '<div id="resultsMobile"></div>';
        } else {
            if ($_GET["typeRechercheMobile"] == "titre") {
                echo '<input class="text" type="text" placeholder="Entrez le titre de l\'oeuvre" id="keywordMobile" name="inputOeuvreMobile" onkeyup="autoCompleteMobile(\'titre\', \'' . $nomServeur . '\')">';
                echo '<div id="resultsMobile"></div>';
            } else {
                if ($_GET["typeRechercheMobile"] == "arrondissement") {
                    echo '<select name="selectArrondissementMobile" class="selectArrondissementMobile">';
                    echo '<option value = "">Faites un choix</option>';
                    $nouvelArrondissement = new Arrondissement();
                    $arrondissements = $nouvelArrondissement->getAllArrondissements();
                    foreach ($arrondissements as $arrondissement) {
                        echo '<option value="' . $arrondissement["idArrondissement"] . '">' . $arrondissement["nomArrondissement"] . '</option>';
                    }
                    echo '</select>';
                } else {
                    if ($_GET["typeRechercheMobile"] == "categorie") {
                        $nouvelleCategorie = new Categorie();
                        if (isset($_COOKIE["langue"])) {
                            $langue = $_COOKIE["langue"];
                        } else {
                            $langue = "FR";
                        }
                        $categories = $nouvelleCategorie->getAllCategories($langue);
                        echo '<select name="selectCategorieMobile" class="selectCategorieMobile">';
                        echo '<option value = "">Faites un choix</option>';
                        foreach ($categories as $categorie) {
                            echo '<option value="' . $categorie["idCategorie"] . '">' . $categorie["nomCategorie{$langue}"] . '</option>';
                        }
                        echo '</select>';
                    }
                }
            }
        }
    }
}
コード例 #3
0
<h2>Test unitaire - ajout oeuvre BDD</h2>
<div id="contenu">
<?php 
$oeuvre = new Oeuvre();
$arrondissement = new Arrondissement();
$categorie = new Categorie();
$idOeuvre = "";
$arrondissementsBDD = $arrondissement->getAllArrondissements();
$categoriesBDD = $categorie->getAllCategories('FR');
if (isset($_GET["testajoutOeuvre"])) {
    if (!empty($_GET["titreAjout"]) && !empty($_GET["prenomArtisteAjout"]) && !empty($_GET["adresseAjout"]) && !empty($_GET["descriptionAjout"]) && !empty($_GET["nomArtisteAjout"]) && !empty($_GET["selectArrondissement"]) && !empty($_GET["selectCategorie"])) {
        $oeuvre->ajouterOeuvrePourTest($_GET['titreAjout'], $_GET['adresseAjout'], $_GET['prenomArtisteAjout'], $_GET['nomArtisteAjout'], $_GET['descriptionAjout'], $_GET["selectCategorie"], $_GET["selectArrondissement"], true, 'FR');
        $idOeuvre = $oeuvre->getIdOeuvreByTitreandAdresse($_GET['titreAjout'], $_GET['adresseAjout']);
        //aller chercher id oeuvre insérée
    } else {
        echo "ne laissez rien en blanc";
    }
}
?>
   
    
    <form method="get" name="formTestsuppOeuvre" enctype="multipart/form-data">                
                <input type='text' name='titreAjout' value="" placeholder="Titre de l'oeuvre (si connu)"/>  
                <input type='text' name='prenomArtisteAjout' value="" placeholder="Prénom de l'artiste (si connu)"/>
                <input type='text' name='nomArtisteAjout' value="" placeholder="Nom de l'artiste (si connu)"/>
                <input type='text' name='adresseAjout' value="" placeholder="Adresse (obligatoire)"/>   
                <textarea name='descriptionAjout' placeholder="Description (obligatoire)"></textarea>
                <select name="selectArrondissement">
                    <option value="">Choisir un arrondissement</option>
                    <?php 
foreach ($arrondissementsBDD as $arrondissement) {
コード例 #4
0
ファイル: Oeuvre.class.php プロジェクト: cmahneke/origin
 /**
  * @brief Méthode qui récupère les foreign key associées à l'oeuvre à insérer / updater.
  * @param array $oeuvre
  * @access private
  * @return void
  */
 private function getFKOeuvreByName($oeuvre)
 {
     //Catégories
     $categorie = new Categorie();
     $idCategorie = false;
     if (isset($oeuvre["SousCategorieObjet"])) {
         $idCategorie = $categorie->getCategorieIdByName($oeuvre["SousCategorieObjet"]);
         //Récupère l'ID en fonction des noms passés en paramètres
     } else {
         if (isset($oeuvre["SousCategorieObjetAng"])) {
             $idCategorie = $categorie->getCategorieIdByName($oeuvre["SousCategorieObjetAng"]);
             //Récupère l'ID en fonction des noms passés en paramètres
         }
     }
     if (!$idCategorie) {
         //Si la catégorie n'existe pas...
         $categorie->ajouterCategorie($oeuvre["SousCategorieObjet"], $oeuvre["SousCategorieObjetAng"]);
         //Fait l'insertion si non trouvé dans la BDD
         $idCategorie = $categorie->getCategorieIdByName($oeuvre["SousCategorieObjet"]);
         //Récupère l'ID en fonction des noms passés en paramètres
     }
     $this->idCategorie = $idCategorie;
     //Mets à jour la propriété avec l'ID trouvé
     //Arrondissements
     $arrondissement = new Arrondissement();
     $idArrondissement = false;
     if (isset($oeuvre["Arrondissement"])) {
         $idArrondissement = $arrondissement->getArrondissementIdByName($oeuvre["Arrondissement"]);
         //Récupère l'ID en fonction des noms passés en paramètres
     }
     if (!$idArrondissement) {
         //Si larrondissement n'existe pas...
         $arrondissement->ajouterArrondissement($oeuvre["Arrondissement"], $oeuvre["Arrondissement"]);
         //Fait l'insertion si non trouvé dans la BDD
         $idArrondissement = $arrondissement->getArrondissementIdByName($oeuvre["Arrondissement"]);
         //Récupère l'ID en fonction des noms passés en paramètres
     }
     $this->idArrondissement = $idArrondissement;
     //Mets à jour la propriété avec l'ID trouvé
     //Artistes
     $artisteVide = new Artiste();
     foreach ($oeuvre["Artistes"] as $artiste) {
         $idArtiste = false;
         $idArtiste = $artisteVide->getArtisteIdByName($artiste["Prenom"], $artiste["Nom"], $artiste["NomCollectif"]);
         //Récupère l'ID en fonction des noms passés en paramètres
         if (!$idArtiste) {
             //Si l'artiste n'existe pas...
             $artisteVide->ajouterArtiste($artiste["Prenom"], $artiste["Nom"], $artiste["NomCollectif"]);
             //Fait l'insertion si non trouvé dans la BDD
             $idArtiste = $artisteVide->getArtisteIdByName($artiste["Prenom"], $artiste["Nom"], $artiste["NomCollectif"]);
             //Récupère l'ID en fonction des noms passés en paramètres
         }
         $idArtistes[] = $idArtiste;
         //Tableau de tous les artistes de l'eouvre
     }
     $this->idArtistes = $idArtistes;
     //Mets à jour la propriété avec les ID trouvés
 }
コード例 #5
0
ファイル: Controler.class.php プロジェクト: cmahneke/origin
 /**
  * @brief Méthode qui appelle la vue d'affichage de la page gestion
  * @access private
  * @return void
  */
 private function gestion()
 {
     $oeuvre = new Oeuvre();
     $arrondissement = new Arrondissement();
     $categorie = new Categorie();
     $photo = new Photo();
     $commentaire = new Commentaire();
     $msgErreurs = array();
     $oeuvreAjouter = '';
     //Mise à jour des oeuvres de la ville de Montréal
     if (isset($_POST["misAJour"])) {
         $msgErreurs = $oeuvre->updaterOeuvresVille();
     }
     //Affichage de la date de dernière mise à jour des oeuvres de la ville.
     $date = $oeuvre->getDateDernierUpdate();
     //Suppression d'une oeuvre.
     if (isset($_POST["boutonSuppOeuvre"])) {
         $msgErreurs = $oeuvre->supprimerOeuvre($_POST["selectOeuvreSupp"]);
     }
     //Ajout d'une oeuvre.
     $authorise = true;
     //Essaie l'ajout et récupère les messages d'erreur si présents.
     if (isset($_POST["boutonAjoutOeuvre"])) {
         $msgErreurs = $oeuvre->AjouterOeuvre($_POST['titreAjout'], $_POST['adresseAjout'], $_POST['prenomArtisteAjout'], $_POST['nomArtisteAjout'], $_POST['descriptionAjout'], $_POST["selectCategorie"], $_POST["selectArrondissement"], $authorise, $this->langueAffichage);
     }
     //Modification d'une oeuvre.
     if (isset($_POST["selectOeuvreModif"]) && $_POST["selectOeuvreModif"] != "") {
         $oeuvreAModifier = $oeuvre->getOeuvreById($_POST['selectOeuvreModif']);
     } else {
         $oeuvreAModifier = "";
     }
     //Tente la modif et récupère les messages d'erreur si présents.
     if (isset($_POST["boutonModifOeuvre"])) {
         $msgErreurs = $oeuvre->modifierOeuvre($_POST["selectOeuvreModif"], $_POST["titreModif"], $_POST["adresseModif"], $_POST["descriptionModif"], $_POST["selectCategorieModif"], $_POST["selectArrondissementModif"], $this->langueAffichage);
     }
     //Ajout d'une catégorie
     if (isset($_POST["boutonAjoutCategorie"])) {
         $msgErreurs = $categorie->ajouterCategorie($_POST["categorieFrAjout"], $_POST["categorieEnAjout"]);
     }
     //Suppression d'une catégorie
     if (isset($_POST["boutonSuppCategorie"])) {
         $msgErreurs = $categorie->supprimerCategorie($_POST["selectCategorieSupp"]);
     }
     //Soumissions des utilisateurs pour approbation par l'administrateur
     $oeuvresApprobation = $oeuvre->getAllOeuvresPourApprobation();
     $photosApprobation = $photo->getAllPhotosPourApprobation();
     $commentairesApprobation = $commentaire->getAllCommentairesPourApprobation();
     $oeuvresBDD = $oeuvre->getAllOeuvres();
     $arrondissementsBDD = $arrondissement->getAllArrondissements();
     $categorieBDD = $categorie->getAllCategories($this->langueAffichage);
     $this->oVue = new VueGestion();
     $this->oVue->setDataGlobal("Gestion", "page de gestion par l'administrateur", $this->langueAffichage, $this->pGestion);
     $this->oVue->setData($date, $oeuvreAModifier, $oeuvreAjouter, $oeuvresBDD, $arrondissementsBDD, $categorieBDD, $msgErreurs, $oeuvresApprobation, $photosApprobation, $commentairesApprobation);
     $this->oVue->afficherMeta();
     $this->oVue->afficherEntete();
     $this->oVue->afficherBody();
     $this->oVue->afficherPiedPage();
 }
コード例 #6
0
ファイル: Controler.class.php プロジェクト: MontreArt/origin
 /**
  * @brief Méthode qui affiche les résultats de la recherche utilisateur
  * @access private
  * @return void
  */
 private function recherche()
 {
     $oeuvres = array();
     $typeRecherche = "";
     $nomRecherche = "";
     if (isset($_POST["boutonRecherche"])) {
         if (isset($_POST["selectArrondissement"]) && $_POST["selectArrondissement"] != "") {
             $oeuvre = new Oeuvre();
             $oeuvres = $oeuvre->getAllOeuvresByArrondissement($_POST["selectArrondissement"]);
             $typeRecherche = "par arrondissement";
             $arrondissement = new Arrondissement();
             $nomRecherche = $arrondissement->getArrondissementNameById($_POST["selectArrondissement"]);
         } else {
             if (isset($_POST["selectCategorie"]) && $_POST["selectCategorie"] != "") {
                 $oeuvre = new Oeuvre();
                 $oeuvres = $oeuvre->getAllOeuvresByCategorie($_POST["selectCategorie"]);
                 $typeRecherche = "par catégorie";
                 $categorie = new Categorie();
                 $nomRecherche = $categorie->getCategorieNameById($_POST["selectCategorie"]);
             }
         }
     } else {
         if (isset($_GET["rechercheParArtiste"])) {
             $oeuvre = new Oeuvre();
             $oeuvres = $oeuvre->getAllOeuvresByArtiste($_GET["rechercheParArtiste"]);
             $typeRecherche = "par artiste";
             $nomRecherche = $_GET["nomArtiste"];
         } else {
             if (isset($_POST["boutonRechercheMobile"])) {
                 if (isset($_POST["selectArrondissementMobile"]) && $_POST["selectArrondissementMobile"] != "") {
                     $oeuvre = new Oeuvre();
                     $oeuvres = $oeuvre->getAllOeuvresByArrondissement($_POST["selectArrondissementMobile"]);
                     $typeRecherche = "par arrondissement";
                     $arrondissement = new Arrondissement();
                     $nomRecherche = $arrondissement->getArrondissementNameById($_POST["selectArrondissementMobile"]);
                 } else {
                     if (isset($_POST["selectCategorieMobile"]) && $_POST["selectCategorieMobile"] != "") {
                         $oeuvre = new Oeuvre();
                         $oeuvres = $oeuvre->getAllOeuvresByCategorie($_POST["selectCategorieMobile"]);
                         $typeRecherche = "par catégorie";
                         $categorie = new Categorie();
                         $nomRecherche = $categorie->getCategorieNameById($_POST["selectCategorieMobile"]);
                     }
                 }
             } else {
                 if (isset($_GET["rechercheParArtisteMobile"])) {
                     $oeuvre = new Oeuvre();
                     $oeuvres = $oeuvre->getAllOeuvresByArtiste($_GET["rechercheParArtisteMobile"]);
                     $typeRecherche = "par artiste";
                     $nomRecherche = $_GET["nomArtiste"];
                 }
             }
         }
     }
     if (isset($oeuvres)) {
         $photo = new Photo();
         $oeuvresTemp = array();
         foreach ($oeuvres as $oeuvre) {
             if ($photoOeuvre = $photo->getPhotoByOeuvre($oeuvre["idOeuvre"])) {
                 $oeuvre["photo"] = $photoOeuvre["image"];
             }
             $oeuvresTemp[] = $oeuvre;
         }
         $oeuvres = $oeuvresTemp;
     }
     $this->oVue = new VueRecherche();
     $this->oVue->setDataGlobal('recherche', 'page de recherche', $this->langueAffichage, $this->pRecherche);
     $this->oVue->setData($oeuvres, $typeRecherche, $nomRecherche);
     $this->oVue->afficherMeta();
     $this->oVue->afficherEntete();
     $this->oVue->afficherBody();
     $this->oVue->afficherPiedPage();
 }