Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 76 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 76 Rev 84
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Resultat extends aControleur {
15
class Resultat extends aControleur {
-
 
16
	
-
 
17
	private $resultatType = 'classique';
-
 
18
	
-
 
19
	public function initialiser() {
-
 
20
		$this->capturerParametres();
-
 
21
	}
-
 
22
	
-
 
23
	private function capturerParametres() {
-
 
24
		Debug::printr($_GET);
-
 
25
		if (isset($_GET['resultat'])) {
-
 
26
			$this->resultatType = $_GET['resultat'];
-
 
27
		}
-
 
28
	}
16
	
29
	
17
	public function executerActionParDefaut() {
30
	public function executerActionParDefaut() {
18
		$this->executerResultat();
31
		$this->executerResultat();
19
	}
32
	}
20
	
33
	
21
	public function executerResultat() {
34
	public function executerResultat() {
22
		$donnees = array();
-
 
23
		$resultats = Registre::get('resultats');
35
		$resultats = Registre::get('resultats');
-
 
36
		
-
 
37
		$donnees = array();	
-
 
38
		$donnees['typeResultat'] = $this->resultatType;
-
 
39
		$donnees['urlResClassique'] = $this->obtenirUrlResultatClassique();
-
 
40
		$donnees['urlResRetenu'] = $this->obtenirUrlResultatRetenu();
24
		$donnees['nbreTaxons'] = $resultats['entete']['total'];
41
		$donnees['nbreTaxons'] = $resultats['entete']['total'];
25
		$donnees['taxons'] = $resultats['resultat'];
42
		$donnees['nomsHtml'] = $this->getNoms($resultats['resultat']);
-
 
43
		
26
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $donnees));
44
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $donnees));
27
		//print_r(Registre::get('resultats'));
-
 
28
	}
45
	}
-
 
46
	
-
 
47
	private function getNoms($resultats) {
-
 
48
		$noms = null;
-
 
49
		$methode = 'genererListe'.ucwords($this->resultatType);
-
 
50
		Debug::printr($methode);
-
 
51
		$noms = $this->$methode($resultats);
-
 
52
		return $noms;
-
 
53
	}
-
 
54
	
-
 
55
	private function genererListeClassique($resultats) {
-
 
56
		$donnees = array();
-
 
57
		$donnees['noms'] = $this->trierParNoms($resultats);
-
 
58
		return $this->getVue('resultat_liste_noms', $donnees);
-
 
59
	}
-
 
60
	
-
 
61
	private function trierParNoms($noms) {
-
 
62
		$noms = Tableau::trierTableauMd($noms, array('nom_sci' => SORT_ASC));
-
 
63
		return $noms;
-
 
64
	}
-
 
65
	
-
 
66
	private function genererListeRetenu($resultats) {
-
 
67
		$donnees = array();
-
 
68
		$donnees['noms'] = $this->trierParNomsRetenus($resultats);
-
 
69
		return $this->getVue('resultat_liste_noms', $donnees);
-
 
70
	}
-
 
71
	
-
 
72
	private function trierParNomsRetenus($noms) {
-
 
73
		$nomsRetenus = array();
-
 
74
		$nomsSynonymes = array();
-
 
75
		foreach ($noms as $id => $nom) {
-
 
76
			if ($nom['retenu'] == 'true') {
-
 
77
				$nomsRetenus[$id] = $nom;
-
 
78
			} else {
-
 
79
				$nomsSynonymes[$id] = $nom;
-
 
80
			}
-
 
81
		}
-
 
82
		$nomsRetenus = Tableau::trierTableauMd($nomsRetenus, array('nom_sci' => SORT_ASC));
-
 
83
		$nomsSynonymes = Tableau::trierTableauMd($nomsSynonymes, array('nom_sci' => SORT_ASC));
-
 
84
		$noms = array_merge($nomsRetenus, $nomsSynonymes);
-
 
85
		return $noms;
-
 
86
	}
-
 
87
 
-
 
88
	
-
 
89
	
29
}
90
}
30
?>
91
?>