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 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_taxon', $this->donnees));
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
82 |
delphine |
68 |
private function chargerNomenclature() {
|
|
|
69 |
$this->donnees['selectionne'] = $this->taxonDao->getNomenclature($this->referentiel, $this->donnees['num_nom']);
|
168 |
delphine |
70 |
if ($this->donnees['num_nom'] != $this->donnees['num_nom_retenu'] && $this->donnees['num_nom_retenu'] != '') {
|
|
|
71 |
$this->donnees['retenu'] = $this->taxonDao->getNomenclature($this->referentiel, $this->donnees['num_nom_retenu']);
|
|
|
72 |
}
|
|
|
73 |
if ($this->donnees['info']['hybride_parent_01'] != '' && $this->donnees['info']['hybride_parent_02'] != '') {
|
|
|
74 |
$this->donnees['parents'] = $this->taxonDao->getParentsHybride($this->referentiel, $this->donnees['num_nom']);
|
|
|
75 |
} elseif ($this->donnees['info']['hybride_parent_01'] != '' || $this->donnees['info']['hybride_parent_02'] != ''){
|
|
|
76 |
$this->donnees['parents'] = $this->taxonDao->getParentsHybride($this->referentiel, $this->donnees['num_nom']);
|
82 |
delphine |
77 |
}
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
// recherche les synonymes (à compléter)
|
|
|
81 |
private function chargerSynonymie() {
|
|
|
82 |
$rechercheDao = new RechercheDao();
|
|
|
83 |
// recherche des synonymes nomenclaturaux et taxonomiques
|
|
|
84 |
$parametres = $this->parserChaineDeRecherche('nn:'.$this->donnees['num_nom'].' tax:1');
|
|
|
85 |
$parametres['ref']= $this->referentiel;
|
85 |
delphine |
86 |
$synonymes = $rechercheDao->chercher('ParTaxon', $parametres);
|
|
|
87 |
if ($synonymes != '') {
|
277 |
delphine |
88 |
$this->donnees['syn'] = $synonymes;
|
104 |
delphine |
89 |
}
|
|
|
90 |
// synonyme proparte
|
|
|
91 |
if ($this->donnees['info']['synonyme_proparte'] != ''){
|
260 |
delphine |
92 |
$propartes = explode(',', $this->donnees['info']['synonyme_proparte']);
|
|
|
93 |
foreach ($propartes as $proparte) {
|
|
|
94 |
$this->donnees['pp'][] = $this->taxonDao->getTaxonAffichage($this->referentiel, trim($proparte));
|
85 |
delphine |
95 |
}
|
104 |
delphine |
96 |
}
|
|
|
97 |
// homonymie
|
149 |
jpm |
98 |
$nom = $this->encodeChaine($this->donnees['info']['nom_sci']);
|
110 |
jpm |
99 |
$homonymes = $this->taxonDao->getHomonyme($this->referentiel, $nom);
|
|
|
100 |
if (count($homonymes) > 1) {
|
|
|
101 |
foreach ($homonymes as $id => &$homonyme) {
|
|
|
102 |
$homonyme['statut'] = $homonyme['homonyme'];
|
|
|
103 |
}
|
|
|
104 |
|
117 |
delphine |
105 |
$this->donnees['h'] = $homonymes;
|
104 |
delphine |
106 |
}
|
|
|
107 |
}
|
110 |
jpm |
108 |
|
82 |
delphine |
109 |
private function chargerChorologie() {
|
85 |
delphine |
110 |
$this->chargerTableauManuel('presence');
|
|
|
111 |
$this->chargerTableauManuel('statuts_origine');
|
|
|
112 |
$this->chargerTableauManuel('statuts_introduction');
|
|
|
113 |
$this->chargerTableauManuel('statuts_culture');
|
82 |
delphine |
114 |
foreach ($this->donnees['info'] as $param => $valeur) {
|
|
|
115 |
if ($param == 'presence') {
|
|
|
116 |
$this->donnees['chorologie']['Présence']['France']['code'] = $valeur;
|
85 |
delphine |
117 |
$this->donnees['chorologie']['Présence']['France']['valeur'] = $this->tableau_manuel['presence'][$valeur];
|
82 |
delphine |
118 |
} elseif (preg_match('/presence_(.*)/', $param, $lieu)) {
|
|
|
119 |
$this->donnees['chorologie']['Présence'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
120 |
$this->donnees['chorologie']['Présence'][$lieu['1']]['valeur'] = $this->tableau_manuel['presence'][$valeur];
|
82 |
delphine |
121 |
} elseif ($param == 'statut_origine') {
|
|
|
122 |
$this->donnees['chorologie']['Statut d\'origine']['France']['code'] = $valeur;
|
85 |
delphine |
123 |
$this->donnees['chorologie']['Statut d\'origine']['France']['valeur'] =
|
|
|
124 |
$this->tableau_manuel['statuts_origine'][$valeur];
|
82 |
delphine |
125 |
} elseif (preg_match('/statut_origine_(.*)/', $param, $lieu)) {
|
|
|
126 |
$this->donnees['chorologie']['Statut d\'origine'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
127 |
$this->donnees['chorologie']['Statut d\'origine'][$lieu['1']]['valeur'] =
|
|
|
128 |
$this->tableau_manuel['statuts_origine'][$valeur];
|
82 |
delphine |
129 |
} elseif ($param == 'statut_introduction') {
|
|
|
130 |
$this->donnees['chorologie']['Statut d\'introduction']['France']['code'] = $valeur;
|
85 |
delphine |
131 |
$this->donnees['chorologie']['Statut d\'introduction']['France']['valeur'] =
|
|
|
132 |
$this->tableau_manuel['statuts_introduction'][$valeur];
|
82 |
delphine |
133 |
} elseif (preg_match('/statut_introduction_(.*)/', $param, $lieu)) {
|
|
|
134 |
$this->donnees['chorologie']['Statut d\'introduction'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
135 |
$this->donnees['chorologie']['Statut d\'introduction'][$lieu['1']]['valeur'] =
|
|
|
136 |
$this->tableau_manuel['statuts_introduction'][$valeur];
|
82 |
delphine |
137 |
} elseif ($param == 'statut_culture') {
|
|
|
138 |
$this->donnees['chorologie']['Statut de culture']['France']['code'] = $valeur;
|
85 |
delphine |
139 |
$this->donnees['chorologie']['Statut de culture']['France']['valeur'] =
|
|
|
140 |
$this->tableau_manuel['statuts_culture'][$valeur];
|
82 |
delphine |
141 |
} elseif (preg_match('/statut_culture_(.*)/', $param, $lieu)) {
|
|
|
142 |
$this->donnees['chorologie']['Statut de culture'][$lieu['1']]['code'] = $valeur;
|
85 |
delphine |
143 |
$this->donnees['chorologie']['Statut de culture'][$lieu['1']]['valeur'] =
|
|
|
144 |
$this->tableau_manuel['statuts_culture'][$valeur];
|
82 |
delphine |
145 |
}
|
|
|
146 |
}
|
110 |
jpm |
147 |
foreach ($this->donnees['chorologie']['Présence'] as $lieu => $valeur) {
|
82 |
delphine |
148 |
if (!isset($this->donnees['chorologie']['Statut d\'origine'][$lieu])) {
|
|
|
149 |
$this->donnees['chorologie']['Statut d\'origine'][$lieu]['code'] = '';
|
|
|
150 |
}
|
|
|
151 |
if (!isset($this->donnees['chorologie']['Statut d\'introduction'][$lieu])) {
|
|
|
152 |
$this->donnees['chorologie']['Statut d\'introduction'][$lieu]['code'] = '';
|
|
|
153 |
}
|
|
|
154 |
if (!isset($this->donnees['chorologie']['Statut de culture'][$lieu])) {
|
|
|
155 |
$this->donnees['chorologie']['Statut de culture'][$lieu]['code'] = '';
|
|
|
156 |
}
|
|
|
157 |
}
|
|
|
158 |
}
|
|
|
159 |
|
85 |
delphine |
160 |
private function chargerClassification() {
|
113 |
delphine |
161 |
$this->chargerTableauManuel('signification_rang');
|
243 |
delphine |
162 |
$this->chargerTableauManuel('presence');
|
113 |
delphine |
163 |
$this->donnees['valeur_rang'] = $this->tableau_manuel['signification_rang'];
|
243 |
delphine |
164 |
$this->donnees['valeur_presence'] = $this->tableau_manuel['presence'];
|
168 |
delphine |
165 |
if ($this->donnees['info']['num_tax_sup'] != '' && $this->donnees['info']['num_tax_sup'] !== "0") {
|
|
|
166 |
$this->donnees['classification']['supérieurs'] = array_reverse($this->taxonDao->getClassification
|
|
|
167 |
('Superieur', $this->referentiel, $this->donnees['info']['num_tax_sup']));
|
|
|
168 |
} elseif (isset($this->donnees['retenu']['num_tax_sup']) && ($this->donnees['retenu']['num_tax_sup'] != '')) {
|
|
|
169 |
$this->donnees['classification']['supérieurs'] = array_reverse($this->taxonDao->getClassification
|
85 |
delphine |
170 |
('Superieur', $this->referentiel, $this->donnees['retenu']['num_tax_sup']));
|
|
|
171 |
}
|
|
|
172 |
if ($this->donnees['num_nom_retenu'] != '') {
|
|
|
173 |
$class_inf = $this->taxonDao->getClassification
|
|
|
174 |
('Inferieur', $this->referentiel, $this->donnees['num_nom_retenu']);
|
168 |
delphine |
175 |
if ($class_inf != '') {
|
88 |
delphine |
176 |
$this->donnees['classification']['inférieurs'] = $class_inf['inf'];
|
|
|
177 |
$this->donnees['niveau'] = $class_inf['niveau'];
|
241 |
delphine |
178 |
arsort($class_inf['nb_par_rang']);
|
|
|
179 |
$this->donnees['noms_rang'] = $class_inf['nb_par_rang'];
|
|
|
180 |
}
|
85 |
delphine |
181 |
}
|
|
|
182 |
}
|
|
|
183 |
|
104 |
delphine |
184 |
private function chargerComplements() {
|
85 |
delphine |
185 |
$champs_manuel_technique = explode(',', $this->manuel['champs']);
|
|
|
186 |
$champs_base_donnees = key($this->donnees['info']);
|
|
|
187 |
$champs_supp_base = array_diff_key($this->donnees['info'], array_flip($champs_manuel_technique));
|
|
|
188 |
foreach ($champs_supp_base as $champ=>$valeur) {
|
|
|
189 |
if (!(preg_match('/presence_(.*)/',$champ) || preg_match('/statut_origine_(.*)/', $champ) ||
|
|
|
190 |
preg_match('/statut_introduction_(.*)/', $champ) || preg_match('/statut_culture_(.*)/', $champ))) {
|
|
|
191 |
$this->donnees['complement'][$champ] = $valeur;
|
|
|
192 |
}
|
|
|
193 |
}
|
|
|
194 |
}
|
|
|
195 |
|
82 |
delphine |
196 |
private function parserChaineDeRecherche($chaine) {
|
|
|
197 |
$mots = preg_split('/ /i', $chaine, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
198 |
$parametres = array('mots' => '');
|
|
|
199 |
$cle_precedente = null;
|
|
|
200 |
foreach ($mots as $mot) {
|
|
|
201 |
if (preg_match('/^(sg|gen|sp|ssp|au|an|nn|bib|nr|tax):(.*)$/', $mot, $match)) {
|
|
|
202 |
$cle = $match[1];
|
|
|
203 |
$cle_precedente = $cle;
|
|
|
204 |
$valeur = $match[2];
|
|
|
205 |
$parametres[$cle] = $valeur;
|
|
|
206 |
} else if (!is_null($cle_precedente)) {
|
|
|
207 |
$parametres[$cle_precedente] .= ' '.$mot;
|
|
|
208 |
} else if (is_null($cle_precedente)) {
|
|
|
209 |
if (empty($parametres['mots'])) {
|
|
|
210 |
$parametres['mots'] = $mot;
|
|
|
211 |
} else {
|
|
|
212 |
$parametres['mots'] .= ' '.$mot;
|
|
|
213 |
}
|
|
|
214 |
}
|
|
|
215 |
}
|
|
|
216 |
return $parametres;
|
|
|
217 |
}
|
|
|
218 |
|
88 |
delphine |
219 |
public function encodeChaine($chaine) {
|
|
|
220 |
if (Config::get('sortie_encodage') != Config::get('appli_encodage')) {
|
|
|
221 |
$chaine = mb_convert_encoding($chaine, Config::get('sortie_encodage'), Config::get('appli_encodage'));
|
|
|
222 |
}
|
|
|
223 |
$chaine = urlencode($chaine);
|
|
|
224 |
return $chaine;
|
|
|
225 |
}
|
|
|
226 |
|
82 |
delphine |
227 |
// retourne l'url de la fiche taxon pour les liens
|
295 |
aurelien |
228 |
public static function getUrlFicheTaxon($params, $type = '') {
|
78 |
delphine |
229 |
$taxon = null;
|
|
|
230 |
switch ($type) {
|
|
|
231 |
case 'bas' :
|
|
|
232 |
$taxon['num_nom'] = $params['bas_num'];
|
|
|
233 |
break;
|
|
|
234 |
case 'p1' :
|
|
|
235 |
$taxon['num_nom'] = $params['p1_num'];
|
|
|
236 |
break;
|
|
|
237 |
case 'p2' :
|
|
|
238 |
$taxon['num_nom'] = $params['p2_num'];
|
|
|
239 |
break;
|
245 |
delphine |
240 |
default : $taxon['num_nom'] = $params;
|
110 |
jpm |
241 |
break;
|
78 |
delphine |
242 |
}
|
|
|
243 |
return Recherche::getUrlFicheTaxon($taxon);
|
|
|
244 |
}
|
|
|
245 |
|
85 |
delphine |
246 |
// charger tableau de $this->manuel
|
|
|
247 |
private function chargerTableauManuel($titreTableau) {
|
|
|
248 |
$champs = explode(',', $this->manuel[$titreTableau]);
|
|
|
249 |
foreach ($champs as $champ) {
|
|
|
250 |
list($champ_nom, $type) = explode('=', trim($champ));
|
|
|
251 |
$this->tableau_manuel[$titreTableau][$champ_nom] = $type;
|
|
|
252 |
}
|
|
|
253 |
}
|
|
|
254 |
|
78 |
delphine |
255 |
|
|
|
256 |
}
|