Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1217 Rev 1219
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
			
63
			
64
			//TODO: démochir ce code
64
			//TODO: démochir ce code
65
			// Chargement des nn des synonymes pour obtenir une carte plus complète
65
			// Chargement des nn des synonymes pour obtenir une carte plus complète
66
			$noms = $this->conteneur->getApiNoms();
66
			$noms = $this->conteneur->getApiNoms();
67
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
67
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
68
			$nns_syns = array_keys($syns['resultat']);
68
			$nns_syns = array_keys($syns['resultat']);
69
			$nns_syns[] = $this->nomCourant->getNnr();
69
			$nns_syns[] = $this->nomCourant->getNnr();
70
			$id = 'nn:'.implode(',', $nns_syns);
70
			$id = 'nn:'.implode(',', $nns_syns);
71
			
71
			
72
			$this->cartes->setId($id);
72
			$this->cartes->setId($id);
73
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
73
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
74
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
74
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
75
			$repartition['legende'] = $this->cartes->getLegendeId();
75
			$repartition['legende'] = $this->cartes->getLegendeId();
76
			$this->meta->setProjet($projetRepartition);
76
			$this->meta->setProjet($projetRepartition);
77
			$meta = $this->meta->getMetaDonnees();
77
			$meta = $this->meta->getMetaDonnees();
78
			$repartition['meta'] = $meta[0];
78
			$repartition['meta'] = $meta[0];
79
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
79
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
80
			$this->donnees['repartition'] = $repartition;
80
			$this->donnees['repartition'] = $repartition;
81
		}
81
		}
82
	}
82
	}
83
	
83
	
84
	private function getMoissonnage() {
84
	private function getMoissonnage() {
85
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
85
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
86
		if (! $projetMoissonnage) return;
86
		if (! $projetMoissonnage) return;
87
		$this->cartes->setProjet('moissonnage');
87
		$this->cartes->setProjet('moissonnage');
88
		$this->cartes->setLargeur('600');
88
		$this->cartes->setLargeur('600');
89
		$this->cartes->setInfoNom($this->nomCourant->getNt());
89
		$this->cartes->setInfoNom($this->nomCourant->getNt());
90
		$this->cartes->setInfoReferentiel($this->referentiel);
90
		$this->cartes->setInfoReferentiel($this->referentiel);
91
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
91
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
92
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
92
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
93
												'html' => $this->cartes->getUrlTelechargementMapHtml());
93
												'html' => $this->cartes->getUrlTelechargementMapHtml());
94
		$eflore['legende'] = $this->cartes->getLegende();
94
		$eflore['legende'] = $this->cartes->getLegende();
95
		$this->donnees['moissonnage'] = $eflore;
95
		$this->donnees['moissonnage'] = $eflore;
96
	}
96
	}
97
	
97
	
98
	private function getMoissonnageExport() {
98
	private function getMoissonnageExport() {
99
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
99
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
100
		if (! $projetMoissonnage) return;
100
		if (! $projetMoissonnage) return;
101
		$this->cartes->setProjet($projetMoissonnage);
101
		$this->cartes->setProjet($projetMoissonnage);
102
		$this->cartes->setLargeur('min');
102
		$this->cartes->setLargeur('min');
103
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
103
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
104
		$eflore['min'] = $this->cartes->getUrlEflorePng();
104
		$eflore['min'] = $this->cartes->getUrlEflorePng();
105
		$eflore['legende'] = $this->cartes->getLegende();
105
		$eflore['legende'] = $this->cartes->getLegende();
106
		$this->donnees['moissonnage'] = $eflore;
106
		$this->donnees['moissonnage'] = $eflore;
107
	}
107
	}
108
	
108
	
109
	private function getFloreProbable() {
109
	private function getFloreProbable() {
110
		$projetFloreProbable = "sophy";//Config::get($this->referentiel.'.floreProbable');
110
		$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
111
		if (! $projetFloreProbable) return;
111
		if (! $projetFloreProbable) return;
112
		$this->cartes->setProjet($projetFloreProbable);
112
		$this->cartes->setProjet($projetFloreProbable);
113
 
-
 
114
		$this->meta->setProjet($projetFloreProbable);
113
		$this->meta->setProjet($projetFloreProbable);
115
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
114
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
116
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
115
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
117
		// dans ['carte']['telechargement'] par exemple
116
		// dans ['carte']['telechargement'] par exemple
118
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
117
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
119
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
118
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
120
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
119
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
121
	}
120
	}
122
 
121
 
123
	public function getBloc() {
122
	public function getBloc() {
124
		$donnees['chorodep'] = $this->getChorodepMiniature();
123
		$donnees['chorodep'] = $this->getChorodepMiniature();
125
		$donnees['eflore'] = $this->getMoissonnageMiniature();
124
		$donnees['eflore'] = $this->getMoissonnageMiniature();
126
 
125
 
127
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
126
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
128
		// afficher la carte chorologie, et non la carte chorodep.
127
		// afficher la carte chorologie, et non la carte chorodep.
129
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
128
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
130
		if($this->referentiel == 'bdtxa') {
129
		if($this->referentiel == 'bdtxa') {
131
			$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
130
			$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
132
			$nns_syns = array_keys($syns['resultat']);
131
			$nns_syns = array_keys($syns['resultat']);
133
			$nns_syns[] = $this->nomCourant->getNnr();
132
			$nns_syns[] = $this->nomCourant->getNnr();
134
			$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
133
			$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
135
														  'nn:'.implode(',', $nns_syns),
134
														  'nn:'.implode(',', $nns_syns),
136
														  '190x178');
135
														  '190x178');
137
		}
136
		}
138
 
137
 
139
		return $donnees;
138
		return $donnees;
140
	}
139
	}
141
	
140
	
142
	private function getChorodepMiniature() {
141
	private function getChorodepMiniature() {
143
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
142
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
144
		$url = null;
143
		$url = null;
145
		if ($projetRepartition != "") {
144
		if ($projetRepartition != "") {
146
			$this->cartes->setProjet($projetRepartition);
145
			$this->cartes->setProjet($projetRepartition);
147
			$this->cartes->setProjet('chorodep');
146
			$this->cartes->setProjet('chorodep');
148
			$this->cartes->setLargeur('190x178');
147
			$this->cartes->setLargeur('190x178');
149
			//TODO: démochir ce code
148
			//TODO: démochir ce code
150
			// Chargement des nn des synonymes pour obtenir une carte plus complète
149
			// Chargement des nn des synonymes pour obtenir une carte plus complète
151
			$noms = $this->conteneur->getApiNoms();
150
			$noms = $this->conteneur->getApiNoms();
152
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
151
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
153
			$nns_syns = array_keys($syns['resultat']);
152
			$nns_syns = array_keys($syns['resultat']);
154
			$nns_syns[] = $this->nomCourant->getNnr();
153
			$nns_syns[] = $this->nomCourant->getNnr();
155
			$id = 'nn:'.implode(',', $nns_syns);
154
			$id = 'nn:'.implode(',', $nns_syns);
156
			$this->cartes->setId($id);
155
			$this->cartes->setId($id);
157
			$url =  $this->cartes->getUrlPng();
156
			$url =  $this->cartes->getUrlPng();
158
		}
157
		}
159
		return $url;
158
		return $url;
160
	}
159
	}
161
	
160
	
162
	private function getMoissonnageMiniature() {
161
	private function getMoissonnageMiniature() {
163
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
162
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
164
		$url = null;
163
		$url = null;
165
		if ($projetMoissonnage != "") {
164
		if ($projetMoissonnage != "") {
166
			$this->cartes->setProjet('moissonnage');
165
			$this->cartes->setProjet('moissonnage');
167
			$this->cartes->setLargeur('190');
166
			$this->cartes->setLargeur('190');
168
			$this->cartes->setInfoReferentiel($this->referentiel);
167
			$this->cartes->setInfoReferentiel($this->referentiel);
169
			$this->cartes->setInfoNom($this->nomCourant->getNt());
168
			$this->cartes->setInfoNom($this->nomCourant->getNt());
170
			$url = $this->cartes->getUrlMapPng();
169
			$url = $this->cartes->getUrlMapPng();
171
		}
170
		}
172
		return $url;
171
		return $url;
173
	}
172
	}
174
}
173
}
175
?>
174
?>