Subversion Repositories eFlore/Applications.cel

Rev

Rev 1425 | Rev 1427 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1425 Rev 1426
Line 65... Line 65...
65
		$masque = ((isset($nom_decoupe['genus']) && $nom_decoupe['genus']!= '') && 
65
		$masque = ((isset($nom_decoupe['genus']) && $nom_decoupe['genus']!= '') && 
66
				  (isset($nom_decoupe['species']) && $nom_decoupe['species']!= ''))
66
				  (isset($nom_decoupe['species']) && $nom_decoupe['species']!= ''))
67
				  ? $nom_decoupe['genus'].' '.$nom_decoupe['species'] : $nom_saisi;
67
				  ? $nom_decoupe['genus'].' '.$nom_decoupe['species'] : $nom_saisi;
Line 68... Line 68...
68
		
68
		
69
		$liste_genre_espece = array();
69
		$liste_genre_espece = array();
-
 
70
		$url = 'http://www.tela-botanica.org/service:eflore:0.1/bdtfx/noms?masque='.urlencode($nom_decoupe['genus'].' '.$nom_decoupe['species']).'&recherche=etendue&ns.format=txt&retour.champs=nom_retenu,nom_retenu.*,num_taxonomique,auteur&navigation.limite=1';
70
		$url = 'http://www.tela-botanica.org/service:eflore:0.1/bdtfx/noms?masque='.urlencode($nom_decoupe['genus'].' '.$nom_decoupe['species']).'&recherche=etendue&ns.format=txt&retour.champs=nom_retenu,nom_retenu.*,num_taxonomique,auteur&navigation.limite=3000';
71
 
71
		$resultat = @file_get_contents($url);
72
		$resultat = @file_get_contents($url);
72
		if($resultat != '') {
73
		if($resultat != '') {
73
			$resultat = json_decode($resultat);
74
			$resultat = json_decode($resultat);
74
			if(is_object($resultat) && isset($resultat->resultat)) {
75
			if(is_object($resultat) && isset($resultat->resultat)) {
Line 141... Line 142...
141
		return $presence_taxon;
142
		return $presence_taxon;
142
	}
143
	}
Line 143... Line 144...
143
	
144
	
Line 144... Line -...
144
	public function effectuerRequeteInfosComplementairesSurNumTax($numTax) {
-
 
145
		
-
 
146
		$requete_infos_complementaires = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
-
 
147
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
-
 
148
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
-
 
149
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
-
 
150
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
-
 
151
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
-
 
152
                    " FROM eflore_nom, eflore_nom_rang," .
-
 
153
                    "     eflore_naturaliste_intitule_abreviation AS auteur_bex ".
-
 
154
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
-
 
155
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
-
 
156
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
-
 
157
                    " , eflore_selection_nom ".
-
 
158
                    " WHERE esn_id_taxon = '".$numTax. "'".
-
 
159
                    " AND esn_id_version_projet_taxon = 25 ".
-
 
160
                    " AND esn_ce_statut=3 ".
-
 
161
                    " AND en_id_nom = esn_id_nom" .
-
 
162
                    " AND en_ce_rang = enrg_id_rang" .
-
 
163
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
-
 
164
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
-
 
165
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
-
 
166
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
-
 
167
                    " AND esn_id_version_projet_taxon=en_id_version_projet_nom ";
-
 
168
		
-
 
169
		$resultat_infos_complementaires = $this->executerRequete($requete_infos_complementaires);
-
 
170
		
-
 
171
		return $resultat_infos_complementaires;
-
 
172
	}
-
 
173
	
-
 
174
	public function rechercherFamille($taxon) {
145
	public function effectuerRequeteInfosComplementairesSurNumTax($numTax) {
175
	
-
 
176
		$row = array();
146
		
177
	
-
 
178
		$requete_famille = "SELECT DISTINCT en_ce_rang, etr_id_taxon_2, en_id_nom, en_nom_supra_generique ".
-
 
179
		" FROM eflore_taxon_relation, ".
-
 
180
		" eflore_selection_nom, ".
-
 
181
		" eflore_nom ".
147
		$infos = array();
182
		" WHERE etr_id_taxon_1 = ".$taxon.
148
		//TODO: retourner moins de champs grâce au paramètre retour.champs
183
		" AND etr_id_version_projet_taxon_1 = 25 ".
-
 
184
		" AND etr_id_categorie_taxon = 3 ".
-
 
185
		" AND etr_id_valeur_taxon = 3 ".
149
		$url = "http://www.tela-botanica.org/service:eflore:0.1/bdtfx/taxons/nt:".$numTax;
186
		" AND esn_id_taxon =  etr_id_taxon_2 ".
-
 
187
		" AND esn_ce_statut = 3 ".
150
		$resultat = @file_get_contents($url);
188
		" AND esn_id_version_projet_taxon = etr_id_version_projet_taxon_1 ".
-
 
189
		" AND en_id_nom = esn_id_nom ".
-
 
190
		" AND esn_id_version_projet_taxon=en_id_version_projet_nom  ";
-
 
191
				
-
 
192
		$resultat_recherche_famille = $this->executerRequete($requete_famille);
-
 
193
		
-
 
194
		if (!is_array($resultat_recherche_famille) || count($resultat_recherche_famille) == 0) {	
-
 
195
	    	$resultat_recherche_famille = array('en_ce_rang' => 'fin');
-
 
196
	    } else {
151
		if($resultat != '') {
197
	    	$resultat_recherche_famille = $resultat_recherche_famille[0];
152
			$infos = json_decode($resultat);
198
	    }
153
		}
199
	
154
 
Line 200... Line 155...
200
		return $resultat_recherche_famille;
155
		return $infos;
201
	}
156
	}
202
	
157
	
Line 237... Line 192...
237
		}
192
		}
Line 238... Line 193...
238
		
193
		
239
		return $retour;
194
		return $retour;
Line 240... Line -...
240
	}
-
 
241
	
-
 
242
	private function formaterNom($rawnom) {
-
 
243
 
-
 
244
        // Constitution du nom:
-
 
245
        $nom = '';
-
 
246
 
-
 
247
        if (isset($rawnom['en_nom_supra_generique']) && $rawnom['en_nom_supra_generique'] != '') {
-
 
248
            $nom .= $rawnom['en_nom_supra_generique'];
-
 
249
        } else if (isset($rawnom['en_epithete_infra_generique']) && $rawnom['en_epithete_infra_generique'] != '') {
-
 
250
            $nom .= $rawnom['en_epithete_infra_generique'];
-
 
251
        } else {
-
 
252
            if (isset($rawnom['en_nom_genre']) &&  $rawnom['en_nom_genre'] != '') {
-
 
253
                $nom .=  $rawnom['en_nom_genre'];
-
 
254
            }
-
 
255
            if (isset($rawnom['en_epithete_espece']) &&  $rawnom['en_epithete_espece']!= '') {
-
 
256
                $nom .= ' '.$rawnom['en_epithete_espece'];
-
 
257
            }
-
 
258
            if (isset($rawnom['en_epithete_infra_specifique']) &&  $rawnom['en_epithete_infra_specifique'] != '') {
-
 
259
                if (!empty($rawnom['enrg_abreviation_rang'])) {
-
 
260
                        $nom .= ' '.$rawnom['enrg_abreviation_rang'].'';
-
 
261
                }
-
 
262
                $nom .= ' '.$rawnom['en_epithete_infra_specifique'];
-
 
263
            }
-
 
264
        }
-
 
265
 
-
 
266
        return $nom.$this->retournerAuteur($rawnom) ;
-
 
267
 	}
-
 
268
 
-
 
269
	private function retournerAuteur($rawnom) {
-
 
270
		$auteurs = '';
-
 
271
		$auteur_basio = '';
-
 
272
		$auteur_modif = '';
-
 
273
		if (!empty($rawnom['abreviation_auteur_basio_ex']) && $rawnom['abreviation_auteur_basio_ex']!='-' )  {
-
 
274
		    $auteur_basio .= $rawnom['abreviation_auteur_basio_ex'];
-
 
275
		    if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
-
 
276
		        $auteur_basio .= ' ex '.$rawnom['abreviation_auteur_basio'];
-
 
277
		    }
-
 
278
		} else if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
-
 
279
		    $auteur_basio .= $rawnom['abreviation_auteur_basio'];
-
 
280
		}
-
 
281
 
-
 
282
		if (!empty($rawnom['abreviation_auteur_modif_ex']) && $rawnom['abreviation_auteur_modif_ex']!='-') {
-
 
283
		    $auteur_modif .= $rawnom['abreviation_auteur_modif_ex'];
-
 
284
		    if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-') {
-
 
285
		        $auteur_modif .= ' ex '.$rawnom['abreviation_auteur_modif'];
-
 
286
		    }
-
 
287
		} else if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-')  {
-
 
288
		    $auteur_modif .= $rawnom['abreviation_auteur_modif'];
-
 
289
		}
-
 
290
 
-
 
291
		if (!empty($auteur_modif)) {
-
 
292
		    $auteurs = ' ('.$auteur_basio.') '.$auteur_modif;
-
 
293
		} elseif (!empty($auteur_basio)) {
-
 
294
		    $auteurs = ' '.$auteur_basio;
-
 
295
		}
-
 
296
 
-
 
297
		return $auteurs ;
-
 
298
	}
195
	}
299
	
196
	
300
	function rechercherInfosSurTexteCodeOuNumTax($identifiant_espece) {
197
	function rechercherInfosSurTexteCodeOuNumTax($identifiant_espece) {
301
		// texte libre, nom scientifique, 
198
		// texte libre, nom scientifique, 
302
		// ou code nomenclatural (format BDNFFnn999999) 
199
		// ou code nomenclatural (format BDNFFnn999999) 
303
		// ou code taxonomique (format BDNFFnt999999)
200
		// ou code taxonomique (format BDNFFnt999999)
304
		$identifiant_espece=trim($identifiant_espece);
201
		$identifiant_espece=trim($identifiant_espece);
305
		$identifiant_espece=utf8_encode($identifiant_espece);
202
		$identifiant_espece=utf8_encode($identifiant_espece);
Line 306... Line 203...
306
	
203
		
307
		$retour = array();
204
		$retour = array();
308
		
205
		
309
		preg_match('/BDNFFnn([0-9][0-9]*)/',$identifiant_espece, $elements);
206
		preg_match('/BDNFFnn([0-9][0-9]*)/',$identifiant_espece, $elements);
310
		if (isset($elements[1])) {
207
		if (isset($elements[1])) {
311
			// Numero nomenclatural
208
			// Numero nomenclatural
312
			$infos_taxon = $this->rechercherInformationsComplementairesSurNumNom($elements[1]);
209
			$infos_taxon = $this->rechercherInformationsComplementairesSurNumNom($elements[1]);
313
			$retour = array("nom_sel" => $this->formaterNom($infos_taxon), "en_id_nom" => $elements[1]);
210
			$retour = array("nom_sel" => $infos_taxon['Nom_Retenu'], "en_id_nom" => $elements[1]);
314
		} else { 
-
 
315
			//  Numero taxonomique ou nom scientifique
211
		} else { 
316
			preg_match('/BDNFFnt([0-9][0-9]*)/', $identifiant_espece, $elements);
212
			//  Numero taxonomique ou nom scientifique
317
	
213
			preg_match('/BDNFFnt([0-9][0-9]*)/', $identifiant_espece, $elements);
-
 
214
			if (isset($elements[1])) {
318
			if (isset($elements[1])) {
215
				// Numero taxonomique
319
				// Numero taxonomique
216
				$infos_taxon = (array)$this->effectuerRequeteInfosComplementairesSurNumTax($elements[1]);
-
 
217
				if(isset($infos_taxon['nom_retenu.libelle']) && isset($infos_taxon['id'])) {
-
 
218
					$nom = $infos_taxon['nom_retenu.libelle'];
-
 
219
					$nom .= (isset($infos_taxon['auteur'])) ? ' '.$infos_taxon['auteur'] : '';
320
				$infos_taxon = $this->effectuerRequeteInfosComplementairesSurNumTax($elements[1]);
220
					$retour = array("nom_sel" => $nom, 
321
				$infos_taxon = $infos_taxon[0];
221
									"en_id_nom" => $infos_taxon['id']);
322
				$retour = array("nom_sel" => $this->formaterNom($infos_taxon), "en_id_nom" => $infos_taxon['en_id_nom']);
222
				}
323
			} else { 
223
			} else { 
324
				// Nom scientifique
224
				// Nom scientifique
325
				$id_nom = $this->decouperNomEtRechercheEspeceOuSousEspece($identifiant_espece);	
225
				$id_nom = $this->rechercherInformationsComplementairesSurNom($identifiant_espece);
-
 
226
				// Recherche du nom associe
326
				// Recherche du nom associe
227
				$retour = array("nom_sel" => $identifiant_espece);
327
				$retour = array("nom_sel" => $identifiant_espece);
228
				if(is_array($id_nom) && count($id_nom) > 0 && isset($id_nom[0][0])) {
328
				if(is_array($id_nom) && isset($id_nom['en_id_nom'])) {
-
 
329
					$infos_nom = $this->effectuerRequeteInfosComplementairesSurNumNom($id_nom['en_id_nom']);
229
					$nn = $id_nom[0][0];
330
					if (is_array($infos_nom) && !empty($infos_nom)) {
230
					$infos_nom = (array)$this->effectuerRequeteInfosComplementairesSurNumNom($nn);
331
						$infos_nom = $infos_nom[0];
231
					if (is_array($infos_nom) && !empty($infos_nom)) {
332
						$retour = array("nom_sel" => $this->formaterNom($infos_nom), "en_id_nom" => $id_nom['en_id_nom']);
232
						$retour = array("nom_sel" => $infos_nom['nom_sci'].' '.$infos_nom['auteur'], "en_id_nom" => $infos_nom['id']);
333
					}
233
					}