Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

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