Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 477 → Rev 478

/trunk/scripts/bibliotheque/Conteneur.php
43,7 → 43,7
 
public function getEfloreCommun() {
if (!isset($this->partages['EfloreCommun'])){
$this->partages['EfloreCommun'] = new EfloreCommun();
$this->partages['EfloreCommun'] = new EfloreCommun($this);
}
return $this->partages['EfloreCommun'];
}
61,5 → 61,12
}
return $this->partages['RestClient'];
}
 
public function getBdd() {
if (!isset($this->partages['Bdd'])){
$this->partages['Bdd'] = new Bdd();
}
return $this->partages['Bdd'];
}
}
?>
/trunk/scripts/bibliotheque/EfloreCommun.php
1,68 → 1,62
<?php
/**
*
* fonctions
*
* fonctions
* @author mathilde
*
*/
class EfloreCommun {
 
class EfloreCommun {
private $Conteneur = null;
private $Bdd = null;
private $projetNom = null;
private $projetNom = '';
private $scriptChemin = '';
 
public function __construct($conteneur) {
$this->Conteneur = $conteneur;
$this->Bdd = $this->Conteneur->getBdd();
}
 
public function initialiserProjet($projetNom) {
$this->projetNom = $projetNom;
$this->chargerConfigDuProjet();
}
 
//+------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les scripts n'ont pas besoin de s'y connecter.
*/
public function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
//+------------------------------------------------------------------------------------------------------+
// Méthodes communes aux projets d'eFlore
 
public function chargerConfigDuProjet() {
$fichierIni = $this->getScriptChemin().$this->getProjetNom().'.ini';
if (file_exists($fichierIni)) {
Config::charger($fichierIni);
} else {
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
throw new Exception($m);
}
$scriptChemin = $this->Conteneur->getParametre('scriptChemin');
$fichierIni = $scriptChemin.$this->projetNom.'.ini';
if (file_exists($fichierIni)) {
Config::charger($fichierIni);
} else {
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
throw new Exception($m);
}
}
 
//changée
public function chargerStructureSql($structure_sql) {
$contenuSql = $this->recupererContenu(Config::get($structure_sql));
$this->executerScripSql($contenuSql);
public function chargerStructureSql() {
$fichierStructureSql = $this->Conteneur->getParametre('chemins.structureSql');
$contenuSql = $this->recupererContenu($fichierStructureSql);
$this->executerScripSql($contenuSql);
}
 
public function executerScripSql($sql) {
$requetes = Outils::extraireRequetes($sql);
$requetes = Outils::extraireRequetes($sql);
foreach ($requetes as $requete) {
$this->getBdd()->requeter($requete);
$this->Bdd->requeter($requete);
}
}
}
 
public function recupererContenu($chemin) {
$contenu = file_get_contents($chemin);
if ($contenu === false){
throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
$contenu = file_get_contents($chemin);
if ($contenu === false){
throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
}
return $contenu;
}
return $contenu;
}
}
?>