Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 844 | Rev 962 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 844 Rev 957
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @author		Mathilde Salthun-lassalle <mathilde@tela-botanica.org>
10
 * @author		Mathilde Salthun-lassalle <mathilde@tela-botanica.org>
11
 * @copyright	2011 Tela-Botanica
11
 * @copyright	2011 Tela-Botanica
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
13
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
14
 * @version		$Id$
14
 * @version		$Id$
15
 */
15
 */
16
class Ecologie extends aControleur {
16
class Ecologie extends aControleur {
-
 
17
	
-
 
18
	private $referentiel = 'bdtfx';
-
 
19
	private $donnees = array();
17
	
20
	
18
	public function __construct(Conteneur $conteneur) {
21
	public function __construct(Conteneur $conteneur) {
19
		$this->conteneur = $conteneur;
22
		$this->conteneur = $conteneur;
20
		$this->nomCourant = $this->conteneur->getNomCourant();
23
		$this->nomCourant = $this->conteneur->getNomCourant();
-
 
24
		$this->referentiel = $this->conteneur->getParametre('referentiel');
21
		$this->informations = $this->conteneur->getApiInformations();
25
		$this->informations = $this->conteneur->getApiInformations();
22
		$this->meta = $this->conteneur->getApiMetaDonnees();
26
		$this->meta = $this->conteneur->getApiMetaDonnees();
23
		$this->wikini = $this->conteneur->getApiWikini();
27
		$this->wikini = $this->conteneur->getApiWikini();
24
		$this->appUrls = $this->conteneur->getAppUrls();
28
		$this->appUrls = $this->conteneur->getAppUrls();
25
		$this->graphique = $this->conteneur->getApiGraphiques();
29
		$this->graphique = $this->conteneur->getApiGraphiques();
26
		$this->syntaxons = $this->conteneur->getApiSyntaxons();
30
		$this->syntaxons = $this->conteneur->getApiSyntaxons();
27
		
31
		
28
		parent::__construct();
32
		parent::__construct();
29
	}
33
	}
30
	
34
	
31
	public function obtenirDonnees() {
35
	public function obtenirDonnees() {
32
		$donnees = array();
36
		$donnees = array();
33
		$donnees['wikini'] = $this->getWikini();
37
		$this->getWikini();
34
		$donnees['baseflor'] = $this->getBaseflor();
38
		$this->getBaseflor();
35
		$donnees['baseveg'] = $this->getBaseveg();
39
		$this->getBaseveg();
36
		$donnees['urls'] = $this->appUrls;
40
		$this->donnees['urls'] = $this->appUrls;
37
		return $donnees;
41
		return $this->donnees;
38
	}
42
	}
39
	
43
	
40
	public function obtenirDonneesExport() {
44
	public function obtenirDonneesExport() {
41
		$donnees = array();
45
		$donnees = array();
42
		$donnees['wikini'] = $this->getWikini();
46
		$this->getWikini();
43
		$donnees['baseflor'] = $this->getBaseflorExport();
47
		$this->getBaseflorExport();
44
		$donnees['baseveg'] = $this->getBaseveg();
48
		$this->getBaseveg();
45
		return $donnees;
49
		return $this->donnees;
46
	}
50
	}
47
	
51
	
48
	public function getBaseflorCatminat($depart, $limite) {
52
	public function getBaseflorCatminat($depart, $limite) {
49
		$baseflorCatminat = array();
53
		$baseflorCatminat = array();
50
		$this->informations ->setProjet('baseflor');
54
		$this->informations->setProjet('baseflor');
51
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
55
		$this->informations->setBdnt($this->conteneur->getParametre('referentiel'));
52
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
56
		$this->informations->setNum_nom($this->conteneur->getParametre('num_nom'));
53
		$this->informations ->setDepart($depart);
57
		$this->informations->setDepart($depart);
54
		$this->informations ->setLimite($limite);
58
		$this->informations->setLimite($limite);
55
		$informations = $this->informations->getInformationsRelationCatminat();
59
		$informations = $this->informations->getInformationsRelationCatminat();
56
		if($informations != ""){
60
		if($informations != ""){
57
			$baseflorCatminat['catminat'] = $informations['resultat'][0]['catminat_code'];
61
			$baseflorCatminat['catminat'] = $informations['resultat'][0]['catminat_code'];
58
			$baseflorCatminat['lien-liste-fancy'] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$baseflorCatminat['catminat']);
62
			$baseflorCatminat['lien-liste-fancy'] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$baseflorCatminat['catminat']);
59
		}else {
63
		}else {
60
			$baseflorCatminat['aucune'] = 'Aucunes données';
64
			$baseflorCatminat['aucune'] = 'Aucunes données';
61
		}
65
		}
62
		return $baseflorCatminat;
66
		return $baseflorCatminat;
63
	}
67
	}
64
	
68
	
65
	private function getBaseveg() {
69
	private function getBaseveg() {
-
 
70
		if (Config::get($this->referentiel.'.basePhytosocio') != "") {
66
		$baseveg = array();
71
			$baseveg = array();
67
		$baseflor = $this->getBaseflorCatminat(0,500);
72
			$baseflor = $this->getBaseflorCatminat(0,500);
68
		$baseveg['baseflor'] = $baseflor;
73
			$baseveg['baseflor'] = $baseflor;
69
		if (isset($baseflor['catminat'])) {
74
			if (isset($baseflor['catminat'])) {
70
			$this->syntaxons->setProjet('baseveg');
75
				$this->syntaxons->setProjet('baseveg');
71
			$catminat = str_replace('/','-',$baseflor['catminat']);
76
				$catminat = str_replace('/','-',$baseflor['catminat']);
72
			$this->syntaxons->setCatminat($catminat);
77
				$this->syntaxons->setCatminat($catminat);
73
			$syntaxonsSup = $this->syntaxons->getSyntaxonsSuperieurs();
78
				$syntaxonsSup = $this->syntaxons->getSyntaxonsSuperieurs();
74
			$baseveg['syntaxons-sup'] = $syntaxonsSup['resultat'];
79
				$baseveg['syntaxons-sup'] = $syntaxonsSup['resultat'];
75
			$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
80
				$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
76
			$baseveg['syntaxon-courant'] = $syntaxonsCourant['resultat'];
81
				$baseveg['syntaxon-courant'] = $syntaxonsCourant['resultat'];
77
			foreach ($baseveg['syntaxons-sup'] as $cle => $valeurs) {
82
				foreach ($baseveg['syntaxons-sup'] as $cle => $valeurs) {
78
				$catminat_sup = str_replace('/','-',$valeurs['code_catminat']);
83
					$catminat_sup = str_replace('/','-',$valeurs['code_catminat']);
79
				$baseveg['synonymes']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat_sup);
84
					$baseveg['synonymes']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat_sup);
80
				$baseveg['ref']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat_sup);
85
					$baseveg['ref']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat_sup);
81
				$baseveg['taxons']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons_sup',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat_sup);
86
					$baseveg['taxons']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons_sup',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat_sup);
-
 
87
				}
-
 
88
				$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat);
-
 
89
				$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat);
-
 
90
				$this->meta->setProjet('baseveg');
-
 
91
				$meta = $this->meta->getMetaDonnees();
-
 
92
				$citation = $meta[0]['citation'];
-
 
93
				$baseveg['meta']['citation'] = $citation;
-
 
94
				$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
-
 
95
			}else {
-
 
96
				$baseveg['aucune'] = 'Aucunes données';
82
			}
97
			}
83
			$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat);
-
 
84
			$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat);
-
 
85
			$this->meta->setProjet('baseveg');
98
			$this->donnees['baseveg'] = $baseveg;
86
			$meta = $this->meta->getMetaDonnees();
-
 
87
			$citation = $meta[0]['citation'];
-
 
88
			$baseveg['meta']['citation'] = $citation;
-
 
89
			$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
-
 
90
		}else {
-
 
91
			$baseveg['aucune'] = 'Aucunes données';
-
 
92
		}
99
		}
93
		return $baseveg;
-
 
94
	}
100
	}
95
	
101
	
96
	private function getBasevegSyntaxonCourant() {
102
	private function getBasevegSyntaxonCourant() {
97
		$baseveg = array();
103
		$baseveg = array();
98
		$baseflor = $this->getBaseflorCatminat(0,500);
104
		$baseflor = $this->getBaseflorCatminat(0,500);
99
		if (isset($baseflor['catminat'])) {
105
		if (isset($baseflor['catminat'])) {
100
			$this->syntaxons->setProjet('baseveg');
106
			$this->syntaxons->setProjet('baseveg');
101
			$catminat = str_replace('/','-',$baseflor['catminat']);
107
			$catminat = str_replace('/','-',$baseflor['catminat']);
102
			$this->syntaxons->setCatminat($catminat);
108
			$this->syntaxons->setCatminat($catminat);
103
			$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
109
			$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
104
			$baseveg['description'] = $syntaxonsCourant['resultat'];
110
			$baseveg['description'] = $syntaxonsCourant['resultat'];
105
			}
111
			}
106
		return $baseveg;
112
		return $baseveg;
107
	}
113
	}
108
	
-
 
109
	
114
		
110
	
-
 
111
	private function getWikini() {
115
	private function getWikini() {
112
		$wikini = array();
116
		$wikini = array();
113
		$wikini['titre'] = 'Wikini';
117
		$wikini['titre'] = 'Wikini';
114
		$referentiel = $this->conteneur->getParametre('referentiel');
118
		$referentiel = $this->conteneur->getParametre('referentiel');
115
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
119
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
116
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
120
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
117
		$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
121
		$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
118
		return $wikini;
122
		$this->donnees['wikini'] = $wikini;
119
	}
123
	}
120
	
124
	
121
	public function getBloc() {
125
	public function getBloc() {
122
		$donnees = array();
126
		$donnees = array();
-
 
127
		$this->getBaseflor(false);
123
		$donnees['graph'] = $this->getBaseflor(false);
128
		$this->donnees['graph'] = $this->donnees['baseflor']; 
124
		$donnees['graph']['titre'] = 'Optimum écologique';
129
		$this->donnees['graph']['titre'] = 'Optimum écologique';
125
		$donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
130
		$this->donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
-
 
131
		
126
		return $donnees;
132
		return $this->donnees;
127
	}
133
	}
128
	
134
	
129
	private function getBaseflorExport() {
135
	private function getBaseflorExport() {
130
		$baseflor = array();
136
		$baseflor = array();
131
		$this->informations ->setProjet('baseflor');
137
		$this->informations ->setProjet('baseflor');
132
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
138
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
133
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
139
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
134
		$informations = $this->informations->getInformationsEcologie();
140
		$informations = $this->informations->getInformationsEcologie();
135
		if(is_array($informations)){
141
		if(is_array($informations)){
136
			$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
142
			$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
137
			$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
143
			$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
138
			$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
144
			$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
139
			$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
145
			$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
140
			$this->graphique -> setProjet('baseflor');
146
			$this->graphique -> setProjet('baseflor');
141
			$baseflor['legende_eco'] = Config::get('chemin_images').'legende_formes.png';
147
			$baseflor['legende_eco'] = Config::get('chemin_images').'legende_formes.png';
142
			$this->meta->setProjet('baseflor');
148
			$this->meta->setProjet('baseflor');
143
			$meta = $this->meta->getMetaDonnees();
149
			$meta = $this->meta->getMetaDonnees();
144
			$citation = $meta[0]['citation'];
150
			$citation = $meta[0]['citation'];
145
			$baseflor['meta']['citation'] = $citation;
151
			$baseflor['meta']['citation'] = $citation;
146
		}else {
152
		}else {
147
			$baseflor['aucune'] = 'Aucunes données';
153
			$baseflor['aucune'] = 'Aucunes données';
148
		}
154
		}
149
		return $baseflor;
155
		return $baseflor;
150
	}
156
	}
151
	
157
	
152
	private function getBaseflor($inclure_legende = true) {
158
	private function getBaseflor($inclure_legende = true) {
-
 
159
		if (Config::get($this->referentiel.'.baseEcologie') != "") {
153
		$num_nom = $this->nomCourant->getNns();
160
			$num_nom = $this->nomCourant->getNns();
154
		$cache = $this->obtenirCache('baseflor_graphique_'.$num_nom);
161
			$cache = $this->obtenirCache('baseflor_graphique_'.$num_nom);
155
		if($cache != null) {
162
			if($cache != null) {
156
			$baseflor = $cache;
163
				$baseflor = $cache;
157
			$this->graphique ->setProjet('baseflor');
164
				$this->graphique ->setProjet('baseflor');
158
			$graphique = $this->graphique->getLegendeGraphique();
165
				$graphique = $this->graphique->getLegendeGraphique();
159
			$baseflor['legende'] =  $graphique ;
166
				$baseflor['legende'] =  $graphique ;
160
		} else {
167
			} else {
161
			$baseflor = array();
168
				$baseflor = array();
162
			$this->informations ->setProjet('baseflor');
169
				$this->informations ->setProjet('baseflor');
163
			$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
170
				$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
164
			$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
171
				$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
165
			$informations = $this->informations->getInformationsEcologie();
172
				$informations = $this->informations->getInformationsEcologie();
166
			if(is_array($informations)){
173
				if(is_array($informations)){
167
				if (isset($informations['graphique_climat'])) {
174
					if (isset($informations['graphique_climat'])) {
168
					$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
175
						$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
169
					$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
176
						$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
170
					$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
177
						$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
171
					$baseflor['description']['climat_url_png'] = $informations['graphique_climat']['href']."?retour.format=420&retour=image/png";
178
						$baseflor['description']['climat_url_png'] = $informations['graphique_climat']['href']."?retour.format=420&retour=image/png";
172
					
179
						
173
				}
180
					}
174
				if (isset($informations['graphique_sol'])) {
181
					if (isset($informations['graphique_sol'])) {
175
					$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
182
						$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
176
					$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
183
						$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
177
					$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
184
						$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
178
					$baseflor['description']['sol_url_png'] = $informations['graphique_sol']['href']."?retour.format=420&retour=image/png";
185
						$baseflor['description']['sol_url_png'] = $informations['graphique_sol']['href']."?retour.format=420&retour=image/png";
-
 
186
						
-
 
187
					}
-
 
188
					if($inclure_legende) {
-
 
189
						$this->graphique ->setProjet('baseflor');
-
 
190
						$graphique = $this->graphique->getLegendeGraphique();
-
 
191
						$baseflor['legende'] =  $graphique ;
-
 
192
					}
-
 
193
					$this->meta->setProjet('baseflor');
-
 
194
					$meta = $this->meta->getMetaDonnees();
-
 
195
					$citation = $meta[0]['citation'];
-
 
196
					$baseflor['meta']['citation'] = $citation;
-
 
197
					$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
-
 
198
					
-
 
199
					$this->mettreEnCache('baseflor_graphique_'.$num_nom, $baseflor);
-
 
200
				} else {
179
					
201
					$baseflor['aucune'] = 'Aucunes données';
180
				}
-
 
181
				if($inclure_legende) {
-
 
182
					$this->graphique ->setProjet('baseflor');
-
 
183
					$graphique = $this->graphique->getLegendeGraphique();
-
 
184
					$baseflor['legende'] =  $graphique ;
-
 
185
				}
-
 
186
				$this->meta->setProjet('baseflor');
-
 
187
				$meta = $this->meta->getMetaDonnees();
-
 
188
				$citation = $meta[0]['citation'];
-
 
189
				$baseflor['meta']['citation'] = $citation;
-
 
190
				$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
-
 
191
				
-
 
192
				$this->mettreEnCache('baseflor_graphique_'.$num_nom, $baseflor);
-
 
193
			} else {
-
 
194
				$baseflor['aucune'] = 'Aucunes données';
202
				}
-
 
203
			}
195
			}
204
			$this->donnees['baseflor'] = $baseflor;
196
		}
-
 
197
		return $baseflor;
205
		}
198
	}
206
	}
199
}
207
}
200
?>
208
?>