76 |
delphine |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Classe mère du module Liste.
|
|
|
5 |
*
|
|
|
6 |
* @category PHP 5.2
|
|
|
7 |
* @package eflore-consultation
|
|
|
8 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
9 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
|
|
|
10 |
* @copyright 2011 Tela-Botanica
|
|
|
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
|
|
|
13 |
* @version $Id$
|
|
|
14 |
*/
|
|
|
15 |
class Resultat extends aControleur {
|
|
|
16 |
|
84 |
jpm |
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 |
}
|
|
|
29 |
|
76 |
delphine |
30 |
public function executerActionParDefaut() {
|
|
|
31 |
$this->executerResultat();
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public function executerResultat() {
|
|
|
35 |
$resultats = Registre::get('resultats');
|
84 |
jpm |
36 |
|
|
|
37 |
$donnees = array();
|
|
|
38 |
$donnees['typeResultat'] = $this->resultatType;
|
|
|
39 |
$donnees['urlResClassique'] = $this->obtenirUrlResultatClassique();
|
|
|
40 |
$donnees['urlResRetenu'] = $this->obtenirUrlResultatRetenu();
|
76 |
delphine |
41 |
$donnees['nbreTaxons'] = $resultats['entete']['total'];
|
84 |
jpm |
42 |
$donnees['nomsHtml'] = $this->getNoms($resultats['resultat']);
|
|
|
43 |
|
76 |
delphine |
44 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $donnees));
|
|
|
45 |
}
|
84 |
jpm |
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 |
|
76 |
delphine |
90 |
}
|
|
|
91 |
?>
|