Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 462 | Rev 503 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
450 mathilde 1
<?php
2
/**
3
* Classe GraphiquesBaseflor.php transforme les données écologiques de la table baseflor
4
*  en graphique svg
5
*  graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie un graphique avec les données connues
6
*
7
*
8
* @package eflore-projets
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
13
* @version 1.0
14
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
15
*/
16
 
17
class GraphiquesBaseflor extends CommunGraphiques{
18
 
19
 
20
 
21
 
22
	public function definirTable($version){
23
		$this->table = Config::get('bdd_table')."_v".$version;
24
	}
25
 
26
 
27
 
28
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
29
 
30
	public function traiterReferentieletNum(){
31
		if (isset($this->ressources) && !empty($this->ressources[1])) {
32
			if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[1], $retour) == 1){
33
 
34
				switch ($retour[1]) {
35
					case 'bdtfx' :
36
						$this->requete_condition[]= "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
37
						break;
38
					case  'bdafx' :
39
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdafx' ";
40
						break;
41
					case  'bdbfx' :
42
						$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdbfx' ";
43
						break;
44
					default :
45
						$e = 'Erreur dans l\'url de votre requête : </br> La ressource " '
46
					.$retour[1].' " n\'existe pas.';
47
					throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
48
					break;
49
				}
50
 
51
			}else {
52
				$e = 'Erreur dans l\'url de votre requête : </br> La ressource  n\'existe pas.';
53
				throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
54
			}
55
		} else {
56
			throw new Exception( "Erreur dans l\'url de votre requête :".
57
						"preciser le référentiel et le numéro nomenclatural sous la forme {bdnt}.nn:{nn}.",
58
			RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
59
		}
60
 
61
	}
62
 
63
 
64
 
65
	public function traiterTypeGraphique(){
66
		if (isset($this->ressources) && !empty($this->ressources[0])) {
67
			switch ($this->ressources[0]) {
68
				case  'climat' :
69
					$this->requete_champs = ' ve_lumiere , ve_temperature, ve_continentalite, ve_humidite_atmos' ;
70
					$this->nomGraphique= 'climat';
71
					break;
72
				case 'sol' :
73
					$this->requete_champs = ' ve_humidite_edaph , ve_reaction_sol, ve_nutriments_sol, ve_salinite,'
74
					.'ve_texture_sol, ve_mat_org_sol' ;
75
					$this->nomGraphique = 'sol';
76
					break;
77
				default :
78
					$e = 'Erreur dans l\'url de votre requête : </br> La ressource " '
79
				.$retour[1].' " n\'existe pas.';
80
				throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
81
				break;
82
			}
83
		}else {
84
			throw new Exception("Erreur dans l\'url de votre requête :".
85
				"</br> precisez le graphique -> \"sol\" ou \"climat\".", RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
86
		}
87
	}
88
 
89
 
90
	//+-------------------------- formatage du résultat  -------------------------------------------+
91
 
92
 
93
	/// ++++ svg +++++ ///
94
 
95
	public function changerValeursSVG(){
96
		$Dompath = new DOMXPath($this->dom);
97
		foreach ($this->valeurs_en_pourcentage as $cle => $val){
98
				$val = preg_replace('/,/','.', $val);
99
				$grad_id = array_search($val,$this->graduations_id);
100
				$element = $Dompath->query("//*[@id='".$grad_id."']")->item(0);
101
				$pos_x = $element->getAttribute('x1');
102
				$curseur = $Dompath->query("//*[@id='".$cle."']")->item(0);
103
				$curseur->setAttribute('cx', $pos_x);
104
				$curseur->setAttribute('class', 'curseur');
105
				$this->ajouterInfoAuSurvol($curseur);
106
				$changement = true;
107
		}
108
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
109
		$svg->setAttribute('width',$this->largeurSVG);
110
	}
111
 
112
	public function ajouterInfoAuSurvol($curseur){
113
		$champs = $curseur->getAttribute('id');
114
		$valeurTexte = $this->recupererOntologies($this->valeurs_champs[$champs], $champs );
464 mathilde 115
		$valeurTexte = $this->traiterIntermediaires($valeurTexte->nom, $champs, $champs);
116
		$curseur->setAttribute('title',$this->valeurs_champs[$champs].": ".$valeurTexte );
450 mathilde 117
	}
464 mathilde 118
 
450 mathilde 119
 
120
}
121
?>