Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 163 | Go to most recent revision | 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';
68
			}
69
 
70
		} else if ($this->getNombre() == 3) {
71
			$position3 = $this->getParPosition(2);
72
			if ($this->etreId($position3)) {
73
				if ($this->getServiceNom() == 'noms') {
74
					$classeNom = 'NomDetails';
75
				} else if ($this->getServiceNom() == 'taxons') {
76
					$classeNom = 'TaxonDetails';
77
				}
78
			}
79
		} else if ($this->getNombre() == 4) {
80
			$position3 = $this->getParPosition(2);
81
			$position4 = $this->getParPosition(3);
82
			if ($this->etreStats($position3)) {
83
				if ($this->etreTypeDeStats($position4)) {
84
					$classeNom = 'NomsStats'.ucfirst($position4);
85
				}
86
			} else if ($this->etreId($position3)) {
87
				if ($this->etreRelations($position4)) {
88
					$classeNom = 'NomRelations';
89
				}
90
			}
91
		} else if ($this->getNombre() == 5) {
92
			$position3 = $this->getParPosition(2);
93
			$position4 = $this->getParPosition(3);
94
			$position5 = $this->getParPosition(4);
95
			if ($this->etreId($position3)) {
96
				if ($this->etreRelations($position4)) {
97
					if ($this->etreTypeDeRelations($position5)) {
98
						$classeNom = 'NomRelations'.ucfirst($position5);
99
					}
100
				}
101
			}
102
		}
103
		return $classeNom;
104
	}
163 jpm 105
}
106
?>