* @author Delphine CAUQUIL * @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 Illustrations extends aControleur { private $conteneur = null; private $nomCourant = null; private $images = null; private $appUrls = null; private $meta = null; 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->images = $this->conteneur->getApiImages(); $this->appUrls = $this->conteneur->getAppUrls(); $this->meta = $this->conteneur->getApiMetaDonnees(); $this->images->setApi(Images::API_DEL); } public function getDonnees() { $this->donnees = array(); $this->getPhotos(); $dessin = $this->addDessin(); if (!empty($dessin)) { array_push($this->donnees, $dessin); } return $this->donnees; } public function getPhotos() { $listePhotos = $this->images->getInfosImagesGalerieMobile($this->nomCourant->getNnr()); foreach($listePhotos as $index) { $this->formaterListePhotos($index); } } private function formaterListePhotos($images) { $infosImg['src'] = $images['binaire.href']; $obs = $images['observation']; if ($obs['auteur.nom'] != '') { $infosImg['legende']['titre'] = $obs['auteur.nom']; if ($obs['auteur.prenom'] != '') { $infosImg['legende']['titre'] .= ' '.$obs['auteur.prenom']; } } else { $infosImg['legende']['titre'] = "Anonyme"; } if ($obs['date_observation'] != '') { $infosImg['legende']['titre'] .= ", le ".$this->formaterDateImg($obs['date_observation']); } if ($obs['zone_geo'] != '') { $infosImg['legende']['texte'] = $obs['zone_geo']; if ($obs['lieudit'] != '') { $infosImg['legende']['texte'] .= ' ('.$obs['lieudit'].')'; } } else { $infosImg['legende']['texte'] = " "; } array_push($this->donnees, $infosImg); } private function formaterDateImg($date) { $dateFmt = $date; if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') { $dateFmt = 'inconnue'; } else { $dateFmt = strftime('%e %B %Y', strtotime($date)); } return $dateFmt; } public function addDessin() { $img = array(); $projet = Config::get($this->referentiel.'.baseDessins'); if ($projet != "") { $dessin = array(); $tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique'); $this->images->setProjet($projet); $this->images->setNnTaxon($tax); if ($this->referentiel == 'bdtfx') { $costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons(); $this->images->setApi(Eflore::API_DEL); if (count($costeImg) != 0) { $img['src'] = $costeImg[key($costeImg)]['binaire.href']; $img['legende']['titre'] = "Illustration de Coste"; $img['legende']['texte'] = " "; } } } return $img; } } ?>