Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

<?php
class Ressources {

        private $ressources = array();

        public function __construct(Array $ressources) {
                $this->ressources = $ressources;
        }

        public function getParPosition($position) {
                $valeur = '';
                if (array_key_exists($position, $this->ressources)) {
                        $valeur = $this->ressources[$position];
                }
                return $valeur;
        }

        public function getNombre() {
                return count($this->ressources);
        }

        public function getProjetNom() {
                return $this->getParPosition(0);
        }

        public function getServiceNom() {
                return $this->getParPosition(1);
        }

        public function getDetailsId() {
                return (int) $this->getParPosition(2);
        }

        public function etreId($aTester) {
                $etreId = is_numeric($aTester) ? true : false;
                return $etreId;
        }

        public function etreStats($aTester) {
                $etreStats = $aTester == 'stats' ? true : false;
                return $etreStats;
        }

        public function etreTypeDeStats($aTester) {
                $typesStats = array('annees', 'rangs', 'initiales');
                $etreStatsType = in_array($aTester, $typesStats) ? true : false;
                return $etreStatsType;
        }

        public function etreRelations($aTester) {
                $etreRelations = $aTester == 'relations' ? true : false;
                return $etreRelations;
        }

        public function etreTypeDeRelations($aTester) {
                $typesRelations = array('synonymie', 'homonymie', 'flores');
                $etreRelationsType = in_array($aTester, $typesRelations) ? true : false;
                return $etreRelationsType;
        }

        public function getServiceClasse() {
                $classeNom = '';
                if ($this->getNombre() == 2) {
                        if ($this->getServiceNom() == 'noms') {
                                $classeNom = 'NomsListe';
                        } else if ($this->getServiceNom() == 'taxons') {
                                $classeNom = 'TaxonsListe';
                        } else if ($this->getServiceNom() == 'ontologies') {
                                $classeNom = 'OntologiesListe';
                        }

                } else if ($this->getNombre() == 3) {
                        $position3 = $this->getParPosition(2);
                        if ($this->etreId($position3)) {
                                if ($this->getServiceNom() == 'noms') {
                                        $classeNom = 'NomDetails';
                                } else if ($this->getServiceNom() == 'taxons') {
                                        $classeNom = 'TaxonDetails';
                                }
                        }
                } else if ($this->getNombre() == 4) {
                        $position3 = $this->getParPosition(2);
                        $position4 = $this->getParPosition(3);
                        if ($this->etreStats($position3)) {
                                if ($this->etreTypeDeStats($position4)) {
                                        $classeNom = 'NomsStats'.ucfirst($position4);
                                }
                        } else if ($this->etreId($position3)) {
                                if ($this->etreRelations($position4)) {
                                        $classeNom = 'NomRelations';
                                }
                        }
                } else if ($this->getNombre() == 5) {
                        $position3 = $this->getParPosition(2);
                        $position4 = $this->getParPosition(3);
                        $position5 = $this->getParPosition(4);
                        if ($this->etreId($position3)) {
                                if ($this->etreRelations($position4)) {
                                        if ($this->etreTypeDeRelations($position5)) {
                                                $classeNom = 'NomRelations'.ucfirst($position5);
                                        }
                                }
                        }
                }
                return $classeNom;
        }
}
?>