Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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