Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 566 Rev 1084
Line 9... Line 9...
9
 * @copyright	2011 Tela-Botanica
9
 * @copyright	2011 Tela-Botanica
10
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
10
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
12
 * @version		$Id$
12
 * @version		$Id$
13
 */
13
 */
14
class Graphiques  extends Eflore {
14
class Graphiques extends Eflore {
Line 15... Line 15...
15
 
15
 
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;
-
 
21
	// pour chaque code, [0] est le min (départ de recherche des valeurs)
20
	private $code;
22
	// et [1] est le max (fin)
21
	private $codes =  array ("VEL", "VET", "VEHA", "VEC", "VER", "VEHE", "VETX", "VEN", "VES","VEMO");
-
 
22
	
-
 
-
 
23
	static $codes = array ("VEL" => array(1,9),
-
 
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),
Line 23... Line 32...
23
	
32
						   "VES" => array(0,9) );
24
 
33
 
25
	public function setType_graph($tg) {
34
	public function setType_graph($tg) {
Line 39... Line 48...
39
	}
48
	}
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;
43
	}
-
 
44
	
52
	}
-
 
53
 
45
	
54
	// TODO: array_map() // XXX: PHP-5.3
46
	public function getLegendeGraphique() {
55
	static function _build_range() {
47
		$legende = array();
56
		$ret = array();
48
		foreach ($this->codes as $cod){
-
 
49
			$i = ($cod == "VES") ?  0 : 1 ;
57
		foreach (self::$codes as $classe => $val) {
50
			$max = ($cod == "VEHE") ?  12 : 9 ;
-
 
51
			while ($i < $max+1){
58
			foreach(range($val[0], $val[1]) as $i) {
52
				$this->setClasse($cod);
-
 
53
				$this->setCode($i);
-
 
54
				$url = $this->getUrlLegende();
-
 
55
				$legende[$cod][$i] = $this->chargerDonnees($url);
-
 
56
				$i++;
59
				$ret[] = $classe . ':' . $i;
57
			}			
60
			}
58
		}
61
		}
59
		return $legende;
62
		return implode(',', $ret);
60
	}
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
		}
-
 
72
		return $ret;
-
 
73
	}
61
	
74
 
-
 
75
	public function getLegendeGraphique() {
-
 
76
		$legende = array();
-
 
77
		// eg: VEL:1,VEL:2,VEL:3,...VER:9,VETX:1,...
62
	public function getUrlLegende() {
78
		$ressources = self::_build_range();
63
		$tpl = Config::get('legendeGraphiqueTpl');
79
		$url = Eflore::s_formaterUrl(Config::get('legendeGraphiqueTpl'),
-
 
80
									 $this->ajouterParametreParDefaut(array('params' => $ressources)),
64
		$params = array( 'code' => $this->code, 'classe' => $this->classe );
81
									 FALSE);
65
		$url = $this->formaterUrl($tpl, $params);
82
		$data = $this->chargerDonnees($url);
66
		return $url ;
83
		return self::_split_data($data);
Line 67... Line 84...
67
	}
84
	}
68
	
85
	
69
	public function getGraphique() {
86
	public function getGraphique() {