Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 293 | Rev 387 | 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_defaut'));
                return $noms;
        }

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

        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 getApiMetaDonnees() {
                $meta = new MetaDonnees();
                return $meta;
        }

        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->parametres['utilisateur.niveau.defaut']);
                }
                return $this->partages['Utilisateur'];
        }

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