Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | 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
	}
524 mathilde 69
 
70
	public function getRequetesAssemblage() {
71
		if (!isset($this->partages['RequetesAssemblage'])){
72
			$this->partages['RequetesAssemblage'] =  new RequetesAssemblage($this->getBdd());
73
		}
74
		return $this->partages['RequetesAssemblage'];
75
	}
76
 
163 jpm 77
 
216 jpm 78
	public function getVersionVerificateur() {
79
		if (!isset($this->partages['VersionVerificateur'])){
80
			$ressources = $this->getRessourcesUrl();
81
			$parametres = $this->getParametresUrl();
82
			$versions = $this->getVersions();
83
			$this->partages['VersionVerificateur'] = new VersionVerificateur($ressources, $parametres, $versions);
84
		}
85
		return $this->partages['VersionVerificateur'];
86
	}
87
 
215 jpm 88
	public function getBdd() {
89
		if (!isset($this->partages['Bdd'])){
90
			$this->partages['Bdd'] = new Bdd();
91
		}
92
		return $this->partages['Bdd'];
93
	}
94
 
257 jpm 95
	public function getCacheSimple($options = array()) {
96
		$cache = new CacheSimple($options);
97
		return $cache;
98
	}
99
 
215 jpm 100
	public function getVersions() {
101
		if (!isset($this->partages['Versions'])){
102
			$parametres = $this->getParametresUrl();
103
			$ressources = $this->getRessourcesUrl();
104
			$bdd = $this->getBdd();
105
			$versions = new Versions($parametres, $ressources, $bdd);
106
			$this->partages['Versions'] = $versions;
107
		}
108
		return $this->partages['Versions'];
109
	}
110
 
163 jpm 111
	public function getProjet() {
112
		if (!isset($this->partages['Projet'])){
113
			$ressources = $this->getRessourcesUrl();
114
			$projet = new Projet($ressources);
115
			$projet->setCheminBase($this->getParametre('cheminBase'));
116
			$projet->setCheminConfig($this->getParametre('chemin_configurations'));
117
			$projet->setCheminBiblio($this->getParametre('chemin_bibliotheque'));
118
			$projet->initialiser();
119
			$projet->setParamsVerif($this->getParametresUrlVerificateur());
120
			$projet->setRessourcesVerif($this->getRessourcesUrlVerificateur());
216 jpm 121
			$projet->setVersionVerif($this->getVersionVerificateur());
215 jpm 122
			$projet->setServiceGenerique($this->getServiceGenerique());
163 jpm 123
			$this->partages['Projet'] = $projet;
124
		}
125
		return $this->partages['Projet'];
126
	}
127
 
208 jpm 128
	public function getNomDao() {
129
		$ressources = $this->getRessourcesUrl();
130
		$parametres = $this->getParametresUrl();
131
		$bdd = $this->getBdd();
132
		$versions = $this->getVersions();
215 jpm 133
		$nomDao = new NomDAO($ressources, $parametres, $bdd, $versions);
208 jpm 134
		return $nomDao;
135
	}
136
 
231 jpm 137
	public function getOntologiesDao() {
138
		$ressources = $this->getRessourcesUrl();
139
		$parametres = $this->getParametresUrl();
140
		$bdd = $this->getBdd();
141
		$versions = $this->getVersions();
142
		$ontologieDao = new OntologieDAO($ressources, $parametres, $bdd, $versions);
143
		return $ontologieDao;
144
	}
145
 
208 jpm 146
	public function getNomFormateur() {
147
		$formateur = new NomFormateur();
148
		$formateur->setBdd($this->getBdd());
149
		$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
150
		$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
151
		$formateur->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
152
		return $formateur;
153
	}
154
 
231 jpm 155
	public function getOntologiesFormateur() {
156
		$formateur = new OntologieFormateur();
157
		$formateur->setBdd($this->getBdd());
158
		$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
159
		$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefOntologiesTpl'));
160
		$formateur->setLangueDemandee($this->getParametresUrl()->get('retour.langue'));
161
		return $formateur;
162
	}
163
 
274 jpm 164
	public function getWikipediaBot($options = array()) {
165
		$wpBot = new WikipediaBot($options);
166
		return $wpBot;
167
	}
168
 
169
	public function getUrl($url) {
170
		$url = new Url($url);
171
		return $url;
172
	}
173
 
215 jpm 174
	public function getServiceGenerique() {
231 jpm 175
		$ressources = $this->getRessourcesUrl();
176
		$classe = $ressources->getServiceClasse();
215 jpm 177
		$classeGenerique = $classe.'Generique';
231 jpm 178
		if ($ressources->getServiceNom() == 'noms' || $ressources->getServiceNom() == 'taxons') {
179
			$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur());
180
			if ($classe == 'NomsListe') {
181
				$service->setListeUrl($this->getParametre('listeUrl'));
182
			}
183
		} else if ($ressources->getServiceNom() == 'ontologies') {
184
			$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getOntologiesDao(), $this->getOntologiesFormateur());
185
			if ($classe == 'OntologiesListe') {
186
				$service->setListeUrl($this->getParametre('listeUrlOntologies'));
187
			}
163 jpm 188
		}
231 jpm 189
 
163 jpm 190
		return $service;
191
	}
192
}
193
?>