Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 566 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 566 Rev 1084
Line 16... Line 16...
16
	private $bdnt;
16
	private $bdnt;
17
	private $num_nom;
17
	private $num_nom;
18
	private $type_graph;
18
	private $type_graph;
19
	private $classe;
19
	private $classe;
20
	private $code;
20
	private $code;
-
 
21
	// pour chaque code, [0] est le min (départ de recherche des valeurs)
-
 
22
	// et [1] est le max (fin)
21
	private $codes =  array ("VEL", "VET", "VEHA", "VEC", "VER", "VEHE", "VETX", "VEN", "VES","VEMO");
23
	static $codes = array ("VEL" => array(1,9),
22
	
-
 
23
	
-
 
-
 
24
						   "VET" => array(1,9),
-
 
25
						   "VEHA" => array(1,9),
-
 
26
						   "VEC" => array(1,9),
-
 
27
						   "VER" => array(1,9),
-
 
28
						   "VETX" => array(1,9),
-
 
29
						   "VEN" => array(1,9),
-
 
30
						   "VEMO" => array(1,9),
-
 
31
						   "VEHE" => array(1,12),
-
 
32
						   "VES" => array(0,9) );
Line 24... Line 33...
24
 
33
 
25
	public function setType_graph($tg) {
34
	public function setType_graph($tg) {
26
		$this->type_graph = $tg;
35
		$this->type_graph = $tg;
Line 40... Line 49...
40
	
49
	
41
	public function setNum_nom($nn){
50
	public function setNum_nom($nn){
42
		$this->num_nom = $nn;
51
		$this->num_nom = $nn;
Line -... Line 52...
-
 
52
	}
-
 
53
 
-
 
54
	// TODO: array_map() // XXX: PHP-5.3
-
 
55
	static function _build_range() {
-
 
56
		$ret = array();
-
 
57
		foreach (self::$codes as $classe => $val) {
-
 
58
			foreach(range($val[0], $val[1]) as $i) {
-
 
59
				$ret[] = $classe . ':' . $i;
-
 
60
			}
-
 
61
		}
-
 
62
		return implode(',', $ret);
-
 
63
	}
-
 
64
 
-
 
65
	// TODO: array_map() // XXX: PHP-5.3
-
 
66
	static function _split_data($tab) {
-
 
67
		$ret = array();
-
 
68
		foreach ($tab as $k => $v) {
-
 
69
			list($new_k, $sub_k) = explode(':', $k);
-
 
70
			$ret[$new_k][$sub_k] = $v;
-
 
71
		}
Line 43... Line 72...
43
	}
72
		return $ret;
44
	
73
	}
45
	
-
 
46
	public function getLegendeGraphique() {
74
 
47
		$legende = array();
75
	public function getLegendeGraphique() {
48
		foreach ($this->codes as $cod){
-
 
49
			$i = ($cod == "VES") ?  0 : 1 ;
-
 
50
			$max = ($cod == "VEHE") ?  12 : 9 ;
-
 
51
			while ($i < $max+1){
76
		$legende = array();
52
				$this->setClasse($cod);
77
		// eg: VEL:1,VEL:2,VEL:3,...VER:9,VETX:1,...
53
				$this->setCode($i);
-
 
54
				$url = $this->getUrlLegende();
-
 
55
				$legende[$cod][$i] = $this->chargerDonnees($url);
-
 
56
				$i++;
78
		$ressources = self::_build_range();
57
			}			
-
 
58
		}
-
 
59
		return $legende;
-
 
60
	}
-
 
61
	
-
 
62
	public function getUrlLegende() {
79
		$url = Eflore::s_formaterUrl(Config::get('legendeGraphiqueTpl'),
63
		$tpl = Config::get('legendeGraphiqueTpl');
80
									 $this->ajouterParametreParDefaut(array('params' => $ressources)),
64
		$params = array( 'code' => $this->code, 'classe' => $this->classe );
81
									 FALSE);
Line 65... Line 82...
65
		$url = $this->formaterUrl($tpl, $params);
82
		$data = $this->chargerDonnees($url);
66
		return $url ;
83
		return self::_split_data($data);
67
	}
84
	}