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