Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 880 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
163 jpm 1
<?php
2
class Ressources {
3
 
4
	private $ressources = array();
5
 
6
	public function __construct(Array $ressources) {
7
		$this->ressources = $ressources;
8
	}
9
 
10
	public function getParPosition($position) {
11
		$valeur = '';
12
		if (array_key_exists($position, $this->ressources)) {
13
			$valeur = $this->ressources[$position];
14
		}
15
		return $valeur;
16
	}
17
 
18
	public function getNombre() {
19
		return count($this->ressources);
20
	}
21
 
22
	public function getProjetNom() {
23
		return $this->getParPosition(0);
24
	}
25
 
26
	public function getServiceNom() {
27
		return $this->getParPosition(1);
28
	}
29
 
30
	public function getDetailsId() {
31
		return (int) $this->getParPosition(2);
32
	}
33
 
34
	public function etreId($aTester) {
35
		$etreId = is_numeric($aTester) ? true : false;
36
		return $etreId;
37
	}
38
 
39
	public function etreStats($aTester) {
40
		$etreStats = $aTester == 'stats' ? true : false;
41
		return $etreStats;
42
	}
43
 
44
	public function etreTypeDeStats($aTester) {
45
		$typesStats = array('annees', 'rangs', 'initiales');
46
		$etreStatsType = in_array($aTester, $typesStats) ? true : false;
47
		return $etreStatsType;
48
	}
49
 
50
	public function etreRelations($aTester) {
51
		$etreRelations = $aTester == 'relations' ? true : false;
52
		return $etreRelations;
53
	}
54
 
55
	public function etreTypeDeRelations($aTester) {
56
		$typesRelations = array('synonymie', 'homonymie', 'flores');
57
		$etreRelationsType = in_array($aTester, $typesRelations) ? true : false;
58
		return $etreRelationsType;
59
	}
215 jpm 60
 
61
	public function getServiceClasse() {
62
		$classeNom = '';
63
		if ($this->getNombre() == 2) {
64
			if ($this->getServiceNom() == 'noms') {
65
				$classeNom = 'NomsListe';
66
			} else if ($this->getServiceNom() == 'taxons') {
67
				$classeNom = 'TaxonsListe';
231 jpm 68
			} else if ($this->getServiceNom() == 'ontologies') {
69
				$classeNom = 'OntologiesListe';
215 jpm 70
			}
71
 
72
		} else if ($this->getNombre() == 3) {
73
			$position3 = $this->getParPosition(2);
74
			if ($this->etreId($position3)) {
75
				if ($this->getServiceNom() == 'noms') {
76
					$classeNom = 'NomDetails';
77
				} else if ($this->getServiceNom() == 'taxons') {
78
					$classeNom = 'TaxonDetails';
79
				}
80
			}
81
		} else if ($this->getNombre() == 4) {
82
			$position3 = $this->getParPosition(2);
83
			$position4 = $this->getParPosition(3);
84
			if ($this->etreStats($position3)) {
85
				if ($this->etreTypeDeStats($position4)) {
86
					$classeNom = 'NomsStats'.ucfirst($position4);
87
				}
88
			} else if ($this->etreId($position3)) {
89
				if ($this->etreRelations($position4)) {
90
					$classeNom = 'NomRelations';
91
				}
92
			}
93
		} else if ($this->getNombre() == 5) {
94
			$position3 = $this->getParPosition(2);
95
			$position4 = $this->getParPosition(3);
96
			$position5 = $this->getParPosition(4);
97
			if ($this->etreId($position3)) {
98
				if ($this->etreRelations($position4)) {
99
					if ($this->etreTypeDeRelations($position5)) {
100
						$classeNom = 'NomRelations'.ucfirst($position5);
101
					}
102
				}
103
			}
104
		}
105
		return $classeNom;
106
	}
163 jpm 107
}
108
?>