Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 797 | Rev 815 | 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();
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'];
804 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();
67
		$baseflor = $this->getBaseflorCatminat(0,5);
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);
81
			}
82
			$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat);
83
			$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->conteneur->getParametre('num_nom'),$catminat);
770 mathilde 84
			$this->meta->setProjet('baseveg');
85
			$meta = $this->meta->getMetaDonnees();
86
			$citation = $meta[0]['citation'];
87
			$baseveg['meta']['citation'] = $citation;
88
			$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
89
		}else {
90
			$baseveg['aucune'] = 'Aucunes données';
91
		}
92
		return $baseveg;
93
	}
94
 
95
 
96
 
417 aurelien 97
	private function getWikini() {
98
		$wikini = array();
99
		$wikini['titre'] = 'Wikini';
100
		$referentiel = $this->conteneur->getParametre('referentiel');
101
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
102
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
418 aurelien 103
		$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
417 aurelien 104
		return $wikini;
105
	}
540 mathilde 106
 
558 mathilde 107
	public function getBloc() {
606 mathilde 108
		$donnees = array();
752 aurelien 109
		$donnees = $this->getBaseflor(false);
606 mathilde 110
		$donnees['titre'] = 'Optimum écologique';
558 mathilde 111
		return $donnees;
112
	}
113
 
697 mathilde 114
	private function getBaseflorExport() {
115
		$baseflor = array();
116
		$this->informations ->setProjet('baseflor');
117
		$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
118
		$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
119
		$informations = $this->informations->getInformationsEcologie();
120
		if($informations != ""){
121
			$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
122
			$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
123
			$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
124
			$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
125
			$this->graphique -> setProjet('baseflor');
126
			$baseflor['legende_eco'] = Config::get('chemin_images').'legende_formes.png';
127
			$this->meta->setProjet('baseflor');
128
			$meta = $this->meta->getMetaDonnees();
129
			$citation = $meta[0]['citation'];
130
			$baseflor['meta']['citation'] = $citation;
131
		}else {
132
			$baseflor['aucune'] = 'Aucunes données';
133
		}
134
		return $baseflor;
135
	}
136
 
752 aurelien 137
	private function getBaseflor($inclure_legende = true) {
763 aurelien 138
		$num_nom = $this->nomCourant->getNns();
139
		$cache = $this->obtenirCache('baseflor_graphique_'.$num_nom);
140
		if($cache != null) {
141
			$baseflor = $cache;
797 mathilde 142
			$this->graphique ->setProjet('baseflor');
143
			$graphique = $this->graphique->getLegendeGraphique();
144
			$baseflor['legende'] =  $graphique ;
763 aurelien 145
		} else {
146
			$baseflor = array();
147
			$this->informations ->setProjet('baseflor');
148
			$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
149
			$this->informations ->setNum_nom($this->conteneur->getParametre('num_nom'));
150
			$informations = $this->informations->getInformationsEcologie();
151
			if($informations != ""){
152
				$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
153
				$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
154
				$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
155
				$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
156
				if($inclure_legende) {
797 mathilde 157
					$this->graphique ->setProjet('baseflor');
763 aurelien 158
					$graphique = $this->graphique->getLegendeGraphique();
159
					$baseflor['legende'] =  $graphique ;
160
				}
161
				$this->meta->setProjet('baseflor');
162
				$meta = $this->meta->getMetaDonnees();
163
				$citation = $meta[0]['citation'];
164
				$baseflor['meta']['citation'] = $citation;
165
				$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
166
				$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
167
				$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
168
				$baseflor['description']['climat_url_png'] = $informations['graphique_climat']['href']."?retour.format=420&retour=image/png";
169
				$baseflor['description']['sol_url_png'] = $informations['graphique_sol']['href']."?retour.format=420&retour=image/png";
170
				$this->mettreEnCache('baseflor_graphique_'.$num_nom, $baseflor);
171
			}else {
172
				$baseflor['aucune'] = 'Aucunes données';
752 aurelien 173
			}
540 mathilde 174
		}
175
		return $baseflor;
176
	}
272 delphine 177
}
178
?>