Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 441 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
425 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[] = trim($champ);
24
				} else {
25
					list($cle, $val) = explode('=', $champ);
26
					$tableau[trim($cle)] = trim($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 getOutils() {
38
		if (!isset($this->partages['Outils'])){
39
			$this->partages['Outils'] = new Outils();
40
		}
41
		return $this->partages['Outils'];
42
	}
43
 
44
	public function getMessages() {
45
		if (!isset($this->partages['Messages'])){
46
			$this->partages['Messages'] = new Messages($this->getParametre('-v'));
47
		}
48
		return $this->partages['Messages'];
49
	}
50
}
51
?>