Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

<?php
class NomRangDecorateur extends NomDecorateur {

        private $nomDecorateur = null;
        private $rang = null;
        private $bdd = null;
        private $ontologieHrefTpl = null;
        protected $correspondances = array(
                'rang' => 'Intitule',
                'rang.code' => 'Code',
                'rang.href' => 'Href',
                'rang.*' => 'Intitule,Code,Href');

        public function __construct(NomDecorateur $nomDecorateur, Bdd $bdd = null, $ontologieHrefTpl) {
                $this->nomDecorateur = $nomDecorateur;
                $this->rang = $this->nomDecorateur->nom->getTag('rang');
                $this->bdd = is_null($bdd) ? new Bdd() : $bdd;
                $this->ontologieHrefTpl = $ontologieHrefTpl;
        }

        public function ajouterCode() {
                $squelette = 'bdnt.rangTaxo:%s';
                $rangCode = sprintf($squelette, $this->rang);
                $this->nomDecorateur->nomFormate['rang.code'] = $rangCode;
        }

        public function ajouterHref() {
                $href = sprintf($this->ontologieHrefTpl, $this->rang);
                $this->nomDecorateur->nomFormate['rang.href'] = $href;
        }

        public function ajouterIntitule() {
                $resultat = $this->rechercherOntologieNomParCode($this->rang);
                $this->nomDecorateur->nomFormate['rang'] = $resultat['nom'];
        }

        // TODO : supprimer cette recherche dans la bdd de cette classe
        private function rechercherOntologieNomParCode($code) {
                $code = $this->bdd->proteger($code);
                $requete =      'SELECT nom '.
                                        'FROM bdnt_ontologies_v4_30 '.
                                        "WHERE code = $code ";
                $resultats = $this->bdd->recuperer($requete);
                return $resultats;
        }
}
?>