Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

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