Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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