Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
253 gduche 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 {
291 jpm 16
 
17
	private $conteneur = null;
294 delphine 18
	private $nomCourant = null;
952 delphine 19
	private $referentiel = 'bdtfx';
20
	private $donnees = array();
291 jpm 21
	private $tailleBloc = "190x178";
257 delphine 22
	private $serviceChorodep = null;
346 gduche 23
	private $cartes;
24
	private $meta;
25
	private $appUrls;
26
 
291 jpm 27
	public function __construct(Conteneur $conteneur) {
28
		$this->conteneur = $conteneur;
294 delphine 29
		$this->nomCourant = $this->conteneur->getNomCourant();
952 delphine 30
		$this->referentiel = $this->conteneur->getParametre('referentiel');
291 jpm 31
		$this->cartes = $this->conteneur->getApiCartes();
32
		$this->meta = $this->conteneur->getApiMetaDonnees();
33
		$this->appUrls = $this->conteneur->getAppUrls();
276 gduche 34
	}
291 jpm 35
 
36
	public function obtenirDonnees() {
952 delphine 37
		$this->getRepartition();
38
		$this->getMoissonnage();
39
		$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
40
		$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
963 aurelien 41
		$this->donnees['widget']['referentiel'] = $this->referentiel;
952 delphine 42
		return $this->donnees;
269 delphine 43
	}
291 jpm 44
 
697 mathilde 45
	public function obtenirDonneesExport() {
952 delphine 46
		$donnees['chorodep'] = $this->getRepartition();
47
		$donnees['eflore'] = $this->getMoissonnageExport();
697 mathilde 48
		return $donnees;
49
	}
50
 
952 delphine 51
	private function getRepartition() {
52
		$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
53
		if ($projetRepartition != "") {
54
			$this->cartes->setProjet($projetRepartition);
55
			$this->cartes->setLargeur('630');
963 aurelien 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
 
952 delphine 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
		}
253 gduche 76
	}
361 delphine 77
 
952 delphine 78
	private function getMoissonnage() {
79
		$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
80
		if ($projetMoissonnage != "") {
81
			$this->cartes->setProjet('eflore');
82
			$this->cartes->setLargeur('max');
83
			$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
84
			$eflore['mapUrl'] = $this->cartes->getUrlMap();
85
			$eflore['legende'] = $this->cartes->getLegende();
86
			$this->donnees['moissonnage'] = $eflore;
87
		}
361 delphine 88
	}
697 mathilde 89
 
952 delphine 90
	private function getMoissonnageExport() {
697 mathilde 91
		$this->cartes->setProjet('eflore');
92
		$this->cartes->setLargeur('min');
93
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
94
		$eflore['min'] = $this->cartes->getUrlEflorePng();
95
		$eflore['legende'] = $this->cartes->getLegende();
96
		return $eflore;
97
	}
291 jpm 98
 
99
	public function getBloc() {
422 delphine 100
		$donnees['chorodep'] = $this->getChorodepMiniature();
441 delphine 101
		$donnees['eflore'] = $this->getEfloreMiniature();
422 delphine 102
		return $donnees;
103
	}
104
 
105
	private function getChorodepMiniature() {
291 jpm 106
		$this->cartes->setProjet('chorodep');
107
		$this->cartes->setLargeur('190x178');
963 aurelien 108
		//TODO: démochir ce code
109
		// Chargement des nn des synonymes pour obtenir une carte plus complète
110
		$noms = $this->conteneur->getApiNoms();
111
		$syns = $noms->getSynonymes($this->nomCourant->getNnr());
112
		$nns_syns = array_keys($syns['resultat']);
113
		$nns_syns[] = $this->nomCourant->getNnr();
114
		$id = 'nn:'.implode(',', $nns_syns);
291 jpm 115
		$this->cartes->setId($id);
422 delphine 116
		return $this->cartes->getUrlPng();
263 gduche 117
	}
422 delphine 118
 
119
	private function getEfloreMiniature() {
120
		$this->cartes->setProjet('eflore');
121
		$this->cartes->setLargeur('min');
122
		$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
441 delphine 123
		return $this->cartes->getUrlEflorePng();
422 delphine 124
	}
253 gduche 125
}
126
?>