Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Details | 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']);
1130 aurelien 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();
1130 aurelien 93
				$baseveg['meta'] = $meta[0];
957 aurelien 94
				$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
95
			}else {
989 delphine 96
				$baseveg['aucune'] = 'Aucune donnée';
804 mathilde 97
			}
957 aurelien 98
			$this->donnees['baseveg'] = $baseveg;
770 mathilde 99
		}
100
	}
101
 
824 mathilde 102
	private function getBasevegSyntaxonCourant() {
103
		$baseveg = array();
104
		$baseflor = $this->getBaseflorCatminat(0,500);
105
		if (isset($baseflor['catminat'])) {
106
			$this->syntaxons->setProjet('baseveg');
107
			$catminat = str_replace('/','-',$baseflor['catminat']);
108
			$this->syntaxons->setCatminat($catminat);
109
			$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
110
			$baseveg['description'] = $syntaxonsCourant['resultat'];
111
			}
112
		return $baseveg;
113
	}
957 aurelien 114
 
417 aurelien 115
	private function getWikini() {
116
		$wikini = array();
117
		$wikini['titre'] = 'Wikini';
118
		$referentiel = $this->conteneur->getParametre('referentiel');
119
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
120
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
418 aurelien 121
		$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
957 aurelien 122
		$this->donnees['wikini'] = $wikini;
417 aurelien 123
	}
540 mathilde 124
 
558 mathilde 125
	public function getBloc() {
606 mathilde 126
		$donnees = array();
957 aurelien 127
		$this->getBaseflor(false);
128
		$this->donnees['graph'] = $this->donnees['baseflor'];
129
		$this->donnees['graph']['titre'] = 'Optimum écologique';
130
		$this->donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
131
 
132
		return $this->donnees;
558 mathilde 133
	}
134
 
697 mathilde 135
	private function getBaseflorExport() {
136
		$baseflor = array();
137
		$this->informations ->setProjet('baseflor');
138
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
987 delphine 139
		$this->informations ->setNum_nom($this->nomCourant->getNnr());
697 mathilde 140
		$informations = $this->informations->getInformationsEcologie();
844 aurelien 141
		if(is_array($informations)){
697 mathilde 142
			$baseflor['climat_url'] = $informations['graphique_climat']['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";
145
			$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
146
			$this->graphique -> setProjet('baseflor');
1023 raphael 147
			$baseflor['legende_eco'] = $this->urls->obtenirUrlBaseDossier() . Config::get('dossier_images') . '/legende_formes.png';
697 mathilde 148
			$this->meta->setProjet('baseflor');
149
			$meta = $this->meta->getMetaDonnees();
1130 aurelien 150
			$baseflor['meta']= $meta[0];
697 mathilde 151
		}else {
989 delphine 152
			$baseflor['aucune'] = 'Aucune donnée';
697 mathilde 153
		}
154
		return $baseflor;
155
	}
156
 
752 aurelien 157
	private function getBaseflor($inclure_legende = true) {
1058 raphael 158
		if (Config::get($this->referentiel.'.baseEcologie')) {
159
			$referentiel = $this->conteneur->getParametre('referentiel');
987 delphine 160
			$num_nom = $this->nomCourant->getNnr();
1058 raphael 161
 
162
			// TODO: unserialize() pourrait aussi légitimement retourner FALSE
163
			$cache = unserialize($this->conteneur->getCache()->charger('baseflor/graphique/'.$referentiel.'_'.$num_nom));
164
			if($cache) {
957 aurelien 165
				$baseflor = $cache;
166
				$this->graphique ->setProjet('baseflor');
167
				$graphique = $this->graphique->getLegendeGraphique();
168
				$baseflor['legende'] =  $graphique ;
169
			} else {
170
				$baseflor = array();
171
				$this->informations ->setProjet('baseflor');
172
				$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
987 delphine 173
				$this->informations ->setNum_nom($this->nomCourant->getNnr());
957 aurelien 174
				$informations = $this->informations->getInformationsEcologie();
175
				if(is_array($informations)){
176
					if (isset($informations['graphique_climat'])) {
177
						$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
178
						$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
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";
181
 
182
					}
183
					if (isset($informations['graphique_sol'])) {
184
						$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
185
						$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
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";
188
 
189
					}
190
					if($inclure_legende) {
191
						$this->graphique ->setProjet('baseflor');
192
						$graphique = $this->graphique->getLegendeGraphique();
193
						$baseflor['legende'] =  $graphique ;
194
					}
195
					$this->meta->setProjet('baseflor');
196
					$meta = $this->meta->getMetaDonnees();
1130 aurelien 197
					$baseflor['meta'] = $meta[0];
957 aurelien 198
					$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
840 mathilde 199
 
1058 raphael 200
					$this->conteneur->getCache()->sauver(serialize($baseflor),
201
														 'baseflor/graphique/'.$referentiel.'_'.$num_nom);
957 aurelien 202
				} else {
989 delphine 203
					$baseflor['aucune'] = 'Aucune donnée';
838 mathilde 204
				}
752 aurelien 205
			}
957 aurelien 206
			$this->donnees['baseflor'] = $baseflor;
540 mathilde 207
		}
208
	}
272 delphine 209
}
210
?>