Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1058 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
// declare(encoding='UTF-8');
/**
 * Classe Onglet Synthese.
 *
 * @category    PHP 5.2
 * @package             eflore-consultation
 * @author              Jean-Pascal MILCENT <jpm@tela-botanica.org>
 * @author              Delphine CAUQUIL <delphine@tela-botanica.org>
 * @author              Grégoire DUCHÉ <gregoire@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/fiche/Fiche.php::obtenirDonnees()
 */
class Synthese /* aControleur inutilisé à ce jour */ {

        private $conteneur = null;
        private $nomCourant = null;

        public function __construct(Conteneur $conteneur) {
                $this->conteneur = $conteneur;
                $this->nomCourant = $this->conteneur->getNomCourant();
        }

        public function obtenirDonnees() {
                $donnees = array();
                $num_nom = $this->nomCourant->getNns();
                
                $blocs = array(
                        'illustrations', // grep-friendly: new Illustrations()
                        'repartition', // grep-friendly: new Repartition()
                        'nomenclature', // grep-friendly: new Nomenclature()
                        'description', // grep-friendly: new Description()
                        'ethnobotanique', // grep-friendly: new Ethnobotanique()
                        'bibliographie', // grep-friendly: new Bibliographie()
                        'statut', // grep-friendly: new Statut()
                        'ecologie' // grep-friendly: new Ecologie()
                );
                $cache = array();
                
                $nt = $this->conteneur->getNomCourant()->getNomRetenu()->get('num_taxonomique');
                $donnees['infos'] = array('referentiel' => $this->conteneur->getParametre('referentiel'), 'num_tax' => $nt);
                $referentiel = $this->conteneur->getParametre('referentiel');
                foreach ($blocs as $bloc) {
                        // TODO: unserialize() pourrait aussi légitimement retourner FALSE
                        $cache_bloc = unserialize($this->conteneur->getCache()->charger($bloc.'/bloc/'.$referentiel.'_'.$num_nom));
                        if($cache_bloc) {
                                $donnees[$bloc] = $cache_bloc;
                        } else {
                                $nom_classe = ucfirst($bloc);
                                $classe = new $nom_classe($this->conteneur);
                                $donnees[$bloc] = $classe->getBloc();
                                if($donnees[$bloc]) {
                                        $this->conteneur->getCache()->sauver(serialize($donnees[$bloc]),
                                                                                                                 $bloc.'/bloc/'.$referentiel.'_'.$num_nom);
                                }
                        }
                }
                return $donnees;
        }
}
?>