Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1236 | Rev 1346 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1236 Rev 1327
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
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
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Repartition extends aControleur {
15
class Repartition extends aControleur {
16
 
16
 
17
	private $conteneur = null;
17
	private $conteneur = null;
18
	private $nomCourant = null;
18
	private $nomCourant = null;
19
	private $referentiel = 'bdtfx';
19
	private $referentiel = 'bdtfx';
20
	private $donnees = array();
20
	private $donnees = array();
21
	private $tailleBloc = "190x178";
21
	private $tailleBloc = "190x178";
22
	private $serviceChorodep = null;
22
	private $serviceChorodep = null;
23
	private $cartes;
23
	private $cartes;
24
	private $meta;
24
	private $meta;
25
	private $appUrls;
25
	private $appUrls;
26
	
26
 
27
	public function __construct(Conteneur $conteneur) {
27
	public function __construct(Conteneur $conteneur) {
28
		$this->conteneur = $conteneur;
28
		$this->conteneur = $conteneur;
29
		$this->nomCourant = $this->conteneur->getNomCourant();
29
		$this->nomCourant = $this->conteneur->getNomCourant();
30
		$this->referentiel = $this->conteneur->getParametre('referentiel');
30
		$this->referentiel = $this->conteneur->getParametre('referentiel');
31
		$this->cartes = $this->conteneur->getApiCartes();
31
		$this->cartes = $this->conteneur->getApiCartes();
32
		$this->meta = $this->conteneur->getApiMetaDonnees();
32
		$this->meta = $this->conteneur->getApiMetaDonnees();
33
		$this->appUrls = $this->conteneur->getAppUrls();
33
		$this->appUrls = $this->conteneur->getAppUrls();
34
	}
34
	}
35
 
35
 
36
	public function obtenirDonnees() {
36
	public function obtenirDonnees() {
37
		$this->getRepartition();
37
		$this->getRepartition();
38
		$this->getMoissonnage();
38
		$this->getMoissonnage();
39
		$this->getFloreProbable();
39
		$this->getFloreProbable();
40
		$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
40
		$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
41
		$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
41
		$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
42
		$this->donnees['widget']['referentiel'] = $this->referentiel;
42
		$this->donnees['widget']['referentiel'] = $this->referentiel;
43
		return $this->donnees;
43
		return $this->donnees;
44
	}
44
	}
45
 
45
 
46
	public function obtenirDonneesExport() {
46
	public function obtenirDonneesExport() {
47
		$this->getRepartition();
47
		$this->getRepartition();
48
		$donnees['chorodep'] = $this->donnees['repartition'];
48
		$donnees['chorodep'] = $this->donnees['repartition'];
49
		$this->getMoissonnageExport();
49
		$this->getMoissonnageExport();
50
		// TODO: renommer l'index "eflore" en moissonnage
50
		// TODO: renommer l'index "eflore" en moissonnage
51
		// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html 
51
		// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html
52
		$donnees['eflore'] = $this->donnees['moissonnage'];
52
		$donnees['eflore'] = $this->donnees['moissonnage'];
53
		return $donnees;
53
		return $donnees;
54
	}
54
	}
55
	
55
 
56
	private function getRepartition() {
56
	private function getRepartition() {
57
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
57
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
58
		// eg: eflore ou chorodep
58
		// eg: eflore ou chorodep
59
		// cf: bdtfx.ini, bdtxa.ini
59
		// cf: bdtfx.ini, bdtxa.ini
60
		if ($projetRepartition != "") {
60
		if ($projetRepartition != '') {
61
			$this->cartes->setProjet($projetRepartition);
61
			$this->cartes->setProjet($projetRepartition);
62
			$this->cartes->setLargeur('630');
62
			$this->cartes->setLargeur('630');
63
			
-
 
64
			//TODO: démochir ce code
-
 
65
			// Chargement des nn des synonymes pour obtenir une carte plus complète
-
 
66
			$noms = $this->conteneur->getApiNoms();
63
			$nt = $this->conteneur->getNomCourant()->getNt();
67
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
-
 
68
			$nns_syns = array_keys($syns['resultat']);
-
 
69
			$nns_syns[] = $this->nomCourant->getNnr();
64
			$referentiel = $this->conteneur->getParametre('referentiel');
70
			$id = 'nn:'.implode(',', $nns_syns);
-
 
71
			
-
 
72
			$this->cartes->setId($id);
65
			$this->cartes->setId("$referentiel.nn:$nt");
73
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
66
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
74
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
67
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
75
			$repartition['legende'] = $this->cartes->getLegendeId();
68
			$repartition['legende'] = $this->cartes->getLegendeId();
76
			$this->meta->setProjet($projetRepartition);
69
			$this->meta->setProjet($projetRepartition);
77
			$meta = $this->meta->getMetaDonnees();
70
			$meta = $this->meta->getMetaDonnees();
78
			$repartition['meta'] = $meta[0];
71
			$repartition['meta'] = $meta[0];
79
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
72
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
80
			$this->donnees['repartition'] = $repartition;
73
			$this->donnees['repartition'] = $repartition;
81
		}
74
		}
82
	}
75
	}
83
	
76
 
84
	private function getMoissonnage() {
77
	private function getMoissonnage() {
85
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
78
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
86
		if (! $projetMoissonnage) return;
79
		if (! $projetMoissonnage) return;
87
		$this->cartes->setProjet('moissonnage');
80
		$this->cartes->setProjet('moissonnage');
88
		$this->cartes->setLargeur('600');
81
		$this->cartes->setLargeur('600');
89
		$this->cartes->setInfoNom($this->nomCourant->getNt());
82
		$this->cartes->setInfoNom($this->nomCourant->getNt());
90
		$this->cartes->setInfoReferentiel($this->referentiel);
83
		$this->cartes->setInfoReferentiel($this->referentiel);
91
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
84
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
92
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
85
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
93
												'html' => $this->cartes->getUrlTelechargementMapHtml());
86
												'html' => $this->cartes->getUrlTelechargementMapHtml());
94
		$eflore['legende'] = $this->cartes->getLegende();
87
		$eflore['legende'] = $this->cartes->getLegende();
95
		$this->donnees['moissonnage'] = $eflore;
88
		$this->donnees['moissonnage'] = $eflore;
96
	}
89
	}
97
	
90
 
98
	private function getMoissonnageExport() {
91
	private function getMoissonnageExport() {
99
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
92
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
100
		if (! $projetMoissonnage) return;
93
		if (! $projetMoissonnage) return;
101
		$this->cartes->setProjet($projetMoissonnage);
94
		$this->cartes->setProjet($projetMoissonnage);
102
		$this->cartes->setLargeur('min');
95
		$this->cartes->setLargeur('min');
103
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
96
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
104
		$eflore['min'] = $this->cartes->getUrlEflorePng();
97
		$eflore['min'] = $this->cartes->getUrlEflorePng();
105
		$eflore['legende'] = $this->cartes->getLegende();
98
		$eflore['legende'] = $this->cartes->getLegende();
106
		$this->donnees['moissonnage'] = $eflore;
99
		$this->donnees['moissonnage'] = $eflore;
107
	}
100
	}
108
	
101
 
109
	private function getFloreProbable() {
102
	private function getFloreProbable() {
110
		$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
103
		$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
111
		if (! $projetFloreProbable) return;
104
		if (! $projetFloreProbable) return;
112
		$this->cartes->setProjet($projetFloreProbable);
105
		$this->cartes->setProjet($projetFloreProbable);
113
		$this->meta->setProjet($projetFloreProbable);
106
		$this->meta->setProjet($projetFloreProbable);
114
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
107
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
115
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
108
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
116
		// dans ['carte']['telechargement'] par exemple
109
		// dans ['carte']['telechargement'] par exemple
117
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
110
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
118
		$this->meta->setProjet($projetFloreProbable);
111
		$this->meta->setProjet($projetFloreProbable);
119
		$meta = $this->meta->getMetaDonnees();
112
		$meta = $this->meta->getMetaDonnees();
120
		$this->donnees['flore_probable']['meta'] = $meta[0];
113
		$this->donnees['flore_probable']['meta'] = $meta[0];
121
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
114
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
122
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
115
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
123
	}
116
	}
124
 
117
 
125
	public function getBloc() {
118
	public function getBloc() {
126
		$donnees['chorodep'] = $this->getChorodepMiniature();
119
		$donnees['chorodep'] = $this->getChorodepMiniature();
127
		$donnees['eflore'] = $this->getMoissonnageMiniature();
120
		$donnees['eflore'] = $this->getMoissonnageMiniature();
128
 
121
 
129
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
122
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
130
		// afficher la carte chorologie, et non la carte chorodep.
123
		// afficher la carte chorologie, et non la carte chorodep.
131
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
124
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
132
		if($this->referentiel == 'bdtxa') {
125
		if($this->referentiel == 'bdtxa') {
133
			$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
126
			$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
134
			$nns_syns = array_keys($syns['resultat']);
127
			$nns_syns = array_keys($syns['resultat']);
135
			$nns_syns[] = $this->nomCourant->getNnr();
128
			$nns_syns[] = $this->nomCourant->getNnr();
136
			$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
129
			$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
137
														  'nn:'.implode(',', $nns_syns),
130
														  'nn:'.implode(',', $nns_syns),
138
														  '190x178');
131
														  '190x178');
139
		}
132
		}
140
 
133
 
141
		return $donnees;
134
		return $donnees;
142
	}
135
	}
143
	
136
 
144
	private function getChorodepMiniature() {
137
	private function getChorodepMiniature() {
145
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
138
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
146
		$url = null;
139
		$url = null;
147
		if ($projetRepartition != "") {
140
		if ($projetRepartition != "") {
148
			$this->cartes->setProjet($projetRepartition);
141
			$this->cartes->setProjet($projetRepartition);
149
			$this->cartes->setProjet('chorodep');
142
			$this->cartes->setProjet('chorodep');
150
			$this->cartes->setLargeur('190x178');
143
			$this->cartes->setLargeur('190x178');
151
			//TODO: démochir ce code
144
			//TODO: démochir ce code
152
			// Chargement des nn des synonymes pour obtenir une carte plus complète
145
			// Chargement des nn des synonymes pour obtenir une carte plus complète
153
			$noms = $this->conteneur->getApiNoms();
146
			$noms = $this->conteneur->getApiNoms();
154
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
147
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
155
			$nns_syns = array_keys($syns['resultat']);
148
			$nns_syns = array_keys($syns['resultat']);
156
			$nns_syns[] = $this->nomCourant->getNnr();
149
			$nns_syns[] = $this->nomCourant->getNnr();
157
			$id = 'nn:'.implode(',', $nns_syns);
150
			$id = 'nn:'.implode(',', $nns_syns);
158
			$this->cartes->setId($id);
151
			$this->cartes->setId($id);
159
			$url =  $this->cartes->getUrlPng();
152
			$url =  $this->cartes->getUrlPng();
160
		}
153
		}
161
		return $url;
154
		return $url;
162
	}
155
	}
163
	
156
 
164
	private function getMoissonnageMiniature() {
157
	private function getMoissonnageMiniature() {
165
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
158
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
166
		$url = null;
159
		$url = null;
167
		if ($projetMoissonnage != "") {
160
		if ($projetMoissonnage != "") {
168
			$this->cartes->setProjet('moissonnage');
161
			$this->cartes->setProjet('moissonnage');
169
			$this->cartes->setLargeur('190');
162
			$this->cartes->setLargeur('190');
170
			$this->cartes->setInfoReferentiel($this->referentiel);
163
			$this->cartes->setInfoReferentiel($this->referentiel);
171
			$this->cartes->setInfoNom($this->nomCourant->getNt());
164
			$this->cartes->setInfoNom($this->nomCourant->getNt());
172
			$url = $this->cartes->getUrlMapPng();
165
			$url = $this->cartes->getUrlMapPng();
173
		}
166
		}
174
		return $url;
167
		return $url;
175
	}
168
	}
176
}
169
}
177
?>
170
?>