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 {
|
106 |
jpm |
16 |
|
95 |
delphine |
17 |
private $resultatType = 'determination';
|
106 |
jpm |
18 |
|
84 |
jpm |
19 |
public function initialiser() {
|
|
|
20 |
$this->capturerParametres();
|
|
|
21 |
}
|
106 |
jpm |
22 |
|
84 |
jpm |
23 |
private function capturerParametres() {
|
|
|
24 |
Debug::printr($_GET);
|
|
|
25 |
if (isset($_GET['resultat'])) {
|
|
|
26 |
$this->resultatType = $_GET['resultat'];
|
|
|
27 |
}
|
|
|
28 |
}
|
106 |
jpm |
29 |
|
76 |
delphine |
30 |
public function executerActionParDefaut() {
|
|
|
31 |
$this->executerResultat();
|
|
|
32 |
}
|
106 |
jpm |
33 |
|
76 |
delphine |
34 |
public function executerResultat() {
|
|
|
35 |
$resultats = Registre::get('resultats');
|
106 |
jpm |
36 |
Debug::printr(Registre);
|
|
|
37 |
$donnees = array();
|
84 |
jpm |
38 |
$donnees['typeResultat'] = $this->resultatType;
|
106 |
jpm |
39 |
$donnees['urlResAlphab'] = $this->obtenirUrlResultatAlphab();
|
84 |
jpm |
40 |
$donnees['urlResRetenu'] = $this->obtenirUrlResultatRetenu();
|
95 |
delphine |
41 |
$donnees['urlResDetermination'] = $this->obtenirUrlResultatDetermination();
|
106 |
jpm |
42 |
$donnees['urlResDecompo'] = $this->obtenirUrlResultatDecompo();
|
76 |
delphine |
43 |
$donnees['nbreTaxons'] = $resultats['entete']['total'];
|
84 |
jpm |
44 |
$donnees['nomsHtml'] = $this->getNoms($resultats['resultat']);
|
106 |
jpm |
45 |
|
76 |
delphine |
46 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $donnees));
|
|
|
47 |
}
|
106 |
jpm |
48 |
|
84 |
jpm |
49 |
private function getNoms($resultats) {
|
|
|
50 |
$noms = null;
|
|
|
51 |
$methode = 'genererListe'.ucwords($this->resultatType);
|
|
|
52 |
$noms = $this->$methode($resultats);
|
|
|
53 |
return $noms;
|
|
|
54 |
}
|
106 |
jpm |
55 |
|
|
|
56 |
private function genererListeAlphab($resultats) {
|
84 |
jpm |
57 |
$donnees = array();
|
|
|
58 |
$donnees['noms'] = $this->trierParNoms($resultats);
|
|
|
59 |
return $this->getVue('resultat_liste_noms', $donnees);
|
|
|
60 |
}
|
106 |
jpm |
61 |
|
84 |
jpm |
62 |
private function trierParNoms($noms) {
|
|
|
63 |
$noms = Tableau::trierTableauMd($noms, array('nom_sci' => SORT_ASC));
|
|
|
64 |
return $noms;
|
|
|
65 |
}
|
106 |
jpm |
66 |
|
84 |
jpm |
67 |
private function genererListeRetenu($resultats) {
|
|
|
68 |
$donnees = array();
|
|
|
69 |
$donnees['noms'] = $this->trierParNomsRetenus($resultats);
|
|
|
70 |
return $this->getVue('resultat_liste_noms', $donnees);
|
|
|
71 |
}
|
106 |
jpm |
72 |
|
84 |
jpm |
73 |
private function trierParNomsRetenus($noms) {
|
|
|
74 |
$nomsRetenus = array();
|
|
|
75 |
$nomsSynonymes = array();
|
|
|
76 |
foreach ($noms as $id => $nom) {
|
|
|
77 |
if ($nom['retenu'] == 'true') {
|
|
|
78 |
$nomsRetenus[$id] = $nom;
|
|
|
79 |
} else {
|
|
|
80 |
$nomsSynonymes[$id] = $nom;
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
$nomsRetenus = Tableau::trierTableauMd($nomsRetenus, array('nom_sci' => SORT_ASC));
|
|
|
84 |
$nomsSynonymes = Tableau::trierTableauMd($nomsSynonymes, array('nom_sci' => SORT_ASC));
|
|
|
85 |
$noms = array_merge($nomsRetenus, $nomsSynonymes);
|
|
|
86 |
return $noms;
|
|
|
87 |
}
|
106 |
jpm |
88 |
|
95 |
delphine |
89 |
private function genererListeDetermination($resultats) {
|
|
|
90 |
$donnees = array();
|
|
|
91 |
$donnees['noms'] = $this->trierSynonymes($resultats);
|
|
|
92 |
return $this->getVue('resultat_determination_noms', $donnees);
|
|
|
93 |
}
|
84 |
jpm |
94 |
|
95 |
delphine |
95 |
private function trierSynonymes($noms) {
|
|
|
96 |
$nomsRetenus = array();
|
106 |
jpm |
97 |
|
|
|
98 |
foreach ($noms as $idNomCourant => $nom) {
|
95 |
delphine |
99 |
if ($nom['retenu'] == 'true') {
|
106 |
jpm |
100 |
$nomRetenu = array();
|
|
|
101 |
$nomRetenu['nom_sci_retenu'] = $nom['nom_sci'];
|
|
|
102 |
$nomRetenu['url'] = $this->obtenirUrlFiche($idNomCourant);
|
|
|
103 |
$nomsRetenus[$idNomCourant] = $nomRetenu;
|
|
|
104 |
} else {
|
|
|
105 |
$idNomRetenu = $nom['nom_retenu.id'];
|
|
|
106 |
if (array_key_exists($nom['nom_retenu.id'], $nomsRetenus) == false) {
|
|
|
107 |
$nomRetenu = array();
|
|
|
108 |
$nomRetenu['nom_sci_retenu'] = $nom['nom_retenu'];
|
|
|
109 |
$nomRetenu['url'] = $this->obtenirUrlFiche($idNomRetenu);
|
|
|
110 |
$nomsRetenus[$idNomRetenu] = $nomRetenu;
|
|
|
111 |
}
|
|
|
112 |
$nomsRetenus[$idNomRetenu]['synonymes'][$idNomCourant] = $nom['nom_sci'];
|
95 |
delphine |
113 |
}
|
|
|
114 |
}
|
106 |
jpm |
115 |
$nomsRetenus = Tableau::trierMDType($nomsRetenus, array('nom_sci_retenu' => SORT_ASC), Tableau::TRI_NATUREL);
|
95 |
delphine |
116 |
return $nomsRetenus;
|
|
|
117 |
}
|
106 |
jpm |
118 |
|
|
|
119 |
private function genererListeDecompo($noms) {
|
|
|
120 |
return '<p>À réaliser</p>';
|
|
|
121 |
}
|
76 |
delphine |
122 |
}
|
|
|
123 |
?>
|