Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1013 Rev 1023
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
	
17
	
18
	private $referentiel = 'bdtfx';
18
	private $referentiel = 'bdtfx';
19
	private $donnees = array();
19
	private $donnees = array();
20
	
20
	
21
	public function __construct(Conteneur $conteneur) {
21
	public function __construct(Conteneur $conteneur) {
22
		$this->conteneur = $conteneur;
22
		$this->conteneur = $conteneur;
23
		$this->nomCourant = $this->conteneur->getNomCourant();
23
		$this->nomCourant = $this->conteneur->getNomCourant();
24
		$this->referentiel = $this->conteneur->getParametre('referentiel');
24
		$this->referentiel = $this->conteneur->getParametre('referentiel');
25
		$this->informations = $this->conteneur->getApiInformations();
25
		$this->informations = $this->conteneur->getApiInformations();
26
		$this->meta = $this->conteneur->getApiMetaDonnees();
26
		$this->meta = $this->conteneur->getApiMetaDonnees();
27
		$this->wikini = $this->conteneur->getApiWikini();
27
		$this->wikini = $this->conteneur->getApiWikini();
28
		$this->appUrls = $this->conteneur->getAppUrls();
28
		$this->appUrls = $this->conteneur->getAppUrls();
29
		$this->graphique = $this->conteneur->getApiGraphiques();
29
		$this->graphique = $this->conteneur->getApiGraphiques();
30
		$this->syntaxons = $this->conteneur->getApiSyntaxons();
30
		$this->syntaxons = $this->conteneur->getApiSyntaxons();
31
		
31
		
32
		parent::__construct();
32
		parent::__construct();
33
	}
33
	}
34
	
34
	
35
	public function obtenirDonnees() {
35
	public function obtenirDonnees() {
36
		$donnees = array();
36
		$donnees = array();
37
		$this->getWikini();
37
		$this->getWikini();
38
		$this->getBaseflor();
38
		$this->getBaseflor();
39
		$this->getBaseveg();
39
		$this->getBaseveg();
40
		$this->donnees['urls'] = $this->appUrls;
40
		$this->donnees['urls'] = $this->appUrls;
41
		return $this->donnees;
41
		return $this->donnees;
42
	}
42
	}
43
	
43
	
44
	public function obtenirDonneesExport() {
44
	public function obtenirDonneesExport() {
45
		$donnees['wikini'] = $this->getWikini();
45
		$donnees['wikini'] = $this->getWikini();
46
		$donnees['baseflor'] = $this->getBaseflorExport();
46
		$donnees['baseflor'] = $this->getBaseflorExport();
47
		$donnees['baseveg'] = $this->getBaseveg();
47
		$donnees['baseveg'] = $this->getBaseveg();
48
		return $donnees;
48
		return $donnees;
49
	}
49
	}
50
	
50
	
51
	public function getBaseflorCatminat($depart, $limite) {
51
	public function getBaseflorCatminat($depart, $limite) {
52
		$baseflorCatminat = array();
52
		$baseflorCatminat = array();
53
		$this->informations->setProjet('baseflor');
53
		$this->informations->setProjet('baseflor');
54
		$this->informations->setBdnt($this->conteneur->getParametre('referentiel'));
54
		$this->informations->setBdnt($this->conteneur->getParametre('referentiel'));
55
		$this->informations->setNum_nom($this->nomCourant->getNnr());
55
		$this->informations->setNum_nom($this->nomCourant->getNnr());
56
		$this->informations->setDepart($depart);
56
		$this->informations->setDepart($depart);
57
		$this->informations->setLimite($limite);
57
		$this->informations->setLimite($limite);
58
		$informations = $this->informations->getInformationsRelationCatminat();
58
		$informations = $this->informations->getInformationsRelationCatminat();
59
		if($informations != ""){
59
		if($informations != ""){
60
			$baseflorCatminat['catminat'] = $informations['resultat'][0]['catminat_code'];
60
			$baseflorCatminat['catminat'] = $informations['resultat'][0]['catminat_code'];
61
			$baseflorCatminat['lien-liste-fancy'] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$baseflorCatminat['catminat']);
61
			$baseflorCatminat['lien-liste-fancy'] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$baseflorCatminat['catminat']);
62
		}else {
62
		}else {
63
			$baseflorCatminat['aucune'] = 'Aucune donnée';
63
			$baseflorCatminat['aucune'] = 'Aucune donnée';
64
		}
64
		}
65
		return $baseflorCatminat;
65
		return $baseflorCatminat;
66
	}
66
	}
67
	
67
	
68
	private function getBaseveg() {
68
	private function getBaseveg() {
69
		if (Config::get($this->referentiel.'.basePhytosocio') != "") {
69
		if (Config::get($this->referentiel.'.basePhytosocio') != "") {
70
			$baseveg = array();
70
			$baseveg = array();
71
			$baseflor = $this->getBaseflorCatminat(0,500);
71
			$baseflor = $this->getBaseflorCatminat(0,500);
72
			$baseveg['baseflor'] = $baseflor;
72
			$baseveg['baseflor'] = $baseflor;
73
			if (isset($baseflor['catminat'])) {
73
			if (isset($baseflor['catminat'])) {
74
				$this->syntaxons->setProjet('baseveg');
74
				$this->syntaxons->setProjet('baseveg');
75
				$catminat = str_replace('/','-',$baseflor['catminat']);
75
				$catminat = str_replace('/','-',$baseflor['catminat']);
76
				$this->syntaxons->setCatminat($catminat);
76
				$this->syntaxons->setCatminat($catminat);
77
				$syntaxonsSup = $this->syntaxons->getSyntaxonsSuperieurs();
77
				$syntaxonsSup = $this->syntaxons->getSyntaxonsSuperieurs();
78
				$baseveg['syntaxons-sup'] = $syntaxonsSup['resultat'];
78
				$baseveg['syntaxons-sup'] = $syntaxonsSup['resultat'];
79
				$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
79
				$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
80
				$baseveg['syntaxon-courant'] = $syntaxonsCourant['resultat'];
80
				$baseveg['syntaxon-courant'] = $syntaxonsCourant['resultat'];
81
				foreach ($baseveg['syntaxons-sup'] as $cle => $valeurs) {
81
				foreach ($baseveg['syntaxons-sup'] as $cle => $valeurs) {
82
					$catminat_sup = str_replace('/','-',$valeurs['code_catminat']);
82
					$catminat_sup = str_replace('/','-',$valeurs['code_catminat']);
83
					$baseveg['synonymes']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
83
					$baseveg['synonymes']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
84
					$baseveg['ref']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
84
					$baseveg['ref']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
85
					$baseveg['taxons']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons_sup',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
85
					$baseveg['taxons']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons_sup',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
86
				}
86
				}
87
				$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
87
				$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
88
				$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
88
				$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
89
				$this->meta->setProjet('baseveg');
89
				$this->meta->setProjet('baseveg');
90
				$meta = $this->meta->getMetaDonnees();
90
				$meta = $this->meta->getMetaDonnees();
91
				$citation = $meta[0]['citation'];
91
				$citation = $meta[0]['citation'];
92
				$baseveg['meta']['citation'] = $citation;
92
				$baseveg['meta']['citation'] = $citation;
93
				$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
93
				$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
94
			}else {
94
			}else {
95
				$baseveg['aucune'] = 'Aucune donnée';
95
				$baseveg['aucune'] = 'Aucune donnée';
96
			}
96
			}
97
			$this->donnees['baseveg'] = $baseveg;
97
			$this->donnees['baseveg'] = $baseveg;
98
		}
98
		}
99
	}
99
	}
100
	
100
	
101
	private function getBasevegSyntaxonCourant() {
101
	private function getBasevegSyntaxonCourant() {
102
		$baseveg = array();
102
		$baseveg = array();
103
		$baseflor = $this->getBaseflorCatminat(0,500);
103
		$baseflor = $this->getBaseflorCatminat(0,500);
104
		if (isset($baseflor['catminat'])) {
104
		if (isset($baseflor['catminat'])) {
105
			$this->syntaxons->setProjet('baseveg');
105
			$this->syntaxons->setProjet('baseveg');
106
			$catminat = str_replace('/','-',$baseflor['catminat']);
106
			$catminat = str_replace('/','-',$baseflor['catminat']);
107
			$this->syntaxons->setCatminat($catminat);
107
			$this->syntaxons->setCatminat($catminat);
108
			$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
108
			$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
109
			$baseveg['description'] = $syntaxonsCourant['resultat'];
109
			$baseveg['description'] = $syntaxonsCourant['resultat'];
110
			}
110
			}
111
		return $baseveg;
111
		return $baseveg;
112
	}
112
	}
113
		
113
		
114
	private function getWikini() {
114
	private function getWikini() {
115
		$wikini = array();
115
		$wikini = array();
116
		$wikini['titre'] = 'Wikini';
116
		$wikini['titre'] = 'Wikini';
117
		$referentiel = $this->conteneur->getParametre('referentiel');
117
		$referentiel = $this->conteneur->getParametre('referentiel');
118
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
118
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
119
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
119
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
120
		$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
120
		$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
121
		$this->donnees['wikini'] = $wikini;
121
		$this->donnees['wikini'] = $wikini;
122
	}
122
	}
123
	
123
	
124
	public function getBloc() {
124
	public function getBloc() {
125
		$donnees = array();
125
		$donnees = array();
126
		$this->getBaseflor(false);
126
		$this->getBaseflor(false);
127
		$this->donnees['graph'] = $this->donnees['baseflor']; 
127
		$this->donnees['graph'] = $this->donnees['baseflor']; 
128
		$this->donnees['graph']['titre'] = 'Optimum écologique';
128
		$this->donnees['graph']['titre'] = 'Optimum écologique';
129
		$this->donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
129
		$this->donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
130
		
130
		
131
		return $this->donnees;
131
		return $this->donnees;
132
	}
132
	}
133
	
133
	
134
	private function getBaseflorExport() {
134
	private function getBaseflorExport() {
135
		$baseflor = array();
135
		$baseflor = array();
136
		$this->informations ->setProjet('baseflor');
136
		$this->informations ->setProjet('baseflor');
137
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
137
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
138
		$this->informations ->setNum_nom($this->nomCourant->getNnr());
138
		$this->informations ->setNum_nom($this->nomCourant->getNnr());
139
		$informations = $this->informations->getInformationsEcologie();
139
		$informations = $this->informations->getInformationsEcologie();
140
		if(is_array($informations)){
140
		if(is_array($informations)){
141
			$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
141
			$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
142
			$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
142
			$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
143
			$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
143
			$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
144
			$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
144
			$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
145
			$this->graphique -> setProjet('baseflor');
145
			$this->graphique -> setProjet('baseflor');
146
			$baseflor['legende_eco'] = Config::get('chemin_images').'legende_formes.png';
146
			$baseflor['legende_eco'] = $this->urls->obtenirUrlBaseDossier() . Config::get('dossier_images') . '/legende_formes.png';
147
			$this->meta->setProjet('baseflor');
147
			$this->meta->setProjet('baseflor');
148
			$meta = $this->meta->getMetaDonnees();
148
			$meta = $this->meta->getMetaDonnees();
149
			$citation = $meta[0]['citation'];
149
			$citation = $meta[0]['citation'];
150
			$baseflor['meta']['citation'] = $citation;
150
			$baseflor['meta']['citation'] = $citation;
151
		}else {
151
		}else {
152
			$baseflor['aucune'] = 'Aucune donnée';
152
			$baseflor['aucune'] = 'Aucune donnée';
153
		}
153
		}
154
		return $baseflor;
154
		return $baseflor;
155
	}
155
	}
156
	
156
	
157
	private function getBaseflor($inclure_legende = true) {
157
	private function getBaseflor($inclure_legende = true) {
158
		if (Config::get($this->referentiel.'.baseEcologie') != "") {
158
		if (Config::get($this->referentiel.'.baseEcologie') != "") {
159
			$num_nom = $this->nomCourant->getNnr();
159
			$num_nom = $this->nomCourant->getNnr();
160
			$referentiel = $this->conteneur->getParametre('referentiel');
160
			$referentiel = $this->conteneur->getParametre('referentiel');
161
			$cache = $this->obtenirCache('baseflor/graphique/'.$referentiel.'_'.$num_nom);
161
			$cache = $this->obtenirCache('baseflor/graphique/'.$referentiel.'_'.$num_nom);
162
			if($cache != null) {
162
			if($cache != null) {
163
				$baseflor = $cache;
163
				$baseflor = $cache;
164
				$this->graphique ->setProjet('baseflor');
164
				$this->graphique ->setProjet('baseflor');
165
				$graphique = $this->graphique->getLegendeGraphique();
165
				$graphique = $this->graphique->getLegendeGraphique();
166
				$baseflor['legende'] =  $graphique ;
166
				$baseflor['legende'] =  $graphique ;
167
			} else {
167
			} else {
168
				$baseflor = array();
168
				$baseflor = array();
169
				$this->informations ->setProjet('baseflor');
169
				$this->informations ->setProjet('baseflor');
170
				$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
170
				$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
171
				$this->informations ->setNum_nom($this->nomCourant->getNnr());
171
				$this->informations ->setNum_nom($this->nomCourant->getNnr());
172
				$informations = $this->informations->getInformationsEcologie();
172
				$informations = $this->informations->getInformationsEcologie();
173
				if(is_array($informations)){
173
				if(is_array($informations)){
174
					if (isset($informations['graphique_climat'])) {
174
					if (isset($informations['graphique_climat'])) {
175
						$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
175
						$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
176
						$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
176
						$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
177
						$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
177
						$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
178
						$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";
179
						
179
						
180
					}
180
					}
181
					if (isset($informations['graphique_sol'])) {
181
					if (isset($informations['graphique_sol'])) {
182
						$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
182
						$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
183
						$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
183
						$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
184
						$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
184
						$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
185
						$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
						
186
						
187
					}
187
					}
188
					if($inclure_legende) {
188
					if($inclure_legende) {
189
						$this->graphique ->setProjet('baseflor');
189
						$this->graphique ->setProjet('baseflor');
190
						$graphique = $this->graphique->getLegendeGraphique();
190
						$graphique = $this->graphique->getLegendeGraphique();
191
						$baseflor['legende'] =  $graphique ;
191
						$baseflor['legende'] =  $graphique ;
192
					}
192
					}
193
					$this->meta->setProjet('baseflor');
193
					$this->meta->setProjet('baseflor');
194
					$meta = $this->meta->getMetaDonnees();
194
					$meta = $this->meta->getMetaDonnees();
195
					$citation = $meta[0]['citation'];
195
					$citation = $meta[0]['citation'];
196
					$baseflor['meta']['citation'] = $citation;
196
					$baseflor['meta']['citation'] = $citation;
197
					$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
197
					$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
198
					
198
					
199
					$this->mettreEnCache('baseflor/graphique/'.$referentiel.'_'.$num_nom, $baseflor);
199
					$this->mettreEnCache('baseflor/graphique/'.$referentiel.'_'.$num_nom, $baseflor);
200
				} else {
200
				} else {
201
					$baseflor['aucune'] = 'Aucune donnée';
201
					$baseflor['aucune'] = 'Aucune donnée';
202
				}
202
				}
203
			}
203
			}
204
			$this->donnees['baseflor'] = $baseflor;
204
			$this->donnees['baseflor'] = $baseflor;
205
		}
205
		}
206
	}
206
	}
207
}
207
}
208
?>
208
?>