Rev 963 | Blame | Last modification | View Log | RSS feed
<?php
// declare(encoding='UTF-8');
/**
* Classe mère du module Liste.
*
* @category PHP 5.2
* @package eflore-consultation
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
* @copyright 2011 Tela-Botanica
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
* @version $Id$
*/
class Repartition extends aControleur {
private $conteneur = null;
private $nomCourant = null;
private $referentiel = 'bdtfx';
private $donnees = array();
private $tailleBloc = "190x178";
private $serviceChorodep = null;
private $cartes;
private $meta;
private $appUrls;
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
$this->referentiel = $this->conteneur->getParametre('referentiel');
$this->cartes = $this->conteneur->getApiCartes();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->appUrls = $this->conteneur->getAppUrls();
}
public function obtenirDonnees() {
$this->getRepartition();
$this->getMoissonnage();
$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
$this->donnees['widget']['referentiel'] = $this->referentiel;
return $this->donnees;
}
public function obtenirDonneesExport() {
$donnees['chorodep'] = $this->getRepartition();
$donnees['eflore'] = $this->getMoissonnageExport();
return $donnees;
}
private function getRepartition() {
$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
if ($projetRepartition != "") {
$this->cartes->setProjet($projetRepartition);
$this->cartes->setLargeur('630');
//TODO: démochir ce code
// Chargement des nn des synonymes pour obtenir une carte plus complète
$noms = $this->conteneur->getApiNoms();
$syns = $noms->getSynonymes($this->nomCourant->getNnr());
$nns_syns = array_keys($syns['resultat']);
$nns_syns[] = $this->nomCourant->getNnr();
$id = 'nn:'.implode(',', $nns_syns);
$this->cartes->setId($id);
$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
$repartition['pngUrl'] = $this->cartes->getUrlPng();
$repartition['legende'] = $this->cartes->getLegendeId();
$this->meta->setProjet($projetRepartition);
$meta = $this->meta->getMetaDonnees();
$citation = $meta[0]['citation'];
$repartition['meta']['citation'] = $citation;
$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
$this->donnees['repartition'] = $repartition;
}
}
private function getMoissonnage() {
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
if ($projetMoissonnage != "") {
$this->cartes->setProjet('eflore');
$this->cartes->setLargeur('max');
$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
$eflore['mapUrl'] = $this->cartes->getUrlMap();
$eflore['legende'] = $this->cartes->getLegende();
$this->donnees['moissonnage'] = $eflore;
}
}
private function getMoissonnageExport() {
$this->cartes->setProjet('eflore');
$this->cartes->setLargeur('min');
$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
$eflore['min'] = $this->cartes->getUrlEflorePng();
$eflore['legende'] = $this->cartes->getLegende();
return $eflore;
}
public function getBloc() {
$donnees['chorodep'] = $this->getChorodepMiniature();
$donnees['eflore'] = $this->getEfloreMiniature();
return $donnees;
}
private function getChorodepMiniature() {
$projetRepartition = Config::get($this->referentiel.'.baseRepartition');
$url = "";
if ($projetRepartition != "") {
$this->cartes->setProjet($projetRepartition);
$this->cartes->setLargeur('190x178');
//TODO: démochir ce code
// Chargement des nn des synonymes pour obtenir une carte plus complète
$noms = $this->conteneur->getApiNoms();
$syns = $noms->getSynonymes($this->nomCourant->getNnr());
$nns_syns = array_keys($syns['resultat']);
$nns_syns[] = $this->nomCourant->getNnr();
$id = 'nn:'.implode(',', $nns_syns);
$this->cartes->setId($id);
$url = $this->cartes->getUrlPng();
}
return $url;
}
private function getEfloreMiniature() {
$this->cartes->setProjet('eflore');
$this->cartes->setLargeur('min');
$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
return $this->cartes->getUrlEflorePng();
}
}
?>