Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1327 Rev 1346
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";
-
 
22
	private $serviceChorodep = null;
-
 
23
	private $cartes;
21
	private $cartes;
24
	private $meta;
22
	private $meta;
25
	private $appUrls;
23
	private $appUrls;
26
 
24
 
27
	public function __construct(Conteneur $conteneur) {
25
	public function __construct(Conteneur $conteneur) {
28
		$this->conteneur = $conteneur;
26
		$this->conteneur = $conteneur;
29
		$this->nomCourant = $this->conteneur->getNomCourant();
27
		$this->nomCourant = $this->conteneur->getNomCourant();
30
		$this->referentiel = $this->conteneur->getParametre('referentiel');
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
31
		$this->cartes = $this->conteneur->getApiCartes();
29
		$this->cartes = $this->conteneur->getApiCartes();
32
		$this->meta = $this->conteneur->getApiMetaDonnees();
30
		$this->meta = $this->conteneur->getApiMetaDonnees();
33
		$this->appUrls = $this->conteneur->getAppUrls();
31
		$this->appUrls = $this->conteneur->getAppUrls();
34
	}
32
	}
35
 
33
 
36
	public function obtenirDonnees() {
34
	public function obtenirDonnees() {
37
		$this->getRepartition();
35
		$this->getRepartition();
38
		$this->getMoissonnage();
36
		$this->getMoissonnage();
39
		$this->getFloreProbable();
37
		$this->getFloreProbable();
40
		$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
38
		$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
41
		$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
39
		$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
42
		$this->donnees['widget']['referentiel'] = $this->referentiel;
40
		$this->donnees['widget']['referentiel'] = $this->referentiel;
43
		return $this->donnees;
41
		return $this->donnees;
44
	}
42
	}
45
 
43
 
46
	public function obtenirDonneesExport() {
44
	public function obtenirDonneesExport() {
47
		$this->getRepartition();
45
		$this->getRepartition();
48
		$donnees['chorodep'] = $this->donnees['repartition'];
46
		$donnees['chorodep'] = $this->donnees['repartition'];
49
		$this->getMoissonnageExport();
47
		$this->getMoissonnageExport();
50
		// TODO: renommer l'index "eflore" en moissonnage
48
		// TODO: renommer l'index "eflore" en moissonnage
51
		// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html
49
		// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html
52
		$donnees['eflore'] = $this->donnees['moissonnage'];
50
		$donnees['eflore'] = $this->donnees['moissonnage'];
53
		return $donnees;
51
		return $donnees;
54
	}
52
	}
55
 
53
 
56
	private function getRepartition() {
54
	private function getRepartition() {
57
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
55
		$projetRepartition = Config::get("{$this->referentiel}.baseRepartition");
58
		// eg: eflore ou chorodep
56
		// eg: eflore ou chorodep
59
		// cf: bdtfx.ini, bdtxa.ini
57
		// cf: bdtfx.ini, bdtxa.ini
60
		if ($projetRepartition != '') {
58
		if ($projetRepartition != '') {
61
			$this->cartes->setProjet($projetRepartition);
59
			$this->cartes->setProjet($projetRepartition);
62
			$this->cartes->setLargeur('630');
60
			$this->cartes->setLargeur('630');
63
			$nt = $this->conteneur->getNomCourant()->getNt();
61
			$nt = $this->nomCourant->getNt();
64
			$referentiel = $this->conteneur->getParametre('referentiel');
-
 
65
			$this->cartes->setId("$referentiel.nn:$nt");
62
			$this->cartes->setId("{$this->referentiel}.nt:$nt");
66
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
63
			$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
67
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
64
			$repartition['pngUrl'] = $this->cartes->getUrlPng();
68
			$repartition['legende'] = $this->cartes->getLegendeId();
65
			$repartition['legende'] = $this->cartes->getLegendeId();
69
			$this->meta->setProjet($projetRepartition);
66
			$this->meta->setProjet($projetRepartition);
70
			$meta = $this->meta->getMetaDonnees();
67
			$meta = $this->meta->getMetaDonnees();
71
			$repartition['meta'] = $meta[0];
68
			$repartition['meta'] = $meta[0];
72
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
69
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
73
			$this->donnees['repartition'] = $repartition;
70
			$this->donnees['repartition'] = $repartition;
74
		}
71
		}
75
	}
72
	}
76
 
73
 
77
	private function getMoissonnage() {
74
	private function getMoissonnage() {
78
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
75
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
79
		if (! $projetMoissonnage) return;
76
		if (! $projetMoissonnage) return;
80
		$this->cartes->setProjet('moissonnage');
77
		$this->cartes->setProjet('moissonnage');
81
		$this->cartes->setLargeur('600');
78
		$this->cartes->setLargeur('600');
82
		$this->cartes->setInfoNom($this->nomCourant->getNt());
79
		$this->cartes->setInfoNom($this->nomCourant->getNt());
83
		$this->cartes->setInfoReferentiel($this->referentiel);
80
		$this->cartes->setInfoReferentiel($this->referentiel);
84
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
81
		$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
85
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
82
		$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
86
												'html' => $this->cartes->getUrlTelechargementMapHtml());
83
												'html' => $this->cartes->getUrlTelechargementMapHtml());
87
		$eflore['legende'] = $this->cartes->getLegende();
84
		$eflore['legende'] = $this->cartes->getLegende();
88
		$this->donnees['moissonnage'] = $eflore;
85
		$this->donnees['moissonnage'] = $eflore;
89
	}
86
	}
90
 
87
 
91
	private function getMoissonnageExport() {
88
	private function getMoissonnageExport() {
92
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
89
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
93
		if (! $projetMoissonnage) return;
90
		if (! $projetMoissonnage) return;
94
		$this->cartes->setProjet($projetMoissonnage);
91
		$this->cartes->setProjet($projetMoissonnage);
95
		$this->cartes->setLargeur('min');
92
		$this->cartes->setLargeur('min');
96
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
93
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
97
		$eflore['min'] = $this->cartes->getUrlEflorePng();
94
		$eflore['min'] = $this->cartes->getUrlEflorePng();
98
		$eflore['legende'] = $this->cartes->getLegende();
95
		$eflore['legende'] = $this->cartes->getLegende();
99
		$this->donnees['moissonnage'] = $eflore;
96
		$this->donnees['moissonnage'] = $eflore;
100
	}
97
	}
101
 
98
 
102
	private function getFloreProbable() {
99
	private function getFloreProbable() {
103
		$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
100
		$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
104
		if (! $projetFloreProbable) return;
101
		if (! $projetFloreProbable) return;
105
		$this->cartes->setProjet($projetFloreProbable);
102
		$this->cartes->setProjet($projetFloreProbable);
106
		$this->meta->setProjet($projetFloreProbable);
103
		$this->meta->setProjet($projetFloreProbable);
107
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
104
		$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
108
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
105
		// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
109
		// dans ['carte']['telechargement'] par exemple
106
		// dans ['carte']['telechargement'] par exemple
110
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
107
		$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
111
		$this->meta->setProjet($projetFloreProbable);
108
		$this->meta->setProjet($projetFloreProbable);
112
		$meta = $this->meta->getMetaDonnees();
109
		$meta = $this->meta->getMetaDonnees();
113
		$this->donnees['flore_probable']['meta'] = $meta[0];
110
		$this->donnees['flore_probable']['meta'] = $meta[0];
114
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
111
		$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
115
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
112
		$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
116
	}
113
	}
117
 
114
 
118
	public function getBloc() {
115
	public function getBloc() {
119
		$donnees['chorodep'] = $this->getChorodepMiniature();
116
		$donnees['chorodep'] = $this->getChorodepMiniature();
120
		$donnees['eflore'] = $this->getMoissonnageMiniature();
117
		$donnees['eflore'] = $this->getMoissonnageMiniature();
121
 
118
 
122
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
119
		// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
123
		// afficher la carte chorologie, et non la carte chorodep.
120
		// afficher la carte chorologie, et non la carte chorodep.
124
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
121
		// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
125
		if($this->referentiel == 'bdtxa') {
122
		if ($this->referentiel == 'bdtxa') {
126
			$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
123
			$nt = $this->nomCourant->getNt();
127
			$nns_syns = array_keys($syns['resultat']);
124
			$idCarte = "{$this->referentiel}.nt:$nt";
128
			$nns_syns[] = $this->nomCourant->getNnr();
125
			$urlCarte = Config::get("{$this->referentiel}.baseRepartition");
-
 
126
 
129
			$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
127
			$donnees['chorodep'] = Cartes::getCarteUrlPng($urlCarte, $idCarte, '190x178');
130
														  'nn:'.implode(',', $nns_syns),
-
 
131
														  '190x178');
-
 
132
		}
128
		}
133
 
129
 
134
		return $donnees;
130
		return $donnees;
135
	}
131
	}
136
 
132
 
137
	private function getChorodepMiniature() {
133
	private function getChorodepMiniature() {
138
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
134
		$projetRepartition = Config::get("{$this->referentiel}.baseRepartition");
139
		$url = null;
135
		$url = null;
140
		if ($projetRepartition != "") {
136
		if ($projetRepartition != '') {
141
			$this->cartes->setProjet($projetRepartition);
137
			$this->cartes->setProjet($projetRepartition);
142
			$this->cartes->setProjet('chorodep');
138
			$this->cartes->setProjet('chorodep');
143
			$this->cartes->setLargeur('190x178');
139
			$this->cartes->setLargeur('190x178');
144
			//TODO: démochir ce code
-
 
145
			// Chargement des nn des synonymes pour obtenir une carte plus complète
-
 
146
			$noms = $this->conteneur->getApiNoms();
-
 
147
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
-
 
148
			$nns_syns = array_keys($syns['resultat']);
-
 
-
 
140
 
149
			$nns_syns[] = $this->nomCourant->getNnr();
141
			$nt = $this->nomCourant->getNt();
150
			$id = 'nn:'.implode(',', $nns_syns);
-
 
151
			$this->cartes->setId($id);
142
			$this->cartes->setId("{$this->referentiel}.nt:$nt");
-
 
143
 
152
			$url =  $this->cartes->getUrlPng();
144
			$url =  $this->cartes->getUrlPng();
153
		}
145
		}
154
		return $url;
146
		return $url;
155
	}
147
	}
156
 
148
 
157
	private function getMoissonnageMiniature() {
149
	private function getMoissonnageMiniature() {
158
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
150
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
159
		$url = null;
151
		$url = null;
160
		if ($projetMoissonnage != "") {
152
		if ($projetMoissonnage != '') {
161
			$this->cartes->setProjet('moissonnage');
153
			$this->cartes->setProjet('moissonnage');
162
			$this->cartes->setLargeur('190');
154
			$this->cartes->setLargeur('190');
163
			$this->cartes->setInfoReferentiel($this->referentiel);
155
			$this->cartes->setInfoReferentiel($this->referentiel);
164
			$this->cartes->setInfoNom($this->nomCourant->getNt());
156
			$this->cartes->setInfoNom($this->nomCourant->getNt());
165
			$url = $this->cartes->getUrlMapPng();
157
			$url = $this->cartes->getUrlMapPng();
166
		}
158
		}
167
		return $url;
159
		return $url;
168
	}
160
	}
169
}
161
}
170
?>
162
?>