Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 59 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59 Rev 64
Line 15... Line 15...
15
class Liste extends aControleur {
15
class Liste extends aControleur {
Line 16... Line 16...
16
	
16
	
17
	private $alphabet = null;
17
	private $alphabet = null;
18
	protected $rang = null;
18
	protected $rang = null;
-
 
19
	protected $lettre = null;
Line 19... Line 20...
19
	protected $lettre = null;
20
	private $rangsCorrespondance = array('F' => 'Famille', 'G' => 'Genre');
20
	
21
	
21
	public function initialiser() {
22
	public function initialiser() {
Line 22... Line 23...
22
		$this->capturerParametres();
23
		$this->capturerParametres();
23
	}
24
	}
24
	
25
	
Line 25... Line 26...
25
	public function executerActionParDefaut() {
26
	public function executerActionParDefaut() {
26
		$this->executerListe();
27
		$this->executerListe();
27
	}
-
 
28
	
28
	}
29
	public function executerListe() {
-
 
30
		$this->chargerAlphabet();
-
 
31
		$this->lettre = key($this->alphabet);
-
 
32
		$this->executerFiltre();
-
 
33
	}
29
	
34
	
30
	public function executerListe() {
Line 35... Line 31...
35
	public function executerFiltre() {
31
		$this->initialiserAlphabet();
36
		$this->chargerAlphabet();
32
		$this->initialiserLettre();
37
		$couleurs = $this->creerColoration($this->alphabet);
33
		$couleurs = $this->creerColoration($this->alphabet);
38
		$taxons = $this->getListeTaxons();
34
		$taxons = $this->getListeTaxons();
-
 
35
		
39
		
36
		$donnees = array();
-
 
37
		$donnees['i18n'] = I18n::get('Liste');
40
		$donnees = array();
38
		$donnees['lettre'] = $this->lettre;
41
		$donnees['i18n'] = I18n::get('Liste');
39
		$donnees['rang'] = $this->rang;
42
		$donnees['lettre'] = $this->lettre;
40
		$donnees['rangCodes'] = array_keys($this->rangsCorrespondance);
43
		$donnees['rang'] = $this->rang;
41
		$donnees['initiales'] = $this->alphabet;
44
		$donnees['initiales'] = $this->alphabet;
42
		$donnees['lettreCorrespondance'] = $this->chargerCorrespondanceSpeciale();
45
		$donnees['couleurs'] = $couleurs;
43
		$donnees['couleurs'] = $couleurs;
46
		$donnees['taxons'] = $taxons;
44
		$donnees['taxons'] = $taxons;
47
		$donnees['nbreTaxons'] = $this->getEfloreTaxons()->getEnteteTotal();
45
		$donnees['nbreTaxons'] = $this->getEfloreTaxons()->getEnteteTotal();
48
		$donnees['urlFiltre'] = $this->obtenirUrlBase();
46
		$donnees['urlFiltre'] = $this->obtenirUrlBase();
Line 49... Line 47...
49
		$donnees['referentiel'] = Registre::get('parametres.referentiel');
47
		$donnees['referentiel'] = Registre::get('parametres.referentiel');
Line 60... Line 58...
60
		if (isset($_GET['lettre'])) {
58
		if (isset($_GET['lettre'])) {
61
			$this->lettre = $_GET['lettre'];
59
			$this->lettre = $_GET['lettre'];
62
		}
60
		}
63
	}
61
	}
Line 64... Line 62...
64
	
62
	
65
	private function chargerAlphabet() {
63
	private function initialiserAlphabet() {
66
		if (!isset($this->alphabet)) {
64
		if (!isset($this->alphabet)) {
67
			$this->alphabet = $this->getStatsInitiales();
65
			$this->alphabet = $this->getStatsInitiales();
68
		}
66
		}
69
		ksort($this->alphabet);
67
		ksort($this->alphabet);
-
 
68
	}
-
 
69
 
-
 
70
	private function initialiserLettre() {
-
 
71
		if (empty($this->lettre)) {
-
 
72
			if (!is_null($this->alphabet)) {
-
 
73
				$this->lettre = key($this->alphabet);
-
 
74
				
-
 
75
			} else {
-
 
76
				$m = "Aucune lettre n'a pu être initialiser car l'alphabet vaut null.";
-
 
77
				trigger_error($m, E_USER_WARNING);
-
 
78
			}
-
 
79
		}
-
 
80
	}
-
 
81
	
-
 
82
	private function chargerCorrespondanceSpeciale() {
-
 
83
		return array('chimere' => '+', 'hybride' => '×');
Line 70... Line 84...
70
	}
84
	}
71
	
85
	
72
	private function getStatsInitiales() {
86
	private function getStatsInitiales() {
73
		$nomRang = $this->getNomCodeRang();
87
		$nomRang = $this->getNomCodeRang();
Line 78... Line 92...
78
		}
92
		}
79
		return $stats;
93
		return $stats;
80
	}
94
	}
Line 81... Line 95...
81
	
95
	
82
	private function getListeTaxons() {
96
	private function getListeTaxons() {
83
		$taxons = array();
97
		$taxons = false;
84
		if (isset($this->lettre)) {
98
		if (isset($this->lettre)) {
85
			$nomRang = $this->getNomCodeRang();
99
			$nomRang = $this->getNomCodeRang();
86
			if ($nomRang) {
100
			if ($nomRang) {
87
				$methode = "getListe{$nomRang}ParInitiale";
101
				$methode = "getListe{$nomRang}ParInitiale";
Line 91... Line 105...
91
		return $taxons;
105
		return $taxons;
92
	}
106
	}
Line 93... Line 107...
93
	
107
	
94
	private function getNomCodeRang() {
108
	private function getNomCodeRang() {
95
		$nom = false;
109
		$nom = false;
96
		switch ($this->rang) {
-
 
97
			case 'F' :
110
		if (array_key_exists($this->rang, $this->rangsCorrespondance)) {
98
				$nom = 'Famille';
-
 
99
				break;
-
 
100
			case 'G' :
-
 
101
				$nom = 'Genre';
-
 
102
				break;
111
			$nom = $this->rangsCorrespondance[$this->rang];
103
			default :
112
		} else {
104
				$m = "Ce code de rang '{$this->rang}' est inconnu. Codes disponibles : F (Famille), G (Genre).";
113
			$m = "Ce code de rang '{$this->rang}' est inconnu. Codes disponibles : ".implode(', ', $this->rangsCorrespondance);
105
				trigger_error($m, E_USER_WARNING);
114
			trigger_error($m, E_USER_WARNING);
106
		}
115
		}
107
		return $nom;
116
		return $nom;
Line 108... Line 117...
108
	}
117
	}