Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 922 | Details | Compare with Previous | 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) {
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
 
215 jpm 37
	public function getBdd() {
38
		if (!isset($this->partages['Bdd'])){
39
			$this->partages['Bdd'] = new Bdd();
40
		}
41
		return $this->partages['Bdd'];
42
	}
43
 
257 jpm 44
	public function getCacheSimple($options = array()) {
45
		$cache = new CacheSimple($options);
46
		return $cache;
47
	}
48
 
274 jpm 49
	public function getWikipediaBot($options = array()) {
50
		$wpBot = new WikipediaBot($options);
51
		return $wpBot;
52
	}
53
 
54
	public function getUrl($url) {
55
		$url = new Url($url);
56
		return $url;
57
	}
163 jpm 58
}
59
?>