Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 605 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 605 Rev 919
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
	
-
 
25
	
24
 
26
	//+------------------------------------------------------------------------------------------------------+
25
	//+------------------------------------------------------------------------------------------------------+
27
	// Méthodes communes aux projets d'eFlore
26
	// Méthodes communes aux projets d'eFlore
28
 
27
 
29
	public function chargerConfigDuProjet() {
28
	public function chargerConfigDuProjet() {
30
		$scriptChemin = $this->Conteneur->getParametre('scriptChemin');
29
		$scriptChemin = $this->Conteneur->getParametre('scriptChemin');
31
		$fichierIni = $scriptChemin.$this->projetNom.'.ini';
30
		$fichierIni = $scriptChemin.$this->projetNom.'.ini';
32
		if (file_exists($fichierIni)) {
31
		if (file_exists($fichierIni)) {
33
			Config::charger($fichierIni);
32
			Config::charger($fichierIni);
34
		} else {
33
		} else {
35
			$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
34
			$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'.";
35
			"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
37
			throw new Exception($m);
36
			throw new Exception($m);
38
		}
37
		}
39
	}
38
	}
40
 
39
 
41
	//changée
40
	//changée
42
	public function chargerStructureSql() {
41
	public function chargerStructureSql() {
43
		$this->chargerFichierSql('chemins.structureSql');
42
		$this->chargerFichierSql('chemins.structureSql');
44
	}
43
	}
45
	
-
 
46
	
44
 
47
	public function chargerFichierSql($param_chemin) {
45
	public function chargerFichierSql($param_chemin) {
48
		$fichierStructureSql = $this->Conteneur->getParametre($param_chemin);
46
		$fichierStructureSql = $this->Conteneur->getParametre($param_chemin);
49
		$contenuSql = $this->recupererContenu($fichierStructureSql);
47
		$contenuSql = $this->recupererContenu($fichierStructureSql);
50
		$this->executerScriptSql($contenuSql);
48
		$this->executerScriptSql($contenuSql);
51
	}
49
	}
52
	
-
 
53
	
-
 
54
 
50
 
55
	public function executerScriptSql($sql) {
51
	public function executerScriptSql($sql) {
56
		$requetes = Outils::extraireRequetes($sql);
52
		$requetes = Outils::extraireRequetes($sql);
57
		foreach ($requetes as $requete) {
53
		foreach ($requetes as $requete) {
58
			$this->Bdd->requeter($requete);
54
			$this->Bdd->requeter($requete);
59
		}
55
		}
60
	}
56
	}
61
 
57
 
62
	public function recupererContenu($chemin) {
58
	public function recupererContenu($chemin) {
63
		$contenu = file_get_contents($chemin);
59
		$contenu = file_get_contents($chemin);
64
		if ($contenu === false){
60
		if ($contenu === false){
65
			throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
61
			throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
66
		}
62
		}
67
		return $contenu;
63
		return $contenu;
68
	}
64
	}
69
}
65
}
70
?>
66
?>