Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1130 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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