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 $tailleBloc = "190x178";
|
|
|
22 |
private $serviceChorodep = null;
|
|
|
23 |
private $cartes;
|
|
|
24 |
private $meta;
|
|
|
25 |
private $appUrls;
|
1327 |
jpm |
26 |
|
1026 |
alex |
27 |
public function __construct(Conteneur $conteneur) {
|
|
|
28 |
$this->conteneur = $conteneur;
|
|
|
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() {
|
|
|
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');
|
1327 |
jpm |
63 |
$nt = $this->conteneur->getNomCourant()->getNt();
|
|
|
64 |
$referentiel = $this->conteneur->getParametre('referentiel');
|
|
|
65 |
$this->cartes->setId("$referentiel.nn:$nt");
|
1026 |
alex |
66 |
$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
|
|
|
67 |
$repartition['pngUrl'] = $this->cartes->getUrlPng();
|
|
|
68 |
$repartition['legende'] = $this->cartes->getLegendeId();
|
|
|
69 |
$this->meta->setProjet($projetRepartition);
|
|
|
70 |
$meta = $this->meta->getMetaDonnees();
|
1130 |
aurelien |
71 |
$repartition['meta'] = $meta[0];
|
1026 |
alex |
72 |
$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
|
|
|
73 |
$this->donnees['repartition'] = $repartition;
|
|
|
74 |
}
|
|
|
75 |
}
|
1327 |
jpm |
76 |
|
1026 |
alex |
77 |
private function getMoissonnage() {
|
|
|
78 |
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
|
1028 |
raphael |
79 |
if (! $projetMoissonnage) return;
|
|
|
80 |
$this->cartes->setProjet('moissonnage');
|
|
|
81 |
$this->cartes->setLargeur('600');
|
|
|
82 |
$this->cartes->setInfoNom($this->nomCourant->getNt());
|
|
|
83 |
$this->cartes->setInfoReferentiel($this->referentiel);
|
|
|
84 |
$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
|
1112 |
aurelien |
85 |
$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
|
|
|
86 |
'html' => $this->cartes->getUrlTelechargementMapHtml());
|
1028 |
raphael |
87 |
$eflore['legende'] = $this->cartes->getLegende();
|
|
|
88 |
$this->donnees['moissonnage'] = $eflore;
|
1026 |
alex |
89 |
}
|
1327 |
jpm |
90 |
|
1026 |
alex |
91 |
private function getMoissonnageExport() {
|
1028 |
raphael |
92 |
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
|
|
|
93 |
if (! $projetMoissonnage) return;
|
|
|
94 |
$this->cartes->setProjet($projetMoissonnage);
|
1026 |
alex |
95 |
$this->cartes->setLargeur('min');
|
|
|
96 |
$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
|
|
|
97 |
$eflore['min'] = $this->cartes->getUrlEflorePng();
|
|
|
98 |
$eflore['legende'] = $this->cartes->getLegende();
|
1028 |
raphael |
99 |
$this->donnees['moissonnage'] = $eflore;
|
1026 |
alex |
100 |
}
|
1327 |
jpm |
101 |
|
1217 |
aurelien |
102 |
private function getFloreProbable() {
|
1219 |
aurelien |
103 |
$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
|
1217 |
aurelien |
104 |
if (! $projetFloreProbable) return;
|
|
|
105 |
$this->cartes->setProjet($projetFloreProbable);
|
|
|
106 |
$this->meta->setProjet($projetFloreProbable);
|
|
|
107 |
$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
|
|
|
109 |
// dans ['carte']['telechargement'] par exemple
|
|
|
110 |
$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
|
1236 |
aurelien |
111 |
$this->meta->setProjet($projetFloreProbable);
|
|
|
112 |
$meta = $this->meta->getMetaDonnees();
|
|
|
113 |
$this->donnees['flore_probable']['meta'] = $meta[0];
|
1217 |
aurelien |
114 |
$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
|
|
|
115 |
$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
|
|
|
116 |
}
|
|
|
117 |
|
1026 |
alex |
118 |
public function getBloc() {
|
|
|
119 |
$donnees['chorodep'] = $this->getChorodepMiniature();
|
|
|
120 |
$donnees['eflore'] = $this->getMoissonnageMiniature();
|
1049 |
raphael |
121 |
|
|
|
122 |
// 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.
|
|
|
124 |
// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
|
|
|
125 |
if($this->referentiel == 'bdtxa') {
|
|
|
126 |
$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
|
|
|
127 |
$nns_syns = array_keys($syns['resultat']);
|
|
|
128 |
$nns_syns[] = $this->nomCourant->getNnr();
|
|
|
129 |
$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
|
|
|
130 |
'nn:'.implode(',', $nns_syns),
|
|
|
131 |
'190x178');
|
|
|
132 |
}
|
|
|
133 |
|
1026 |
alex |
134 |
return $donnees;
|
|
|
135 |
}
|
1327 |
jpm |
136 |
|
1026 |
alex |
137 |
private function getChorodepMiniature() {
|
1165 |
aurelien |
138 |
$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
|
|
|
139 |
$url = null;
|
|
|
140 |
if ($projetRepartition != "") {
|
|
|
141 |
$this->cartes->setProjet($projetRepartition);
|
|
|
142 |
$this->cartes->setProjet('chorodep');
|
|
|
143 |
$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']);
|
|
|
149 |
$nns_syns[] = $this->nomCourant->getNnr();
|
|
|
150 |
$id = 'nn:'.implode(',', $nns_syns);
|
|
|
151 |
$this->cartes->setId($id);
|
|
|
152 |
$url = $this->cartes->getUrlPng();
|
|
|
153 |
}
|
|
|
154 |
return $url;
|
1026 |
alex |
155 |
}
|
1327 |
jpm |
156 |
|
1026 |
alex |
157 |
private function getMoissonnageMiniature() {
|
1165 |
aurelien |
158 |
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
|
|
|
159 |
$url = null;
|
1180 |
aurelien |
160 |
if ($projetMoissonnage != "") {
|
1165 |
aurelien |
161 |
$this->cartes->setProjet('moissonnage');
|
|
|
162 |
$this->cartes->setLargeur('190');
|
|
|
163 |
$this->cartes->setInfoReferentiel($this->referentiel);
|
|
|
164 |
$this->cartes->setInfoNom($this->nomCourant->getNt());
|
|
|
165 |
$url = $this->cartes->getUrlMapPng();
|
|
|
166 |
}
|
|
|
167 |
return $url;
|
1026 |
alex |
168 |
}
|
|
|
169 |
}
|
|
|
170 |
?>
|