Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 197 | 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) {
23
					$tableau[] = $champ;
24
				} else {
25
					list($cle, $val) = explode('=', $champ);
26
					$tableau[$cle] = $val;
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
	}
69
 
70
	public function getProjet() {
71
		if (!isset($this->partages['Projet'])){
72
			$ressources = $this->getRessourcesUrl();
73
			$projet = new Projet($ressources);
74
			$projet->setCheminBase($this->getParametre('cheminBase'));
75
			$projet->setCheminConfig($this->getParametre('chemin_configurations'));
76
			$projet->setCheminBiblio($this->getParametre('chemin_bibliotheque'));
77
			$projet->initialiser();
78
			$projet->setParamsVerif($this->getParametresUrlVerificateur());
79
			$projet->setRessourcesVerif($this->getRessourcesUrlVerificateur());
80
			$this->partages['Projet'] = $projet;
81
		}
82
		return $this->partages['Projet'];
83
	}
84
 
85
	public function getBdd() {
86
		if (!isset($this->partages['Bdd'])){
87
			$this->partages['Bdd'] = new Bdd();
88
		}
89
		return $this->partages['Bdd'];
90
	}
91
 
92
	public function getService($classe) {
93
		$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getBdd());
94
		if ($service instanceof NomDetails) {
95
			$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
96
			$service->setChampsProjets($this->getParametreTableau('champsProjets'));
97
			$service->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
98
		} else if ($service instanceof NomsListe) {
99
			$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
100
			$service->setListeUrl($this->getParametre('listeUrl'));
101
		}
102
		return $service;
103
	}
104
}
105
?>