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');
|
|
|
206 |
$this->donnees['valeur_rang'] = $this->tableau_manuel['signification_rang'];
|
168 |
delphine |
207 |
if ($this->donnees['info']['num_tax_sup'] != '' && $this->donnees['info']['num_tax_sup'] !== "0") {
|
|
|
208 |
$this->donnees['classification']['supérieurs'] = array_reverse($this->taxonDao->getClassification
|
|
|
209 |
('Superieur', $this->referentiel, $this->donnees['info']['num_tax_sup']));
|
|
|
210 |
} elseif (isset($this->donnees['retenu']['num_tax_sup']) && ($this->donnees['retenu']['num_tax_sup'] != '')) {
|
|
|
211 |
$this->donnees['classification']['supérieurs'] = array_reverse($this->taxonDao->getClassification
|
85 |
delphine |
212 |
('Superieur', $this->referentiel, $this->donnees['retenu']['num_tax_sup']));
|
|
|
213 |
}
|
|
|
214 |
if ($this->donnees['num_nom_retenu'] != '') {
|
|
|
215 |
$class_inf = $this->taxonDao->getClassification
|
|
|
216 |
('Inferieur', $this->referentiel, $this->donnees['num_nom_retenu']);
|
168 |
delphine |
217 |
if ($class_inf != '') {
|
88 |
delphine |
218 |
$this->donnees['classification']['inférieurs'] = $class_inf['inf'];
|
|
|
219 |
$this->donnees['niveau'] = $class_inf['niveau'];
|
241 |
delphine |
220 |
arsort($class_inf['nb_par_rang']);
|
|
|
221 |
$this->donnees['noms_rang'] = $class_inf['nb_par_rang'];
|
|
|
222 |
}
|
85 |
delphine |
223 |
}
|
|
|
224 |
}
|
|
|
225 |
|
104 |
delphine |
226 |
private function chargerComplements() {
|
85 |
delphine |
227 |
$champs_manuel_technique = explode(',', $this->manuel['champs']);
|
|
|
228 |
$champs_base_donnees = key($this->donnees['info']);
|
|
|
229 |
$champs_supp_base = array_diff_key($this->donnees['info'], array_flip($champs_manuel_technique));
|
|
|
230 |
foreach ($champs_supp_base as $champ=>$valeur) {
|
|
|
231 |
if (!(preg_match('/presence_(.*)/',$champ) || preg_match('/statut_origine_(.*)/', $champ) ||
|
|
|
232 |
preg_match('/statut_introduction_(.*)/', $champ) || preg_match('/statut_culture_(.*)/', $champ))) {
|
|
|
233 |
$this->donnees['complement'][$champ] = $valeur;
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
}
|
|
|
237 |
|
82 |
delphine |
238 |
private function parserChaineDeRecherche($chaine) {
|
|
|
239 |
$mots = preg_split('/ /i', $chaine, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
240 |
$parametres = array('mots' => '');
|
|
|
241 |
$cle_precedente = null;
|
|
|
242 |
foreach ($mots as $mot) {
|
|
|
243 |
if (preg_match('/^(sg|gen|sp|ssp|au|an|nn|bib|nr|tax):(.*)$/', $mot, $match)) {
|
|
|
244 |
$cle = $match[1];
|
|
|
245 |
$cle_precedente = $cle;
|
|
|
246 |
$valeur = $match[2];
|
|
|
247 |
$parametres[$cle] = $valeur;
|
|
|
248 |
} else if (!is_null($cle_precedente)) {
|
|
|
249 |
$parametres[$cle_precedente] .= ' '.$mot;
|
|
|
250 |
} else if (is_null($cle_precedente)) {
|
|
|
251 |
if (empty($parametres['mots'])) {
|
|
|
252 |
$parametres['mots'] = $mot;
|
|
|
253 |
} else {
|
|
|
254 |
$parametres['mots'] .= ' '.$mot;
|
|
|
255 |
}
|
|
|
256 |
}
|
|
|
257 |
}
|
|
|
258 |
return $parametres;
|
|
|
259 |
}
|
|
|
260 |
|
88 |
delphine |
261 |
public function encodeChaine($chaine) {
|
|
|
262 |
if (Config::get('sortie_encodage') != Config::get('appli_encodage')) {
|
|
|
263 |
$chaine = mb_convert_encoding($chaine, Config::get('sortie_encodage'), Config::get('appli_encodage'));
|
|
|
264 |
}
|
|
|
265 |
$chaine = urlencode($chaine);
|
|
|
266 |
return $chaine;
|
|
|
267 |
}
|
|
|
268 |
|
82 |
delphine |
269 |
// retourne l'url de la fiche taxon pour les liens
|
78 |
delphine |
270 |
public static function getUrlFicheTaxon($params, $type) {
|
|
|
271 |
$taxon = null;
|
|
|
272 |
switch ($type) {
|
|
|
273 |
case 'bas' :
|
|
|
274 |
$taxon['num_nom'] = $params['bas_num'];
|
|
|
275 |
break;
|
|
|
276 |
case 'p1' :
|
|
|
277 |
$taxon['num_nom'] = $params['p1_num'];
|
|
|
278 |
break;
|
|
|
279 |
case 'p2' :
|
|
|
280 |
$taxon['num_nom'] = $params['p2_num'];
|
|
|
281 |
break;
|
110 |
jpm |
282 |
default :
|
|
|
283 |
break;
|
78 |
delphine |
284 |
}
|
|
|
285 |
return Recherche::getUrlFicheTaxon($taxon);
|
|
|
286 |
}
|
|
|
287 |
|
85 |
delphine |
288 |
// charger tableau de $this->manuel
|
|
|
289 |
private function chargerTableauManuel($titreTableau) {
|
|
|
290 |
$champs = explode(',', $this->manuel[$titreTableau]);
|
|
|
291 |
foreach ($champs as $champ) {
|
|
|
292 |
list($champ_nom, $type) = explode('=', trim($champ));
|
|
|
293 |
$this->tableau_manuel[$titreTableau][$champ_nom] = $type;
|
|
|
294 |
}
|
|
|
295 |
}
|
|
|
296 |
|
78 |
delphine |
297 |
|
|
|
298 |
}
|