Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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