Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1028 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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() {
46
		$donnees['chorodep'] = $this->getRepartition();
47
		$donnees['eflore'] = $this->getMoissonnageExport();
48
		return $donnees;
49
	}
50
 
51
	private function getRepartition() {
52
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
53
		if ($projetRepartition != "") {
54
			$this->cartes->setProjet($projetRepartition);
55
			$this->cartes->setLargeur('630');
56
 
57
			//TODO: démochir ce code
58
			// Chargement des nn des synonymes pour obtenir une carte plus complète
59
			$noms = $this->conteneur->getApiNoms();
60
			$syns = $noms->getSynonymes($this->nomCourant->getNnr());
61
			$nns_syns = array_keys($syns['resultat']);
62
			$nns_syns[] = $this->nomCourant->getNnr();
63
			$id = 'nn:'.implode(',', $nns_syns);
64
 
65
			$this->cartes->setId($id);
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();
71
			$citation = $meta[0]['citation'];
72
			$repartition['meta']['citation'] = $citation;
73
			$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
74
			$this->donnees['repartition'] = $repartition;
75
		}
76
	}
77
 
78
	private function getMoissonnage() {
79
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
80
		if ($projetMoissonnage != "") {
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();
86
			$eflore['legende'] = $this->cartes->getLegende();
87
			$this->donnees['moissonnage'] = $eflore;
88
		}
89
	}
90
 
91
	private function getMoissonnageExport() {
92
		$this->cartes->setProjet('eflore');
93
		$this->cartes->setLargeur('min');
94
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
95
		$eflore['min'] = $this->cartes->getUrlEflorePng();
96
		$eflore['legende'] = $this->cartes->getLegende();
97
		return $eflore;
98
	}
99
 
100
	public function getBloc() {
101
		$donnees['chorodep'] = $this->getChorodepMiniature();
102
		$donnees['eflore'] = $this->getMoissonnageMiniature();
103
		return $donnees;
104
	}
105
 
106
	private function getChorodepMiniature() {
107
		$this->cartes->setProjet('chorodep');
108
		$this->cartes->setLargeur('190x178');
109
		//TODO: démochir ce code
110
		// Chargement des nn des synonymes pour obtenir une carte plus complète
111
		$noms = $this->conteneur->getApiNoms();
112
		$syns = $noms->getSynonymes($this->nomCourant->getNnr());
113
		$nns_syns = array_keys($syns['resultat']);
114
		$nns_syns[] = $this->nomCourant->getNnr();
115
		$id = 'nn:'.implode(',', $nns_syns);
116
		$this->cartes->setId($id);
117
		return $this->cartes->getUrlPng();
118
	}
119
 
120
	private function getMoissonnageMiniature() {
121
		$this->cartes->setProjet('moissonnage');
122
		$this->cartes->setLargeur('190');
123
		$this->cartes->setInfoReferentiel($this->referentiel);
124
		$this->cartes->setInfoNom($this->nomCourant->getNt());
125
		return $this->cartes->getUrlMapPng();
126
	}
127
}
128
?>