Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

<?php
class NomCompoDecorateur extends NomDecorateur {

        private $nomDecorateur;
        protected $correspondances = array(
                'nom_sci.*' => 'Compo',
                'nom_sci.supra_generique', 'SupraGenre',
                'nom_sci.genre' => 'Genre',
                'nom_sci.infra_generique' => 'InfraGenre',
                'nom_sci.sp' => 'Sp',
                'nom_sci.type_epithete' => 'TypeInfraSp',
                'nom_sci.infra_sp' => 'InfraSp',
                'nom_sci.cultivar_groupe' => 'CultivarGroupe',
                'nom_sci.cultivar' => 'Cultivar',
                'nom_sci.nom_commercial' => 'NomCommercial');

        public function __construct(NomDecorateur $nomDecorateur) {
                $this->nomDecorateur = $nomDecorateur;
        }

        public function ajouterCompo() {
                $this->ajouterSupraGenre();
                $this->ajouterGenre();
                $this->ajouterInfraGenre();
                $this->ajouterSp();
                $this->ajouterTypeInfraSp();
                $this->ajouterInfraSp();
                $this->ajouterCultivarGroupe();
                $this->ajouterCultivar();
                $this->ajouterNomCommercial();
        }

        public function ajouterSupraGenre() {
                $this->ajouterPourChampSonFormatage('nom_supra_generique', 'supra_generique');
        }

        public function ajouterGenre() {
                $this->ajouterPourChampSonFormatage('genre', 'genre');
        }

        public function ajouterInfraGenre() {
                $this->ajouterPourChampSonFormatage('epithete_infra_generique', 'infra_generique');
        }

        public function ajouterSp() {
                $this->ajouterPourChampSonFormatage('epithete_sp', 'sp');
        }

        public function ajouterTypeInfraSp() {
                $this->ajouterPourChampSonFormatage('type_epithete', 'type_epithete');
        }

        public function ajouterInfraSp() {
                $this->ajouterPourChampSonFormatage('epithete_infra_sp', 'infra_sp');
        }

        public function ajouterCultivarGroupe() {
                $this->ajouterPourChampSonFormatage('cultivar_groupe', 'cultivar_groupe');
        }

        public function ajouterCultivar() {
                $this->ajouterPourChampSonFormatage('cultivar', 'cultivar');
        }

        public function ajouterNomCommercial() {
                $this->ajouterPourChampSonFormatage('nom_commercial', 'nom_commercial');
        }

        private function ajouterPourChampSonFormatage($champ, $format) {
                $valeur = $this->nomDecorateur->nom->getTag($champ);
                if ($this->exister($valeur)) {
                        $this->nomDecorateur->nomFormate["nom_sci.$format"] = $valeur;
                }
        }

        private function exister($valeur) {
                $existe = true;
                if (is_null($valeur) || $valeur == '') {
                        $existe = false;
                }
                return $existe;
        }
}
?>