Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

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