Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1346 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1026 alex 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>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Repartition extends aControleur {
16
 
17
	private $conteneur = null;
18
	private $nomCourant = null;
19
	private $referentiel = 'bdtfx';
20
	private $donnees = array();
21
	private $cartes;
22
	private $meta;
23
	private $appUrls;
1327 jpm 24
 
1026 alex 25
	public function __construct(Conteneur $conteneur) {
26
		$this->conteneur = $conteneur;
27
		$this->nomCourant = $this->conteneur->getNomCourant();
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
29
		$this->cartes = $this->conteneur->getApiCartes();
30
		$this->meta = $this->conteneur->getApiMetaDonnees();
31
		$this->appUrls = $this->conteneur->getAppUrls();
32
	}
33
 
34
	public function obtenirDonnees() {
35
		$this->getRepartition();
36
		$this->getMoissonnage();
1217 aurelien 37
		$this->getFloreProbable();
1026 alex 38
		$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
39
		$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
40
		$this->donnees['widget']['referentiel'] = $this->referentiel;
41
		return $this->donnees;
42
	}
43
 
44
	public function obtenirDonneesExport() {
1028 raphael 45
		$this->getRepartition();
46
		$donnees['chorodep'] = $this->donnees['repartition'];
47
		$this->getMoissonnageExport();
48
		// TODO: renommer l'index "eflore" en moissonnage
1327 jpm 49
		// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html
1028 raphael 50
		$donnees['eflore'] = $this->donnees['moissonnage'];
1026 alex 51
		return $donnees;
52
	}
1327 jpm 53
 
1026 alex 54
	private function getRepartition() {
1346 jpm 55
		$projetRepartition = Config::get("{$this->referentiel}.baseRepartition");
1028 raphael 56
		// eg: eflore ou chorodep
57
		// cf: bdtfx.ini, bdtxa.ini
1327 jpm 58
		if ($projetRepartition != '') {
1026 alex 59
			$this->cartes->setProjet($projetRepartition);
60
			$this->cartes->setLargeur('630');
1346 jpm 61
			$nt = $this->nomCourant->getNt();
62
			$this->cartes->setId("{$this->referentiel}.nt:$nt");
1026 alex 63
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
64
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
65
			$repartition['legende'] = $this->cartes->getLegendeId();
66
			$this->meta->setProjet($projetRepartition);
67
			$meta = $this->meta->getMetaDonnees();
1130 aurelien 68
			$repartition['meta'] = $meta[0];
1026 alex 69
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
70
			$this->donnees['repartition'] = $repartition;
71
		}
72
	}
1327 jpm 73
 
1026 alex 74
	private function getMoissonnage() {
75
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
1028 raphael 76
		if (! $projetMoissonnage) return;
77
		$this->cartes->setProjet('moissonnage');
78
		$this->cartes->setLargeur('600');
79
		$this->cartes->setInfoNom($this->nomCourant->getNt());
80
		$this->cartes->setInfoReferentiel($this->referentiel);
81
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
1112 aurelien 82
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
83
												'html' => $this->cartes->getUrlTelechargementMapHtml());
1028 raphael 84
		$eflore['legende'] = $this->cartes->getLegende();
85
		$this->donnees['moissonnage'] = $eflore;
1026 alex 86
	}
1327 jpm 87
 
1026 alex 88
	private function getMoissonnageExport() {
1028 raphael 89
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
90
		if (! $projetMoissonnage) return;
91
		$this->cartes->setProjet($projetMoissonnage);
1026 alex 92
		$this->cartes->setLargeur('min');
93
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
94
		$eflore['min'] = $this->cartes->getUrlEflorePng();
95
		$eflore['legende'] = $this->cartes->getLegende();
1028 raphael 96
		$this->donnees['moissonnage'] = $eflore;
1026 alex 97
	}
1327 jpm 98
 
1217 aurelien 99
	private function getFloreProbable() {
1219 aurelien 100
		$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
1217 aurelien 101
		if (! $projetFloreProbable) return;
102
		$this->cartes->setProjet($projetFloreProbable);
103
		$this->meta->setProjet($projetFloreProbable);
104
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
105
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
106
		// dans ['carte']['telechargement'] par exemple
107
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
1236 aurelien 108
		$this->meta->setProjet($projetFloreProbable);
109
		$meta = $this->meta->getMetaDonnees();
110
		$this->donnees['flore_probable']['meta'] = $meta[0];
1217 aurelien 111
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
112
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
113
	}
114
 
1026 alex 115
	public function getBloc() {
116
		$donnees['chorodep'] = $this->getChorodepMiniature();
117
		$donnees['eflore'] = $this->getMoissonnageMiniature();
1049 raphael 118
 
119
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
120
		// afficher la carte chorologie, et non la carte chorodep.
121
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
1346 jpm 122
		if ($this->referentiel == 'bdtxa') {
123
			$nt = $this->nomCourant->getNt();
124
			$idCarte = "{$this->referentiel}.nt:$nt";
125
			$urlCarte = Config::get("{$this->referentiel}.baseRepartition");
126
 
127
			$donnees['chorodep'] = Cartes::getCarteUrlPng($urlCarte, $idCarte, '190x178');
1049 raphael 128
		}
129
 
1026 alex 130
		return $donnees;
131
	}
1327 jpm 132
 
1026 alex 133
	private function getChorodepMiniature() {
1346 jpm 134
		$projetRepartition = Config::get("{$this->referentiel}.baseRepartition");
1165 aurelien 135
		$url = null;
1346 jpm 136
		if ($projetRepartition != '') {
1165 aurelien 137
			$this->cartes->setProjet($projetRepartition);
138
			$this->cartes->setProjet('chorodep');
139
			$this->cartes->setLargeur('190x178');
1346 jpm 140
 
141
			$nt = $this->nomCourant->getNt();
142
			$this->cartes->setId("{$this->referentiel}.nt:$nt");
143
 
1165 aurelien 144
			$url =  $this->cartes->getUrlPng();
145
		}
146
		return $url;
1026 alex 147
	}
1327 jpm 148
 
1026 alex 149
	private function getMoissonnageMiniature() {
1165 aurelien 150
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
151
		$url = null;
1346 jpm 152
		if ($projetMoissonnage != '') {
1165 aurelien 153
			$this->cartes->setProjet('moissonnage');
154
			$this->cartes->setLargeur('190');
155
			$this->cartes->setInfoReferentiel($this->referentiel);
156
			$this->cartes->setInfoNom($this->nomCourant->getNt());
157
			$url = $this->cartes->getUrlMapPng();
158
		}
159
		return $url;
1026 alex 160
	}
161
}
162
?>