Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 521 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 521 Rev 605
1
<?php
1
<?php
2
/**
2
/**
3
 *
3
 *
4
 * fonctions
4
 * fonctions
5
 * @author mathilde
5
 * @author mathilde
6
 *
6
 *
7
 */
7
 */
8
class EfloreCommun {
8
class EfloreCommun {
9
 
9
 
10
	private $Conteneur = null;
10
	private $Conteneur = null;
11
	private $Bdd = null;
11
	private $Bdd = null;
12
	private $projetNom = '';
12
	private $projetNom = '';
13
	private $scriptChemin = '';
13
	private $scriptChemin = '';
14
 
14
 
15
	public function __construct($conteneur) {
15
	public function __construct($conteneur) {
16
		$this->Conteneur = $conteneur;
16
		$this->Conteneur = $conteneur;
17
		$this->Bdd = $this->Conteneur->getBdd();
17
		$this->Bdd = $this->Conteneur->getBdd();
18
	}
18
	}
19
 
19
 
20
	public function initialiserProjet($projetNom) {
20
	public function initialiserProjet($projetNom) {
21
		$this->projetNom = $projetNom;
21
		$this->projetNom = $projetNom;
22
		$this->chargerConfigDuProjet();
22
		$this->chargerConfigDuProjet();
23
	}
23
	}
24
	
24
	
25
	
25
	
26
	//+------------------------------------------------------------------------------------------------------+
26
	//+------------------------------------------------------------------------------------------------------+
27
	// Méthodes communes aux projets d'eFlore
27
	// Méthodes communes aux projets d'eFlore
28
 
28
 
29
	public function chargerConfigDuProjet() {
29
	public function chargerConfigDuProjet() {
30
		$scriptChemin = $this->Conteneur->getParametre('scriptChemin');
30
		$scriptChemin = $this->Conteneur->getParametre('scriptChemin');
31
		$fichierIni = $scriptChemin.$this->projetNom.'.ini';
31
		$fichierIni = $scriptChemin.$this->projetNom.'.ini';
32
		if (file_exists($fichierIni)) {
32
		if (file_exists($fichierIni)) {
33
			Config::charger($fichierIni);
33
			Config::charger($fichierIni);
34
		} else {
34
		} else {
35
			$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
35
			$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
36
			"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
36
			"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
37
			throw new Exception($m);
37
			throw new Exception($m);
38
		}
38
		}
39
	}
39
	}
40
 
40
 
41
	//changée
41
	//changée
42
	public function chargerStructureSql() {
42
	public function chargerStructureSql() {
43
		$this->chargerFichierSql('chemins.structureSql');
43
		$this->chargerFichierSql('chemins.structureSql');
44
	}
44
	}
45
	
45
	
46
	
46
	
47
	public function chargerFichierSql($param_chemin) {
47
	public function chargerFichierSql($param_chemin) {
48
		$fichierStructureSql = $this->Conteneur->getParametre($param_chemin);
48
		$fichierStructureSql = $this->Conteneur->getParametre($param_chemin);
49
		$contenuSql = $this->recupererContenu($fichierStructureSql);
49
		$contenuSql = $this->recupererContenu($fichierStructureSql);
50
		$this->executerScripSql($contenuSql);
50
		$this->executerScriptSql($contenuSql);
51
	}
51
	}
52
	
52
	
53
	
53
	
54
 
54
 
55
	public function executerScripSql($sql) {
55
	public function executerScriptSql($sql) {
56
		$requetes = Outils::extraireRequetes($sql);
56
		$requetes = Outils::extraireRequetes($sql);
57
		foreach ($requetes as $requete) {
57
		foreach ($requetes as $requete) {
58
			$this->Bdd->requeter($requete);
58
			$this->Bdd->requeter($requete);
59
		}
59
		}
60
	}
60
	}
61
 
61
 
62
	public function recupererContenu($chemin) {
62
	public function recupererContenu($chemin) {
63
		$contenu = file_get_contents($chemin);
63
		$contenu = file_get_contents($chemin);
64
		if ($contenu === false){
64
		if ($contenu === false){
65
			throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
65
			throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
66
		}
66
		}
67
		return $contenu;
67
		return $contenu;
68
	}
68
	}
69
}
69
}
70
?>
70
?>