Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 207 Rev 208
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 getProjet() {
70
	public function getProjet() {
71
		if (!isset($this->partages['Projet'])){
71
		if (!isset($this->partages['Projet'])){
72
			$ressources = $this->getRessourcesUrl();
72
			$ressources = $this->getRessourcesUrl();
73
			$projet = new Projet($ressources);
73
			$projet = new Projet($ressources);
74
			$projet->setCheminBase($this->getParametre('cheminBase'));
74
			$projet->setCheminBase($this->getParametre('cheminBase'));
75
			$projet->setCheminConfig($this->getParametre('chemin_configurations'));
75
			$projet->setCheminConfig($this->getParametre('chemin_configurations'));
76
			$projet->setCheminBiblio($this->getParametre('chemin_bibliotheque'));
76
			$projet->setCheminBiblio($this->getParametre('chemin_bibliotheque'));
77
			$projet->initialiser();
77
			$projet->initialiser();
78
			$projet->setParamsVerif($this->getParametresUrlVerificateur());
78
			$projet->setParamsVerif($this->getParametresUrlVerificateur());
79
			$projet->setRessourcesVerif($this->getRessourcesUrlVerificateur());
79
			$projet->setRessourcesVerif($this->getRessourcesUrlVerificateur());
80
			$this->partages['Projet'] = $projet;
80
			$this->partages['Projet'] = $projet;
81
		}
81
		}
82
		return $this->partages['Projet'];
82
		return $this->partages['Projet'];
83
	}
83
	}
84
 
84
 
85
	public function getVersions() {
85
	public function getVersions() {
86
		if (!isset($this->partages['Versions'])){
86
		if (!isset($this->partages['Versions'])){
87
			$parametres = $this->getParametresUrl();
87
			$parametres = $this->getParametresUrl();
88
			$bdd = $this->getBdd();
88
			$bdd = $this->getBdd();
89
			$projetNom = $this->getProjet()->getNom();
89
			$projetNom = $this->getProjet()->getNom();
90
			$versions = new Versions($parametres, $bdd, $projetNom);
90
			$versions = new Versions($parametres, $bdd, $projetNom);
91
			$this->partages['Versions'] = $versions;
91
			$this->partages['Versions'] = $versions;
92
		}
92
		}
93
		return $this->partages['Versions'];
93
		return $this->partages['Versions'];
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
 
-
 
103
	public function getNomDao() {
-
 
104
		$ressources = $this->getRessourcesUrl();
-
 
105
		$parametres = $this->getParametresUrl();
-
 
106
		$bdd = $this->getBdd();
-
 
107
		$projet = $this->getProjet();
-
 
108
		$versions = $this->getVersions();
-
 
109
		$nomDao = new NomDAO($ressources, $parametres, $bdd, $projet, $versions);
-
 
110
		return $nomDao;
-
 
111
	}
-
 
112
 
-
 
113
	public function getNomFormateur() {
-
 
114
		$formateur = new NomFormateur();
-
 
115
		$formateur->setBdd($this->getBdd());
-
 
116
		$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
-
 
117
		$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
-
 
118
		$formateur->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
-
 
119
		return $formateur;
-
 
120
	}
102
 
121
 
103
	public function getService($classe) {
122
	public function getService($classe) {
104
		$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getBdd());
-
 
105
		$service->setProjet($this->getProjet()->getNom());
-
 
106
		$service->setVersions($this->getVersions());
-
 
107
		$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
-
 
108
		$service->setChampsProjet($this->getParametreTableau('champsProjet'));
-
 
109
		$service->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
123
		$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur());
110
		if ($service instanceof NomsListe) {
124
		if ($service instanceof NomsListe) {
111
			$service->setListeUrl($this->getParametre('listeUrl'));
125
			$service->setListeUrl($this->getParametre('listeUrl'));
112
		}
126
		}
113
		return $service;
127
		return $service;
114
	}
128
	}
115
}
129
}
116
?>
130
?>