78 |
delphine |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Classe Controleur du module Fiche Taxon.
|
|
|
5 |
*
|
|
|
6 |
* @category Php 5.2
|
|
|
7 |
* @package Taxon
|
|
|
8 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
9 |
* @copyright 2010 Tela-Botanica
|
|
|
10 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
11 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
|
|
12 |
* @version SVN: $Id: Fiche.php 96 2010-06-21 16:46:31Z jpm $
|
|
|
13 |
*/
|
|
|
14 |
class FicheTaxon extends AppliControleur {
|
|
|
15 |
|
|
|
16 |
private $donnees = array();
|
|
|
17 |
protected $taxonDao = null;
|
85 |
delphine |
18 |
private $tableau_manuel = null;
|
|
|
19 |
private $num_taxon = array(0=>0,1=>0,2=>0);
|
78 |
delphine |
20 |
|
|
|
21 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// Méthodes
|
|
|
23 |
/**
|
|
|
24 |
* Fonction d'affichage par défaut
|
|
|
25 |
*/
|
|
|
26 |
public function executerActionParDefaut() {
|
|
|
27 |
return $this->afficherTaxon();
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
// +---------------------------------------------------------------------------------------------------------------+
|
82 |
delphine |
31 |
// FICHE CONSULTATION TAXON
|
78 |
delphine |
32 |
public function afficherTaxon() {
|
|
|
33 |
// Récupération du référentiel
|
|
|
34 |
if (isset($_GET['ref'])) {
|
|
|
35 |
$this->referentiel = strtolower($_GET['ref']);
|
|
|
36 |
}
|
|
|
37 |
// Gestion des actions par défaut
|
|
|
38 |
$this->taxonDao = new TaxonDao();
|
|
|
39 |
$this->definirCommeModulePrincipal(get_class($this));
|
|
|
40 |
$this->construireMenu($this->referentiel);
|
|
|
41 |
$this->construireFilAriane($this->referentiel);
|
134 |
delphine |
42 |
$this->executerActionReferentiel('Recherche', 'chargerMoteurRecherche', $this->referentiel, 10);
|
78 |
delphine |
43 |
|
|
|
44 |
// Gestion des données de la requête
|
|
|
45 |
if (!isset($_GET['num_nom'])) {
|
|
|
46 |
|
|
|
47 |
} else {
|
|
|
48 |
// Récupération des données
|
|
|
49 |
$this->donnees['referentiel'] = $this->referentiel;
|
|
|
50 |
$this->donnees['num_nom'] = $_GET['num_nom'];
|
82 |
delphine |
51 |
$this->donnees['info'] = $this->taxonDao->getTaxon($this->referentiel, $this->donnees['num_nom']);
|
103 |
jpm |
52 |
$this->donnees['num_nom_retenu'] = $this->donnees['info']['num_nom_retenu'];
|
149 |
jpm |
53 |
$this->donnees['nom'] = $this->donnees['info']['nom_sci'];
|
204 |
delphine |
54 |
$this->donnees['exclu_taxref'] = $this->donnees['info']['exclure_taxref'];
|
78 |
delphine |
55 |
|
88 |
delphine |
56 |
if ($this->donnees['info'] != '') {
|
|
|
57 |
// Chargement des données des onglets
|
|
|
58 |
$this->chargerNomenclature();
|
|
|
59 |
$this->chargerSynonymie();
|
|
|
60 |
$this->chargerClassification();
|
|
|
61 |
$this->chargerChorologie();
|
|
|
62 |
$this->chargerComplements();
|
|
|
63 |
}
|
78 |
delphine |
64 |
|
|
|
65 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_taxon', $this->donnees));
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
82 |
delphine |
69 |
private function chargerNomenclature() {
|
|
|
70 |
$this->donnees['selectionne'] = $this->taxonDao->getNomenclature($this->referentiel, $this->donnees['num_nom']);
|
168 |
delphine |
71 |
if ($this->donnees['num_nom'] != $this->donnees['num_nom_retenu'] && $this->donnees['num_nom_retenu'] != '') {
|
|
|
72 |
$this->donnees['retenu'] = $this->taxonDao->getNomenclature($this->referentiel, $this->donnees['num_nom_retenu']);
|
|
|
73 |
}
|
|
|
74 |
if ($this->donnees['info']['hybride_parent_01'] != '' && $this->donnees['info']['hybride_parent_02'] != '') {
|
|
|
75 |
$this->donnees['parents'] = $this->taxonDao->getParentsHybride($this->referentiel, $this->donnees['num_nom']);
|
|
|
76 |
} elseif ($this->donnees['info']['hybride_parent_01'] != '' || $this->donnees['info']['hybride_parent_02'] != ''){
|
|
|
77 |
$this->donnees['parents'] = $this->taxonDao->getParentsHybride($this->referentiel, $this->donnees['num_nom']);
|
82 |
delphine |
78 |
}
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
// recherche les synonymes (à compléter)
|
|
|
82 |
private function chargerSynonymie() {
|
|
|
83 |
$rechercheDao = new RechercheDao();
|
|
|
84 |
// recherche des synonymes nomenclaturaux et taxonomiques
|
|
|
85 |
$parametres = $this->parserChaineDeRecherche('nn:'.$this->donnees['num_nom'].' tax:1');
|
|
|
86 |
$parametres['ref']= $this->referentiel;
|
85 |
delphine |
87 |
$synonymes = $rechercheDao->chercher('ParTaxon', $parametres);
|
|
|
88 |
if ($synonymes != '') {
|
|
|
89 |
foreach ($synonymes as $synonyme) {
|
104 |
delphine |
90 |
$this->trierSynonymesNomenclaturauxTaxonomiques($synonyme);
|
|
|
91 |
$this->trierSynonymesMalAppliques($synonyme);
|
|
|
92 |
$this->trierSynonymesOrthographiques($synonyme);
|
82 |
delphine |
93 |
}
|
104 |
delphine |
94 |
}
|
|
|
95 |
// synonyme proparte
|
|
|
96 |
if ($this->donnees['info']['synonyme_proparte'] != ''){
|
|
|
97 |
$propartes = preg_split('/;/', $this->donnees['info']['synonyme_proparte']);
|
|
|
98 |
foreach ($propartes as $protarte) {
|
117 |
delphine |
99 |
$this->donnees['pp'] = $this->taxonDao->getTaxonAffichage($this->referentiel, $proparte);
|
85 |
delphine |
100 |
}
|
104 |
delphine |
101 |
}
|
|
|
102 |
// homonymie
|
149 |
jpm |
103 |
$nom = $this->encodeChaine($this->donnees['info']['nom_sci']);
|
110 |
jpm |
104 |
$homonymes = $this->taxonDao->getHomonyme($this->referentiel, $nom);
|
|
|
105 |
if (count($homonymes) > 1) {
|
|
|
106 |
foreach ($homonymes as $id => &$homonyme) {
|
|
|
107 |
$homonyme['statut'] = $homonyme['homonyme'];
|
|
|
108 |
}
|
|
|
109 |
|
117 |
delphine |
110 |
$this->donnees['h'] = $homonymes;
|
104 |
delphine |
111 |
}
|
|
|
112 |
}
|
110 |
jpm |
113 |
|
104 |
delphine |
114 |
private function trierSynonymesNomenclaturauxTaxonomiques($synonyme) {
|
|
|
115 |
if ($this->donnees['num_nom'] != $synonyme['num_nom'] && $synonyme['basionyme'] != null) {
|
|
|
116 |
if (($this->donnees['num_nom'] != $synonyme['num_nom']) && ($synonyme['basionyme'] ==
|
|
|
117 |
$this->donnees['num_nom'] || $this->donnees['info']['basionyme'] == $synonyme['num_nom'] ||
|
|
|
118 |
$this->donnees['info']['basionyme'] == $synonyme['basionyme'])) {
|
117 |
delphine |
119 |
$this->donnees['n'][] = $synonyme;
|
104 |
delphine |
120 |
} elseif ($this->donnees['num_nom'] != $synonyme['num_nom'] && $synonyme['basionyme'] != null &&
|
|
|
121 |
$this->donnees['info']['basionyme'] != null) {
|
117 |
delphine |
122 |
$this->donnees['t'][] = $synonyme;
|
204 |
delphine |
123 |
} else {
|
|
|
124 |
$this->donnees['i'][] = $synonyme;
|
|
|
125 |
}
|
104 |
delphine |
126 |
} elseif ($this->donnees['num_nom'] != $synonyme['num_nom']) {
|
117 |
delphine |
127 |
$this->donnees['i'][] = $synonyme;
|
104 |
delphine |
128 |
}
|
|
|
129 |
}
|
110 |
jpm |
130 |
|
104 |
delphine |
131 |
private function trierSynonymesMalAppliques($synonyme) {
|
|
|
132 |
if ($synonyme['synonyme_mal_applique'] == 1) {
|
|
|
133 |
if ($synonyme['num_nom'] == $synonyme['num_nom_retenu']) {
|
|
|
134 |
$synonyme['statut'] = 'posséde des synonymes mal appliqués';
|
|
|
135 |
} else {
|
|
|
136 |
$synonyme['statut'] = 'est synonyme mal appliqué du num_nom '.$synonyme['num_nom_retenu'];
|
88 |
delphine |
137 |
}
|
117 |
delphine |
138 |
$this->donnees['ma'][] = $synonyme;
|
104 |
delphine |
139 |
}
|
82 |
delphine |
140 |
}
|
110 |
jpm |
141 |
|
104 |
delphine |
142 |
private function trierSynonymesOrthographiques($synonyme) {
|
|
|
143 |
if (isset($synonyme['synonyme_orthographique']) && $synonyme['synonyme_orthographique'] != '') {
|
|
|
144 |
if ($synonyme['synonyme_orthographique'] == $synonyme['num_nom']) {
|
|
|
145 |
$synonyme['statut'] = 'posséde des synonymes orthographiques';
|
|
|
146 |
} else {
|
|
|
147 |
$synonyme['statut'] = 'est synonyme orthographique du num_nom '.$synonyme['synonyme_orthographique'];
|
|
|
148 |
}
|
117 |
delphine |
149 |
$this->donnees['o'][] = $synonyme;
|
104 |
delphine |
150 |
}
|
|
|
151 |
}
|
82 |
delphine |
152 |
|
|
|
153 |
private function chargerChorologie() {
|
85 |
delphine |
154 |
$this->chargerTableauManuel('presence');
|
|
|
155 |
$this->chargerTableauManuel('statuts_origine');
|
|
|
156 |
$this->chargerTableauManuel('statuts_introduction');
|
|
|
157 |
$this->chargerTableauManuel('statuts_culture');
|
82 |
delphine |
158 |
foreach ($this->donnees['info'] as $param => $valeur) {
|
|
|
159 |
if ($param == 'presence') {
|
|
|
160 |
$this->donnees['chorologie']['Présence']['France']['code'] = $valeur;
|
85 |
delphine |
161 |
$this->donnees['chorologie']['Présence']['France']['valeur'] = $this->tableau_manuel['presence'][$valeur];
|
82 |
delphine |
162 |
} elseif (preg_match('/presence_(.*)/', $param, $lieu)) {
|
|
|
163 |
$this->donnees['chorologie']['Présence'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
164 |
$this->donnees['chorologie']['Présence'][$lieu['1']]['valeur'] = $this->tableau_manuel['presence'][$valeur];
|
82 |
delphine |
165 |
} elseif ($param == 'statut_origine') {
|
|
|
166 |
$this->donnees['chorologie']['Statut d\'origine']['France']['code'] = $valeur;
|
85 |
delphine |
167 |
$this->donnees['chorologie']['Statut d\'origine']['France']['valeur'] =
|
|
|
168 |
$this->tableau_manuel['statuts_origine'][$valeur];
|
82 |
delphine |
169 |
} elseif (preg_match('/statut_origine_(.*)/', $param, $lieu)) {
|
|
|
170 |
$this->donnees['chorologie']['Statut d\'origine'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
171 |
$this->donnees['chorologie']['Statut d\'origine'][$lieu['1']]['valeur'] =
|
|
|
172 |
$this->tableau_manuel['statuts_origine'][$valeur];
|
82 |
delphine |
173 |
} elseif ($param == 'statut_introduction') {
|
|
|
174 |
$this->donnees['chorologie']['Statut d\'introduction']['France']['code'] = $valeur;
|
85 |
delphine |
175 |
$this->donnees['chorologie']['Statut d\'introduction']['France']['valeur'] =
|
|
|
176 |
$this->tableau_manuel['statuts_introduction'][$valeur];
|
82 |
delphine |
177 |
} elseif (preg_match('/statut_introduction_(.*)/', $param, $lieu)) {
|
|
|
178 |
$this->donnees['chorologie']['Statut d\'introduction'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
179 |
$this->donnees['chorologie']['Statut d\'introduction'][$lieu['1']]['valeur'] =
|
|
|
180 |
$this->tableau_manuel['statuts_introduction'][$valeur];
|
82 |
delphine |
181 |
} elseif ($param == 'statut_culture') {
|
|
|
182 |
$this->donnees['chorologie']['Statut de culture']['France']['code'] = $valeur;
|
85 |
delphine |
183 |
$this->donnees['chorologie']['Statut de culture']['France']['valeur'] =
|
|
|
184 |
$this->tableau_manuel['statuts_culture'][$valeur];
|
82 |
delphine |
185 |
} elseif (preg_match('/statut_culture_(.*)/', $param, $lieu)) {
|
|
|
186 |
$this->donnees['chorologie']['Statut de culture'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
187 |
$this->donnees['chorologie']['Statut de culture'][$lieu['1']]['valeur'] =
|
|
|
188 |
$this->tableau_manuel['statuts_culture'][$valeur];
|
82 |
delphine |
189 |
}
|
|
|
190 |
}
|
110 |
jpm |
191 |
foreach ($this->donnees['chorologie']['Présence'] as $lieu => $valeur) {
|
82 |
delphine |
192 |
if (!isset($this->donnees['chorologie']['Statut d\'origine'][$lieu])) {
|
|
|
193 |
$this->donnees['chorologie']['Statut d\'origine'][$lieu]['code'] = '';
|
|
|
194 |
}
|
|
|
195 |
if (!isset($this->donnees['chorologie']['Statut d\'introduction'][$lieu])) {
|
|
|
196 |
$this->donnees['chorologie']['Statut d\'introduction'][$lieu]['code'] = '';
|
|
|
197 |
}
|
|
|
198 |
if (!isset($this->donnees['chorologie']['Statut de culture'][$lieu])) {
|
|
|
199 |
$this->donnees['chorologie']['Statut de culture'][$lieu]['code'] = '';
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
}
|
|
|
203 |
|
85 |
delphine |
204 |
private function chargerClassification() {
|
113 |
delphine |
205 |
$this->chargerTableauManuel('signification_rang');
|
243 |
delphine |
206 |
$this->chargerTableauManuel('presence');
|
113 |
delphine |
207 |
$this->donnees['valeur_rang'] = $this->tableau_manuel['signification_rang'];
|
243 |
delphine |
208 |
$this->donnees['valeur_presence'] = $this->tableau_manuel['presence'];
|
168 |
delphine |
209 |
if ($this->donnees['info']['num_tax_sup'] != '' && $this->donnees['info']['num_tax_sup'] !== "0") {
|
|
|
210 |
$this->donnees['classification']['supérieurs'] = array_reverse($this->taxonDao->getClassification
|
|
|
211 |
('Superieur', $this->referentiel, $this->donnees['info']['num_tax_sup']));
|
|
|
212 |
} elseif (isset($this->donnees['retenu']['num_tax_sup']) && ($this->donnees['retenu']['num_tax_sup'] != '')) {
|
|
|
213 |
$this->donnees['classification']['supérieurs'] = array_reverse($this->taxonDao->getClassification
|
85 |
delphine |
214 |
('Superieur', $this->referentiel, $this->donnees['retenu']['num_tax_sup']));
|
|
|
215 |
}
|
|
|
216 |
if ($this->donnees['num_nom_retenu'] != '') {
|
|
|
217 |
$class_inf = $this->taxonDao->getClassification
|
|
|
218 |
('Inferieur', $this->referentiel, $this->donnees['num_nom_retenu']);
|
168 |
delphine |
219 |
if ($class_inf != '') {
|
88 |
delphine |
220 |
$this->donnees['classification']['inférieurs'] = $class_inf['inf'];
|
|
|
221 |
$this->donnees['niveau'] = $class_inf['niveau'];
|
241 |
delphine |
222 |
arsort($class_inf['nb_par_rang']);
|
|
|
223 |
$this->donnees['noms_rang'] = $class_inf['nb_par_rang'];
|
|
|
224 |
}
|
85 |
delphine |
225 |
}
|
|
|
226 |
}
|
|
|
227 |
|
104 |
delphine |
228 |
private function chargerComplements() {
|
85 |
delphine |
229 |
$champs_manuel_technique = explode(',', $this->manuel['champs']);
|
|
|
230 |
$champs_base_donnees = key($this->donnees['info']);
|
|
|
231 |
$champs_supp_base = array_diff_key($this->donnees['info'], array_flip($champs_manuel_technique));
|
|
|
232 |
foreach ($champs_supp_base as $champ=>$valeur) {
|
|
|
233 |
if (!(preg_match('/presence_(.*)/',$champ) || preg_match('/statut_origine_(.*)/', $champ) ||
|
|
|
234 |
preg_match('/statut_introduction_(.*)/', $champ) || preg_match('/statut_culture_(.*)/', $champ))) {
|
|
|
235 |
$this->donnees['complement'][$champ] = $valeur;
|
|
|
236 |
}
|
|
|
237 |
}
|
|
|
238 |
}
|
|
|
239 |
|
82 |
delphine |
240 |
private function parserChaineDeRecherche($chaine) {
|
|
|
241 |
$mots = preg_split('/ /i', $chaine, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
242 |
$parametres = array('mots' => '');
|
|
|
243 |
$cle_precedente = null;
|
|
|
244 |
foreach ($mots as $mot) {
|
|
|
245 |
if (preg_match('/^(sg|gen|sp|ssp|au|an|nn|bib|nr|tax):(.*)$/', $mot, $match)) {
|
|
|
246 |
$cle = $match[1];
|
|
|
247 |
$cle_precedente = $cle;
|
|
|
248 |
$valeur = $match[2];
|
|
|
249 |
$parametres[$cle] = $valeur;
|
|
|
250 |
} else if (!is_null($cle_precedente)) {
|
|
|
251 |
$parametres[$cle_precedente] .= ' '.$mot;
|
|
|
252 |
} else if (is_null($cle_precedente)) {
|
|
|
253 |
if (empty($parametres['mots'])) {
|
|
|
254 |
$parametres['mots'] = $mot;
|
|
|
255 |
} else {
|
|
|
256 |
$parametres['mots'] .= ' '.$mot;
|
|
|
257 |
}
|
|
|
258 |
}
|
|
|
259 |
}
|
|
|
260 |
return $parametres;
|
|
|
261 |
}
|
|
|
262 |
|
88 |
delphine |
263 |
public function encodeChaine($chaine) {
|
|
|
264 |
if (Config::get('sortie_encodage') != Config::get('appli_encodage')) {
|
|
|
265 |
$chaine = mb_convert_encoding($chaine, Config::get('sortie_encodage'), Config::get('appli_encodage'));
|
|
|
266 |
}
|
|
|
267 |
$chaine = urlencode($chaine);
|
|
|
268 |
return $chaine;
|
|
|
269 |
}
|
|
|
270 |
|
82 |
delphine |
271 |
// retourne l'url de la fiche taxon pour les liens
|
78 |
delphine |
272 |
public static function getUrlFicheTaxon($params, $type) {
|
|
|
273 |
$taxon = null;
|
|
|
274 |
switch ($type) {
|
|
|
275 |
case 'bas' :
|
|
|
276 |
$taxon['num_nom'] = $params['bas_num'];
|
|
|
277 |
break;
|
|
|
278 |
case 'p1' :
|
|
|
279 |
$taxon['num_nom'] = $params['p1_num'];
|
|
|
280 |
break;
|
|
|
281 |
case 'p2' :
|
|
|
282 |
$taxon['num_nom'] = $params['p2_num'];
|
|
|
283 |
break;
|
110 |
jpm |
284 |
default :
|
|
|
285 |
break;
|
78 |
delphine |
286 |
}
|
|
|
287 |
return Recherche::getUrlFicheTaxon($taxon);
|
|
|
288 |
}
|
|
|
289 |
|
85 |
delphine |
290 |
// charger tableau de $this->manuel
|
|
|
291 |
private function chargerTableauManuel($titreTableau) {
|
|
|
292 |
$champs = explode(',', $this->manuel[$titreTableau]);
|
|
|
293 |
foreach ($champs as $champ) {
|
|
|
294 |
list($champ_nom, $type) = explode('=', trim($champ));
|
|
|
295 |
$this->tableau_manuel[$titreTableau][$champ_nom] = $type;
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
|
78 |
delphine |
299 |
|
|
|
300 |
}
|