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