Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 927 | Rev 1239 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
class Conteneur {
        protected $parametres = array();
        protected $partages = array();

        public function __construct(array $parametres = null) {
                $this->parametres = is_null($parametres) ? array() : $parametres;
        }

        public function getParametre($cle) {
                $valeur = isset($this->parametres[$cle]) ? $this->parametres[$cle] : Config::get($cle);
                return $valeur;
        }

        public function getParametreTableau($cle) {
                $tableau = array();
                $parametre = $this->getParametre($cle);
                if (empty($parametre) === false) {
                        $tableauPartiel = explode(',', $parametre);
                        $tableauPartiel = array_map('trim', $tableauPartiel);
                        foreach ($tableauPartiel as $champ) {
                                if (strpos($champ, '=') === false) {
                                        $tableau[] = trim($champ);
                                } else {
                                        list($cle, $val) = explode('=', $champ);
                                        $tableau[trim($cle)] = trim($val);
                                }
                        }
                }
                return $tableau;
        }

        public function setParametre($cle, $valeur) {
                $this->parametres[$cle] = $valeur;
        }

        public function getAppUrls() {
                if (!isset($this->partages['AppUrls'])){
                        $this->partages['AppUrls'] = new AppUrls();
                }
                return $this->partages['AppUrls'];
        }

        public function getApiNoms() {
                        $noms = new Noms($this->getParametre('referentiel'));
                return $noms;
        }

        public function getApiTaxons() {
                        $taxons = new Taxons($this->getParametre('referentiel'));
                return $taxons;
        }

        public function getApiBiblioBota() {
                $biblioBota = new BiblioBota();
                return $biblioBota;
        }

        public function getApiImages() {
                $images = new Images();
                return $images;
        }

        public function getApiCartes() {
                $cartes = new Cartes();
                return $cartes;
        }

        public function getApiNomsVernaculaires() {
                $nomsVernaculaires = new NomsVernaculaires();
                return $nomsVernaculaires;
        }

        public function getApiTextes() {
                $textes = new Textes();
                return $textes;
        }

        public function getApiWikini() {
                $wiki = new Wikini();
                return $wiki;
        }
        
        public function getApiGraphiques() {
                $graphique = new Graphiques();
                return $graphique;
        }
        
        public function getApiSyntaxons() {
                $syntaxon = new Syntaxons();
                return $syntaxon;
        }

        public function getApiMetaDonnees() {
                $meta = new MetaDonnees();
                return $meta;
        }
        
        public function getApiInformations() {
                $informations = new Informations();
                return $informations;
        }
        
        public function getApiStatuts() {
                $statuts = new Statuts();
                return $statuts;
        }

        public function getNomCourant() {
                if (!isset($this->partages['NomCourant'])){
                        $nns = $this->getParametre('num_nom');
                        $noms = $this->getApiNoms();
                        $taxons = $this->getApiTaxons();
                        $this->partages['NomCourant'] = new NomCourant($nns, $noms, $taxons);
                }
                return $this->partages['NomCourant'];
        }

        public function getUtilisateur() {
                if (!isset($this->partages['Utilisateur'])){
                        $this->partages['Utilisateur'] = new Utilisateur($this);
                }
                return $this->partages['Utilisateur'];
        }

        public function getBdd() {
                if (!isset($this->partages['Bdd'])){
                        $this->partages['Bdd'] = new Bdd();
                }
                return $this->partages['Bdd'];
        }
        
        public function getCache($dossierStockage = null) {
                if (!isset($this->partages['Cache'])){
                        $params = array(
                                'mise_en_cache' => $this->getParametre('cache'), 
                                'stockage_chemin' => is_null($dossierStockage) ? $this->getParametre('chemincache') : $dossierStockage, 
                                'duree_de_vie' => $this->getParametre('dureecache')
                        );
                        $this->partages['Cache'] = new CacheSimple($params);
                }
                return $this->partages['Cache'];
        }

        public function getRestClient() {
                if (!isset($this->partages['RestClient'])){
                        $this->partages['RestClient'] = new RestClient();
                }
                return $this->partages['RestClient'];
        }
        
        public function getQrCode() {
                if (!isset($this->partages['QrCode'])){
                        $this->partages['QrCode'] = new QrCode($this);
                }
                return $this->partages['QrCode'];
        }
}
?>