Rev 1130 | Blame | Compare with Previous | 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>
* @author Mathilde Salthun-lassalle <mathilde@tela-botanica.org>
* @author Raphaël Droz <raphael@tela-botanica.org>
* @copyright 2011, 2013 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
* @used by modules/pdf_export/PdfExport.php::initialiser()
* @used by modules/fiche/formateurs/Synthese.php::obtenirDonnees()
*/
class Ecologie extends aControleur {
private $referentiel = 'bdtfx';
private $donnees = array();
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
$this->referentiel = $this->conteneur->getParametre('referentiel');
$this->informations = $this->conteneur->getApiInformations();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->wikini = $this->conteneur->getApiWikini();
$this->appUrls = $this->conteneur->getAppUrls();
$this->graphique = $this->conteneur->getApiGraphiques();
$this->syntaxons = $this->conteneur->getApiSyntaxons();
parent::__construct();
}
public function obtenirDonnees() {
$donnees = array();
$this->getWikini();
$this->getBaseflor();
$this->getBaseveg();
$this->donnees['urls'] = $this->appUrls;
return $this->donnees;
}
public function obtenirDonneesExport() {
$donnees['wikini'] = $this->getWikini();
$donnees['baseflor'] = $this->getBaseflorExport();
$donnees['baseveg'] = $this->getBaseveg();
return $donnees;
}
public function getBaseflorCatminat($depart, $limite) {
$baseflorCatminat = array();
$this->informations->setProjet('baseflor');
$this->informations->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations->setNum_nom($this->nomCourant->getNnr());
$this->informations->setDepart($depart);
$this->informations->setLimite($limite);
$informations = $this->informations->getInformationsRelationCatminat();
if($informations != ""){
$baseflorCatminat['catminat'] = $informations['resultat'][0]['catminat_code'];
$baseflorCatminat['lien-liste-fancy'] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$baseflorCatminat['catminat']);
} else {
$baseflorCatminat['aucune'] = 'Aucune donnée';
}
return $baseflorCatminat;
}
private function getBaseveg() {
if (Config::get($this->referentiel.'.basePhytosocio') != "") {
$baseveg = array();
$baseflor = $this->getBaseflorCatminat(0,500);
$baseveg['baseflor'] = $baseflor;
if (isset($baseflor['catminat'])) {
$this->syntaxons->setProjet('baseveg');
$catminat = str_replace('/','-',$baseflor['catminat']);
$this->syntaxons->setCatminat($catminat);
$syntaxonsSup = $this->syntaxons->getSyntaxonsSuperieurs();
$baseveg['syntaxons-sup'] = $syntaxonsSup['resultat'];
$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
$baseveg['syntaxon-courant'] = $syntaxonsCourant['resultat'];
foreach ($baseveg['syntaxons-sup'] as $cle => $valeurs) {
$catminat_sup = str_replace('/','-',$valeurs['code_catminat']);
$baseveg['synonymes']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
$baseveg['ref']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
$baseveg['taxons']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons_sup',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
}
$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
$this->meta->setProjet('baseveg');
$meta = $this->meta->getMetaDonnees();
$baseveg['meta'] = $meta[0];
$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
}else {
$baseveg['aucune'] = 'Aucune donnée';
}
$this->donnees['baseveg'] = $baseveg;
}
}
private function getBasevegSyntaxonCourant() {
$baseveg = array();
$baseflor = $this->getBaseflorCatminat(0,500);
if (isset($baseflor['catminat'])) {
$this->syntaxons->setProjet('baseveg');
$catminat = str_replace('/','-',$baseflor['catminat']);
$this->syntaxons->setCatminat($catminat);
$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
$baseveg['description'] = $syntaxonsCourant['resultat'];
}
return $baseveg;
}
private function getWikini() {
$wikini = array();
$wikini['titre'] = 'Wikini';
$referentiel = $this->conteneur->getParametre('referentiel');
$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
$wikini['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
$this->donnees['wikini'] = $wikini;
}
public function getBloc() {
$donnees = array();
$this->getBaseflor(false);
$this->donnees['graph'] = $this->donnees['baseflor'];
$this->donnees['graph']['titre'] = 'Optimum écologique';
$this->donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
return $this->donnees;
}
private function getBaseflorExport() {
$baseflor = array();
$this->informations ->setProjet('baseflor');
$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations ->setNum_nom($this->nomCourant->getNnr());
$informations = $this->informations->getInformationsEcologie();
if(is_array($informations)){
$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
$this->graphique -> setProjet('baseflor');
$baseflor['legende_eco'] = $this->urls->obtenirUrlBaseDossier() . Config::get('dossier_images') . '/legende_formes.png';
$this->meta->setProjet('baseflor');
$meta = $this->meta->getMetaDonnees();
$baseflor['meta']= $meta[0];
}else {
$baseflor['aucune'] = 'Aucune donnée';
}
return $baseflor;
}
private function getBaseflor($inclure_legende = true) {
if (Config::get($this->referentiel.'.baseEcologie')) {
$referentiel = $this->conteneur->getParametre('referentiel');
$num_nom = $this->nomCourant->getNnr();
// TODO: unserialize() pourrait aussi légitimement retourner FALSE
$cache = unserialize($this->conteneur->getCache()->charger('baseflor/graphique/'.$referentiel.'_'.$num_nom));
if($cache) {
$baseflor = $cache;
$this->graphique ->setProjet('baseflor');
$graphique = $this->graphique->getLegendeGraphique();
$baseflor['legende'] = $graphique ;
} else {
$baseflor = array();
$this->informations ->setProjet('baseflor');
$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations ->setNum_nom($this->nomCourant->getNnr());
$informations = $this->informations->getInformationsEcologie();
if(is_array($informations)){
if (isset($informations['graphique_climat'])) {
$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
$baseflor['description']['climat_url_png'] = $informations['graphique_climat']['href']."?retour.format=420&retour=image/png";
}
if (isset($informations['graphique_sol'])) {
$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
$baseflor['description']['sol_url_png'] = $informations['graphique_sol']['href']."?retour.format=420&retour=image/png";
}
if($inclure_legende) {
$this->graphique ->setProjet('baseflor');
$graphique = $this->graphique->getLegendeGraphique();
$baseflor['legende'] = $graphique ;
}
$this->meta->setProjet('baseflor');
$meta = $this->meta->getMetaDonnees();
$baseflor['meta'] = $meta[0];
$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
$this->conteneur->getCache()->sauver(serialize($baseflor),
'baseflor/graphique/'.$referentiel.'_'.$num_nom);
} else {
$baseflor['aucune'] = 'Aucune donnée';
}
}
$this->donnees['baseflor'] = $baseflor;
}
}
}
?>