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 |
|
559 |
mathilde |
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 |
}
|
|
|
77 |
|
524 |
mathilde |
78 |
public function getRequetesAssemblage() {
|
|
|
79 |
if (!isset($this->partages['RequetesAssemblage'])){
|
|
|
80 |
$this->partages['RequetesAssemblage'] = new RequetesAssemblage($this->getBdd());
|
|
|
81 |
}
|
|
|
82 |
return $this->partages['RequetesAssemblage'];
|
|
|
83 |
}
|
|
|
84 |
|
163 |
jpm |
85 |
|
216 |
jpm |
86 |
public function getVersionVerificateur() {
|
|
|
87 |
if (!isset($this->partages['VersionVerificateur'])){
|
|
|
88 |
$ressources = $this->getRessourcesUrl();
|
|
|
89 |
$parametres = $this->getParametresUrl();
|
|
|
90 |
$versions = $this->getVersions();
|
|
|
91 |
$this->partages['VersionVerificateur'] = new VersionVerificateur($ressources, $parametres, $versions);
|
|
|
92 |
}
|
|
|
93 |
return $this->partages['VersionVerificateur'];
|
|
|
94 |
}
|
|
|
95 |
|
215 |
jpm |
96 |
public function getBdd() {
|
|
|
97 |
if (!isset($this->partages['Bdd'])){
|
|
|
98 |
$this->partages['Bdd'] = new Bdd();
|
|
|
99 |
}
|
|
|
100 |
return $this->partages['Bdd'];
|
|
|
101 |
}
|
|
|
102 |
|
257 |
jpm |
103 |
public function getCacheSimple($options = array()) {
|
|
|
104 |
$cache = new CacheSimple($options);
|
|
|
105 |
return $cache;
|
|
|
106 |
}
|
|
|
107 |
|
215 |
jpm |
108 |
public function getVersions() {
|
|
|
109 |
if (!isset($this->partages['Versions'])){
|
|
|
110 |
$parametres = $this->getParametresUrl();
|
|
|
111 |
$ressources = $this->getRessourcesUrl();
|
|
|
112 |
$bdd = $this->getBdd();
|
559 |
mathilde |
113 |
$versions = new Versions($parametres, $bdd);
|
215 |
jpm |
114 |
$this->partages['Versions'] = $versions;
|
|
|
115 |
}
|
|
|
116 |
return $this->partages['Versions'];
|
|
|
117 |
}
|
|
|
118 |
|
163 |
jpm |
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());
|
216 |
jpm |
129 |
$projet->setVersionVerif($this->getVersionVerificateur());
|
215 |
jpm |
130 |
$projet->setServiceGenerique($this->getServiceGenerique());
|
163 |
jpm |
131 |
$this->partages['Projet'] = $projet;
|
|
|
132 |
}
|
|
|
133 |
return $this->partages['Projet'];
|
|
|
134 |
}
|
|
|
135 |
|
208 |
jpm |
136 |
public function getNomDao() {
|
|
|
137 |
$ressources = $this->getRessourcesUrl();
|
|
|
138 |
$parametres = $this->getParametresUrl();
|
|
|
139 |
$bdd = $this->getBdd();
|
|
|
140 |
$versions = $this->getVersions();
|
215 |
jpm |
141 |
$nomDao = new NomDAO($ressources, $parametres, $bdd, $versions);
|
208 |
jpm |
142 |
return $nomDao;
|
|
|
143 |
}
|
|
|
144 |
|
231 |
jpm |
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 |
|
208 |
jpm |
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 |
|
231 |
jpm |
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 |
|
274 |
jpm |
172 |
public function getWikipediaBot($options = array()) {
|
|
|
173 |
$wpBot = new WikipediaBot($options);
|
|
|
174 |
return $wpBot;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
public function getUrl($url) {
|
|
|
178 |
$url = new Url($url);
|
|
|
179 |
return $url;
|
|
|
180 |
}
|
|
|
181 |
|
215 |
jpm |
182 |
public function getServiceGenerique() {
|
231 |
jpm |
183 |
$ressources = $this->getRessourcesUrl();
|
|
|
184 |
$classe = $ressources->getServiceClasse();
|
215 |
jpm |
185 |
$classeGenerique = $classe.'Generique';
|
231 |
jpm |
186 |
if ($ressources->getServiceNom() == 'noms' || $ressources->getServiceNom() == 'taxons') {
|
|
|
187 |
$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur());
|
|
|
188 |
if ($classe == 'NomsListe') {
|
|
|
189 |
$service->setListeUrl($this->getParametre('listeUrl'));
|
|
|
190 |
}
|
|
|
191 |
} else if ($ressources->getServiceNom() == 'ontologies') {
|
|
|
192 |
$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getOntologiesDao(), $this->getOntologiesFormateur());
|
|
|
193 |
if ($classe == 'OntologiesListe') {
|
|
|
194 |
$service->setListeUrl($this->getParametre('listeUrlOntologies'));
|
|
|
195 |
}
|
163 |
jpm |
196 |
}
|
231 |
jpm |
197 |
|
163 |
jpm |
198 |
return $service;
|
|
|
199 |
}
|
|
|
200 |
}
|
|
|
201 |
?>
|