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;
|
|
|
26 |
|
|
|
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();
|
|
|
39 |
$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
|
|
|
40 |
$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
|
|
|
41 |
$this->donnees['widget']['referentiel'] = $this->referentiel;
|
|
|
42 |
return $this->donnees;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public function obtenirDonneesExport() {
|
1028 |
raphael |
46 |
$this->getRepartition();
|
|
|
47 |
$donnees['chorodep'] = $this->donnees['repartition'];
|
|
|
48 |
$this->getMoissonnageExport();
|
|
|
49 |
// TODO: renommer l'index "eflore" en moissonnage
|
|
|
50 |
// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html
|
|
|
51 |
$donnees['eflore'] = $this->donnees['moissonnage'];
|
1026 |
alex |
52 |
return $donnees;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
private function getRepartition() {
|
|
|
56 |
$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
|
1028 |
raphael |
57 |
// eg: eflore ou chorodep
|
|
|
58 |
// cf: bdtfx.ini, bdtxa.ini
|
1026 |
alex |
59 |
if ($projetRepartition != "") {
|
|
|
60 |
$this->cartes->setProjet($projetRepartition);
|
|
|
61 |
$this->cartes->setLargeur('630');
|
|
|
62 |
|
|
|
63 |
//TODO: démochir ce code
|
|
|
64 |
// Chargement des nn des synonymes pour obtenir une carte plus complète
|
|
|
65 |
$noms = $this->conteneur->getApiNoms();
|
|
|
66 |
$syns = $noms->getSynonymes($this->nomCourant->getNnr());
|
|
|
67 |
$nns_syns = array_keys($syns['resultat']);
|
|
|
68 |
$nns_syns[] = $this->nomCourant->getNnr();
|
|
|
69 |
$id = 'nn:'.implode(',', $nns_syns);
|
|
|
70 |
|
|
|
71 |
$this->cartes->setId($id);
|
|
|
72 |
$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
|
|
|
73 |
$repartition['pngUrl'] = $this->cartes->getUrlPng();
|
|
|
74 |
$repartition['legende'] = $this->cartes->getLegendeId();
|
|
|
75 |
$this->meta->setProjet($projetRepartition);
|
|
|
76 |
$meta = $this->meta->getMetaDonnees();
|
|
|
77 |
$citation = $meta[0]['citation'];
|
|
|
78 |
$repartition['meta']['citation'] = $citation;
|
|
|
79 |
$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
|
|
|
80 |
$this->donnees['repartition'] = $repartition;
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
private function getMoissonnage() {
|
|
|
85 |
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
|
1028 |
raphael |
86 |
if (! $projetMoissonnage) return;
|
|
|
87 |
$this->cartes->setProjet('moissonnage');
|
|
|
88 |
$this->cartes->setLargeur('600');
|
|
|
89 |
$this->cartes->setInfoNom($this->nomCourant->getNt());
|
|
|
90 |
$this->cartes->setInfoReferentiel($this->referentiel);
|
|
|
91 |
$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
|
1112 |
aurelien |
92 |
$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
|
|
|
93 |
'html' => $this->cartes->getUrlTelechargementMapHtml());
|
1028 |
raphael |
94 |
$eflore['legende'] = $this->cartes->getLegende();
|
|
|
95 |
$this->donnees['moissonnage'] = $eflore;
|
1026 |
alex |
96 |
}
|
|
|
97 |
|
|
|
98 |
private function getMoissonnageExport() {
|
1028 |
raphael |
99 |
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
|
|
|
100 |
if (! $projetMoissonnage) return;
|
|
|
101 |
$this->cartes->setProjet($projetMoissonnage);
|
1026 |
alex |
102 |
$this->cartes->setLargeur('min');
|
|
|
103 |
$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
|
|
|
104 |
$eflore['min'] = $this->cartes->getUrlEflorePng();
|
|
|
105 |
$eflore['legende'] = $this->cartes->getLegende();
|
1028 |
raphael |
106 |
$this->donnees['moissonnage'] = $eflore;
|
1026 |
alex |
107 |
}
|
|
|
108 |
|
|
|
109 |
public function getBloc() {
|
|
|
110 |
$donnees['chorodep'] = $this->getChorodepMiniature();
|
|
|
111 |
$donnees['eflore'] = $this->getMoissonnageMiniature();
|
1049 |
raphael |
112 |
|
|
|
113 |
// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
|
|
|
114 |
// afficher la carte chorologie, et non la carte chorodep.
|
|
|
115 |
// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
|
|
|
116 |
if($this->referentiel == 'bdtxa') {
|
|
|
117 |
$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr());
|
|
|
118 |
$nns_syns = array_keys($syns['resultat']);
|
|
|
119 |
$nns_syns[] = $this->nomCourant->getNnr();
|
|
|
120 |
$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'),
|
|
|
121 |
'nn:'.implode(',', $nns_syns),
|
|
|
122 |
'190x178');
|
|
|
123 |
}
|
|
|
124 |
|
1026 |
alex |
125 |
return $donnees;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
private function getChorodepMiniature() {
|
|
|
129 |
$this->cartes->setProjet('chorodep');
|
|
|
130 |
$this->cartes->setLargeur('190x178');
|
|
|
131 |
//TODO: démochir ce code
|
|
|
132 |
// Chargement des nn des synonymes pour obtenir une carte plus complète
|
|
|
133 |
$noms = $this->conteneur->getApiNoms();
|
|
|
134 |
$syns = $noms->getSynonymes($this->nomCourant->getNnr());
|
|
|
135 |
$nns_syns = array_keys($syns['resultat']);
|
|
|
136 |
$nns_syns[] = $this->nomCourant->getNnr();
|
|
|
137 |
$id = 'nn:'.implode(',', $nns_syns);
|
|
|
138 |
$this->cartes->setId($id);
|
|
|
139 |
return $this->cartes->getUrlPng();
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
private function getMoissonnageMiniature() {
|
|
|
143 |
$this->cartes->setProjet('moissonnage');
|
|
|
144 |
$this->cartes->setLargeur('190');
|
|
|
145 |
$this->cartes->setInfoReferentiel($this->referentiel);
|
|
|
146 |
$this->cartes->setInfoNom($this->nomCourant->getNt());
|
|
|
147 |
return $this->cartes->getUrlMapPng();
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
?>
|