Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1058 | Details | Compare with Previous | Last modification | View Log | RSS feed

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