Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 216 | Rev 257 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
163 jpm 1
<?php
2
class Conteneur {
3
	protected $parametres = array();
4
	protected $partages = array();
5
 
6
	public function __construct(array $parametres = null) {
7
		$this->parametres = is_null($parametres) ? array() : $parametres;
8
	}
9
 
10
	public function getParametre($cle) {
11
		$valeur = isset($this->parametres[$cle]) ? $this->parametres[$cle] : Config::get($cle);
12
		return $valeur;
13
	}
14
 
15
	public function getParametreTableau($cle) {
16
		$tableau = array();
17
		$parametre = $this->getParametre($cle);
18
		if (empty($parametre) === false) {
19
			$tableauPartiel = explode(',', $parametre);
20
			$tableauPartiel = array_map('trim', $tableauPartiel);
21
			foreach ($tableauPartiel as $champ) {
22
				if (strpos($champ, '=') === false) {
197 jpm 23
					$tableau[] = trim($champ);
163 jpm 24
				} else {
25
					list($cle, $val) = explode('=', $champ);
197 jpm 26
					$tableau[trim($cle)] = trim($val);
163 jpm 27
				}
28
			}
29
		}
30
		return $tableau;
31
	}
32
 
33
	public function setParametre($cle, $valeur) {
34
		$this->parametres[$cle] = $valeur;
35
	}
36
 
37
	public function getParametresUrl() {
38
		if (!isset($this->partages['Parametres'])){
39
			$this->partages['Parametres'] = new Parametres($this->parametres['parametres'], $this->getBdd());
40
		}
41
		return $this->partages['Parametres'];
42
	}
43
 
44
	public function getParametresUrlVerificateur() {
45
		if (!isset($this->partages['ParametresVerificateur'])){
46
			$parametres = $this->getParametresUrl();
47
			$parametresAPI = $this->getParametreTableau('parametresAPI');
48
			$this->partages['ParametresVerificateur'] = new ParametresVerificateur($parametres, $parametresAPI);
49
		}
50
		return $this->partages['ParametresVerificateur'];
51
	}
52
 
53
	public function getRessourcesUrl() {
54
		if (!isset($this->partages['Ressources'])){
55
			$this->partages['Ressources'] = new Ressources($this->parametres['ressources']);
56
		}
57
		return $this->partages['Ressources'];
58
	}
59
 
60
	public function getRessourcesUrlVerificateur() {
61
		if (!isset($this->partages['RessourcesVerificateur'])){
62
			$ressources = $this->getRessourcesUrl();
63
			$projetsDispo = $this->getParametreTableau('projetsDispo');
64
			$servicesDispo = $this->getParametreTableau('servicesDispo');
65
			$this->partages['RessourcesVerificateur'] = new RessourcesVerificateur($ressources, $projetsDispo, $servicesDispo);
66
		}
67
		return $this->partages['RessourcesVerificateur'];
68
	}
69
 
216 jpm 70
	public function getVersionVerificateur() {
71
		if (!isset($this->partages['VersionVerificateur'])){
72
			$ressources = $this->getRessourcesUrl();
73
			$parametres = $this->getParametresUrl();
74
			$versions = $this->getVersions();
75
			$this->partages['VersionVerificateur'] = new VersionVerificateur($ressources, $parametres, $versions);
76
		}
77
		return $this->partages['VersionVerificateur'];
78
	}
79
 
215 jpm 80
	public function getBdd() {
81
		if (!isset($this->partages['Bdd'])){
82
			$this->partages['Bdd'] = new Bdd();
83
		}
84
		return $this->partages['Bdd'];
85
	}
86
 
87
	public function getVersions() {
88
		if (!isset($this->partages['Versions'])){
89
			$parametres = $this->getParametresUrl();
90
			$ressources = $this->getRessourcesUrl();
91
			$bdd = $this->getBdd();
92
			$versions = new Versions($parametres, $ressources, $bdd);
93
			$this->partages['Versions'] = $versions;
94
		}
95
		return $this->partages['Versions'];
96
	}
97
 
163 jpm 98
	public function getProjet() {
99
		if (!isset($this->partages['Projet'])){
100
			$ressources = $this->getRessourcesUrl();
101
			$projet = new Projet($ressources);
102
			$projet->setCheminBase($this->getParametre('cheminBase'));
103
			$projet->setCheminConfig($this->getParametre('chemin_configurations'));
104
			$projet->setCheminBiblio($this->getParametre('chemin_bibliotheque'));
105
			$projet->initialiser();
106
			$projet->setParamsVerif($this->getParametresUrlVerificateur());
107
			$projet->setRessourcesVerif($this->getRessourcesUrlVerificateur());
216 jpm 108
			$projet->setVersionVerif($this->getVersionVerificateur());
215 jpm 109
			$projet->setServiceGenerique($this->getServiceGenerique());
163 jpm 110
			$this->partages['Projet'] = $projet;
111
		}
112
		return $this->partages['Projet'];
113
	}
114
 
208 jpm 115
	public function getNomDao() {
116
		$ressources = $this->getRessourcesUrl();
117
		$parametres = $this->getParametresUrl();
118
		$bdd = $this->getBdd();
119
		$versions = $this->getVersions();
215 jpm 120
		$nomDao = new NomDAO($ressources, $parametres, $bdd, $versions);
208 jpm 121
		return $nomDao;
122
	}
123
 
231 jpm 124
	public function getOntologiesDao() {
125
		$ressources = $this->getRessourcesUrl();
126
		$parametres = $this->getParametresUrl();
127
		$bdd = $this->getBdd();
128
		$versions = $this->getVersions();
129
		$ontologieDao = new OntologieDAO($ressources, $parametres, $bdd, $versions);
130
		return $ontologieDao;
131
	}
132
 
208 jpm 133
	public function getNomFormateur() {
134
		$formateur = new NomFormateur();
135
		$formateur->setBdd($this->getBdd());
136
		$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
137
		$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
138
		$formateur->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
139
		return $formateur;
140
	}
141
 
231 jpm 142
	public function getOntologiesFormateur() {
143
		$formateur = new OntologieFormateur();
144
		$formateur->setBdd($this->getBdd());
145
		$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
146
		$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefOntologiesTpl'));
147
		$formateur->setLangueDemandee($this->getParametresUrl()->get('retour.langue'));
148
		return $formateur;
149
	}
150
 
215 jpm 151
	public function getServiceGenerique() {
231 jpm 152
		$ressources = $this->getRessourcesUrl();
153
		$classe = $ressources->getServiceClasse();
215 jpm 154
		$classeGenerique = $classe.'Generique';
231 jpm 155
		if ($ressources->getServiceNom() == 'noms' || $ressources->getServiceNom() == 'taxons') {
156
			$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur());
157
			if ($classe == 'NomsListe') {
158
				$service->setListeUrl($this->getParametre('listeUrl'));
159
			}
160
		} else if ($ressources->getServiceNom() == 'ontologies') {
161
			$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getOntologiesDao(), $this->getOntologiesFormateur());
162
			if ($classe == 'OntologiesListe') {
163
				$service->setListeUrl($this->getParametre('listeUrlOntologies'));
164
			}
163 jpm 165
		}
231 jpm 166
 
163 jpm 167
		return $service;
168
	}
169
}
170
?>