Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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