Subversion Repositories eFlore/Applications.cel

Rev

Rev 1425 | Rev 1427 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1425 Rev 1426
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   jrest
6
* @package   jrest
7
* @author    David Delon <david@tela-botania.org>
7
* @author    David Delon <david@tela-botania.org>
8
* @author    Aurélien Peronnet <aurelien@tela-botania.org>
8
* @author    Aurélien Peronnet <aurelien@tela-botania.org>
9
* @copyright 2010 Tela-Botanica
9
* @copyright 2010 Tela-Botanica
10
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
* @version   SVN: <svn_id>
11
* @version   SVN: <svn_id>
12
* @link      /doc/jrest/
12
* @link      /doc/jrest/
13
*/
13
*/
14
 
14
 
15
/**
15
/**
16
 * 
16
 * 
17
 * La classe appelle les web service d'eflore pour éviter que le code client 
17
 * La classe appelle les web service d'eflore pour éviter que le code client 
18
 * ne soit dépendant de la version d'eflore
18
 * ne soit dépendant de la version d'eflore
19
 */
19
 */
20
class RechercheInfosTaxonBeta extends Cel {
20
class RechercheInfosTaxonBeta extends Cel {
21
	
21
	
22
	public function RechercheInfosTaxonBeta($config) {		
22
	public function RechercheInfosTaxonBeta($config) {		
23
		parent::__construct($config);
23
		parent::__construct($config);
24
	}
24
	}
25
	
25
	
26
	public function rechercherGenreEspeceSurPrefixe($genre = null, $espece = null) {
26
	public function rechercherGenreEspeceSurPrefixe($genre = null, $espece = null) {
27
		
27
		
28
		$liste_genre_espece = array();	
28
		$liste_genre_espece = array();	
29
		$masque = urlencode(trim(trim($genre).' '.trim($espece,' *')));
29
		$masque = urlencode(trim(trim($genre).' '.trim($espece,' *')));
30
		$requete = @file_get_contents('http://localhost/service:eflore:0.1/bdtfx/noms?masque='.$masque.'&recherche=etendue&retour.format=min&navigation.limite=50&ns.structure=au');
30
		$requete = @file_get_contents('http://localhost/service:eflore:0.1/bdtfx/noms?masque='.$masque.'&recherche=etendue&retour.format=min&navigation.limite=50&ns.structure=au');
31
		
31
		
32
		if($requete != '') {
32
		if($requete != '') {
33
			$requete = json_decode($requete);		
33
			$requete = json_decode($requete);		
34
			if(is_object($requete) && isset($requete->resultat)) {
34
			if(is_object($requete) && isset($requete->resultat)) {
35
				foreach ($requete->resultat as $id => $res) {
35
				foreach ($requete->resultat as $id => $res) {
36
					$retenu = $res->retenu == true ? '3' : '';
36
					$retenu = $res->retenu == true ? '3' : '';
37
					$liste_genre_espece[] = array($res->nom_sci_complet, $id, $retenu);
37
					$liste_genre_espece[] = array($res->nom_sci_complet, $id, $retenu);
38
				}
38
				}
39
			}
39
			}
40
			usort($liste_genre_espece, array($this, 'comparerParNom'));  
40
			usort($liste_genre_espece, array($this, 'comparerParNom'));  
41
		}
41
		}
42
		return $liste_genre_espece;
42
		return $liste_genre_espece;
43
	}
43
	}
44
	
44
	
45
	function comparerParNom($a, $b) {
45
	function comparerParNom($a, $b) {
46
		return strnatcmp($a[0], $b[0]); 
46
		return strnatcmp($a[0], $b[0]); 
47
	}
47
	}
48
	
48
	
49
	public function effectuerRequeteInfosComplementairesEtFormaterNom($numNom) {
49
	public function effectuerRequeteInfosComplementairesEtFormaterNom($numNom) {
50
		
50
		
51
		$resultat_infos_complementaires = (array)$this->effectuerRequeteInfosComplementairesSurNumNom($numNom);
51
		$resultat_infos_complementaires = (array)$this->effectuerRequeteInfosComplementairesSurNumNom($numNom);
52
		$retour_infos_complementaires = array();
52
		$retour_infos_complementaires = array();
53
		if (isset($resultat_infos_complementaires['nom_retenu_complet']) && $resultat_infos_complementaires['nom_retenu_complet'] != '') {
53
		if (isset($resultat_infos_complementaires['nom_retenu_complet']) && $resultat_infos_complementaires['nom_retenu_complet'] != '') {
54
           	$retour_infos_complementaires=array(($this->supprimerBiblio($resultat_infos_complementaires['nom_retenu_complet'])));
54
           	$retour_infos_complementaires=array(($this->supprimerBiblio($resultat_infos_complementaires['nom_retenu_complet'])));
55
	    }
55
	    }
56
		
56
		
57
		return $retour_infos_complementaires;
57
		return $retour_infos_complementaires;
58
	}
58
	}
59
	
59
	
60
	public function rechercherInformationsComplementairesSurNom($nom_saisi) {
60
	public function rechercherInformationsComplementairesSurNom($nom_saisi) {
61
		
61
		
62
		$nameparser = new NameParser();
62
		$nameparser = new NameParser();
63
		$nom_decoupe = $nameparser->parse($nom_saisi);
63
		$nom_decoupe = $nameparser->parse($nom_saisi);
64
		
64
		
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;
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=3000';
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';
-
 
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)) {
75
				foreach ($resultat->resultat as $id => $res) {
76
				foreach ($resultat->resultat as $id => $res) {
76
					$nom_complet = $res->{'nom_sci'}.' '.$res->auteur;
77
					$nom_complet = $res->{'nom_sci'}.' '.$res->auteur;
77
					$liste_genre_espece[] = array($res->{'nom_retenu.id'},$nom_complet);
78
					$liste_genre_espece[] = array($res->{'nom_retenu.id'},$nom_complet);
78
				}
79
				}
79
			}
80
			}
80
		}
81
		}
81
		return $liste_genre_espece;
82
		return $liste_genre_espece;
82
	}
83
	}
83
	
84
	
84
	public function rechercherInformationsComplementairesSurNumNom($num_nom) {
85
	public function rechercherInformationsComplementairesSurNumNom($num_nom) {
85
		$infos_formatees = array();
86
		$infos_formatees = array();
86
		$infos = $this->effectuerRequeteInfosComplementairesSurNumNom($num_nom);
87
		$infos = $this->effectuerRequeteInfosComplementairesSurNumNom($num_nom);
87
		if(is_object($infos)) {
88
		if(is_object($infos)) {
88
			$infos_formatees = $this->formaterInfosComplementairesSurNumNom($infos);
89
			$infos_formatees = $this->formaterInfosComplementairesSurNumNom($infos);
89
		}
90
		}
90
		return $infos_formatees;
91
		return $infos_formatees;
91
	}
92
	}
92
	
93
	
93
	public function effectuerRequeteInfosComplementairesSurNumNom($num_nom) {
94
	public function effectuerRequeteInfosComplementairesSurNumNom($num_nom) {
94
		$infos = array();
95
		$infos = array();
95
		//TODO: retourner moins de champs grâce au paramètre retour.champs
96
		//TODO: retourner moins de champs grâce au paramètre retour.champs
96
		$url = "http://www.tela-botanica.org/service:eflore:0.1/bdtfx/noms/".$num_nom;
97
		$url = "http://www.tela-botanica.org/service:eflore:0.1/bdtfx/noms/".$num_nom;
97
		$resultat = @file_get_contents($url);
98
		$resultat = @file_get_contents($url);
98
		if($resultat != '') {
99
		if($resultat != '') {
99
			$infos = json_decode($resultat);
100
			$infos = json_decode($resultat);
100
		}
101
		}
101
		return $infos;
102
		return $infos;
102
	}
103
	}
103
	
104
	
104
	private function formaterInfosComplementairesSurNumNom($infos) {
105
	private function formaterInfosComplementairesSurNumNom($infos) {
105
		$infos = (array)$infos;
106
		$infos = (array)$infos;
106
		return $infos_formatees = array(
107
		return $infos_formatees = array(
107
			'Nom_Retenu' => $this->supprimerBiblio($infos['nom_retenu_complet']),
108
			'Nom_Retenu' => $this->supprimerBiblio($infos['nom_retenu_complet']),
108
			'Num_Nom_Retenu' => $infos['nom_retenu.id'],
109
			'Num_Nom_Retenu' => $infos['nom_retenu.id'],
109
			'Num_Taxon' => $infos['num_taxonomique'],
110
			'Num_Taxon' => $infos['num_taxonomique'],
110
			'Famille' => $infos['famille']
111
			'Famille' => $infos['famille']
111
		);
112
		);
112
	}
113
	}
113
	
114
	
114
	private function supprimerBiblio($nom) {
115
	private function supprimerBiblio($nom) {
115
		return preg_replace('/ \[.*\]/','',$nom);
116
		return preg_replace('/ \[.*\]/','',$nom);
116
	}
117
	}
117
	
118
	
118
	public function rechercherNumTaxSurNumNom($num_nom) {
119
	public function rechercherNumTaxSurNumNom($num_nom) {
119
	
120
	
120
		$nt = null;
121
		$nt = null;
121
		$url = "http://www.tela-botanica.org/service:eflore:0.1/bdtfx/noms/".$num_nom.'?retour.champs=num_taxonomique';
122
		$url = "http://www.tela-botanica.org/service:eflore:0.1/bdtfx/noms/".$num_nom.'?retour.champs=num_taxonomique';
122
		$resultat = @file_get_contents($url);
123
		$resultat = @file_get_contents($url);
123
		if($resultat != '') {
124
		if($resultat != '') {
124
			$infos = json_decode($resultat);
125
			$infos = json_decode($resultat);
125
			$nt = $infos->num_taxonomique;
126
			$nt = $infos->num_taxonomique;
126
		}
127
		}
127
	
128
	
128
		return $nt;
129
		return $nt;
129
	}
130
	}
130
	
131
	
131
	public function taxonEstPresentDansDepartement($num_taxon,$code_departement) {
132
	public function taxonEstPresentDansDepartement($num_taxon,$code_departement) {
132
		$presence_taxon = false;
133
		$presence_taxon = false;
133
		$url = 'http://localhost/service:eflore:0.1/chorodep/observations/?masque.departement='.$code_departement.'&masque.determination.nt='.$num_taxon.'&navigation.limite=1';
134
		$url = 'http://localhost/service:eflore:0.1/chorodep/observations/?masque.departement='.$code_departement.'&masque.determination.nt='.$num_taxon.'&navigation.limite=1';
134
		$resultat = @file_get_contents($url);
135
		$resultat = @file_get_contents($url);
135
		if($resultat != '') {
136
		if($resultat != '') {
136
			$resultat = json_decode($resultat);
137
			$resultat = json_decode($resultat);
137
			if(is_object($resultat) && isset($resultat->resultat) && count($resultat->resultat) > 0) {
138
			if(is_object($resultat) && isset($resultat->resultat) && count($resultat->resultat) > 0) {
138
				$presence_taxon = true;
139
				$presence_taxon = true;
139
			}
140
			}
140
		}
141
		}
141
		return $presence_taxon;
142
		return $presence_taxon;
142
	}
143
	}
143
	
144
	
144
	public function effectuerRequeteInfosComplementairesSurNumTax($numTax) {
145
	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) {
-
 
175
	
146
		
176
		$row = array();
-
 
177
	
147
		$infos = array();
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 ".
-
 
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 ".
149
		$url = "http://www.tela-botanica.org/service:eflore:0.1/bdtfx/taxons/nt:".$numTax;
184
		" AND etr_id_categorie_taxon = 3 ".
-
 
185
		" AND etr_id_valeur_taxon = 3 ".
-
 
186
		" AND esn_id_taxon =  etr_id_taxon_2 ".
150
		$resultat = @file_get_contents($url);
187
		" AND esn_ce_statut = 3 ".
-
 
188
		" AND esn_id_version_projet_taxon = etr_id_version_projet_taxon_1 ".
151
		if($resultat != '') {
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 {
-
 
197
	    	$resultat_recherche_famille = $resultat_recherche_famille[0];
152
			$infos = json_decode($resultat);
198
	    }
153
		}
199
	
154
 
200
		return $resultat_recherche_famille;
155
		return $infos;
201
	}
156
	}
202
	
157
	
203
	private function decouperNomEtRechercheEspeceOuSousEspece($identifiant_espece) {
158
	private function decouperNomEtRechercheEspeceOuSousEspece($identifiant_espece) {
204
		$nameparser=new NameParser();
159
		$nameparser=new NameParser();
205
		$nom_latin_decoupe=$nameparser->parse($identifiant_espece);
160
		$nom_latin_decoupe=$nameparser->parse($identifiant_espece);
206
		// requete sous espece (on privilegie les noms retenu cf tri par esn_ce_statut)
161
		// requete sous espece (on privilegie les noms retenu cf tri par esn_ce_statut)
207
		if (isset($nom_latin_decoupe['infra']) && $nom_latin_decoupe['infra']!="") {
162
		if (isset($nom_latin_decoupe['infra']) && $nom_latin_decoupe['infra']!="") {
208
			$requete="SELECT DISTINCT en_id_nom, esn_ce_statut" .
163
			$requete="SELECT DISTINCT en_id_nom, esn_ce_statut" .
209
            	" FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
164
            	" FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
210
            	" WHERE en_id_version_projet_nom = '25' AND en_nom_genre = ".$this->proteger($nom_latin_decoupe['genus'])." " .
165
            	" WHERE en_id_version_projet_nom = '25' AND en_nom_genre = ".$this->proteger($nom_latin_decoupe['genus'])." " .
211
                " AND enrg_abreviation_rang = ".$this->proteger($nom_latin_decoupe['infra_type'])." " .
166
                " AND enrg_abreviation_rang = ".$this->proteger($nom_latin_decoupe['infra_type'])." " .
212
                " AND en_epithete_infra_specifique = ".$this->proteger($nom_latin_decoupe['infra'])." " .
167
                " AND en_epithete_infra_specifique = ".$this->proteger($nom_latin_decoupe['infra'])." " .
213
                " AND esn_id_nom= en_id_nom ".
168
                " AND esn_id_nom= en_id_nom ".
214
                " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
169
                " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
215
                " AND en_epithete_espece =  ".$this->proteger($nom_latin_decoupe['species'])." AND en_ce_rang = enrg_id_rang " .
170
                " AND en_epithete_espece =  ".$this->proteger($nom_latin_decoupe['species'])." AND en_ce_rang = enrg_id_rang " .
216
                " ORDER BY esn_ce_statut ".
171
                " ORDER BY esn_ce_statut ".
217
                " LIMIT 1";
172
                " LIMIT 1";
218
		}
173
		}
219
		else { // espece  (on privilegie les noms retenu cf tri par esn_ce_statut)
174
		else { // espece  (on privilegie les noms retenu cf tri par esn_ce_statut)
220
			$requete="SELECT DISTINCT en_id_nom, esn_ce_statut" .
175
			$requete="SELECT DISTINCT en_id_nom, esn_ce_statut" .
221
				" FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
176
				" FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
222
				" WHERE en_id_version_projet_nom = '25' AND en_nom_genre = ".$this->proteger($nom_latin_decoupe['genus'])." " .
177
				" WHERE en_id_version_projet_nom = '25' AND en_nom_genre = ".$this->proteger($nom_latin_decoupe['genus'])." " .
223
				" AND enrg_abreviation_rang = 'sp.' " .
178
				" AND enrg_abreviation_rang = 'sp.' " .
224
				" AND esn_id_nom= en_id_nom ".
179
				" AND esn_id_nom= en_id_nom ".
225
				" AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
180
				" AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
226
				" AND en_epithete_espece =  ".$this->proteger($nom_latin_decoupe['species'])." AND en_ce_rang = enrg_id_rang " .
181
				" AND en_epithete_espece =  ".$this->proteger($nom_latin_decoupe['species'])." AND en_ce_rang = enrg_id_rang " .
227
				" ORDER BY esn_ce_statut ".
182
				" ORDER BY esn_ce_statut ".
228
				" LIMIT 1";
183
				" LIMIT 1";
229
		
184
		
230
		}
185
		}
231
		
186
		
232
		$resultat = $this->executerRequete($requete);
187
		$resultat = $this->executerRequete($requete);
233
		
188
		
234
		$retour = array();
189
		$retour = array();
235
		if (is_array($resultat) && count($resultat) > 0) {
190
		if (is_array($resultat) && count($resultat) > 0) {
236
			$retour = $resultat[0];
191
			$retour = $resultat[0];
237
		}
192
		}
238
		
193
		
239
		return $retour;
194
		return $retour;
240
	}
195
	}
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
	}
-
 
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);
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 { 
211
		} else { 
315
			//  Numero taxonomique ou nom scientifique
212
			//  Numero taxonomique ou nom scientifique
316
			preg_match('/BDNFFnt([0-9][0-9]*)/', $identifiant_espece, $elements);
213
			preg_match('/BDNFFnt([0-9][0-9]*)/', $identifiant_espece, $elements);
317
	
-
 
318
			if (isset($elements[1])) {
214
			if (isset($elements[1])) {
319
				// Numero taxonomique
215
				// Numero taxonomique
320
				$infos_taxon = $this->effectuerRequeteInfosComplementairesSurNumTax($elements[1]);
216
				$infos_taxon = (array)$this->effectuerRequeteInfosComplementairesSurNumTax($elements[1]);
-
 
217
				if(isset($infos_taxon['nom_retenu.libelle']) && isset($infos_taxon['id'])) {
321
				$infos_taxon = $infos_taxon[0];
218
					$nom = $infos_taxon['nom_retenu.libelle'];
322
				$retour = array("nom_sel" => $this->formaterNom($infos_taxon), "en_id_nom" => $infos_taxon['en_id_nom']);
219
					$nom .= (isset($infos_taxon['auteur'])) ? ' '.$infos_taxon['auteur'] : '';
-
 
220
					$retour = array("nom_sel" => $nom, 
-
 
221
									"en_id_nom" => $infos_taxon['id']);
-
 
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);
326
				// Recherche du nom associe
226
				// Recherche du nom associe
327
				$retour = array("nom_sel" => $identifiant_espece);
227
				$retour = array("nom_sel" => $identifiant_espece);
328
				if(is_array($id_nom) && isset($id_nom['en_id_nom'])) {
228
				if(is_array($id_nom) && count($id_nom) > 0 && isset($id_nom[0][0])) {
-
 
229
					$nn = $id_nom[0][0];
329
					$infos_nom = $this->effectuerRequeteInfosComplementairesSurNumNom($id_nom['en_id_nom']);
230
					$infos_nom = (array)$this->effectuerRequeteInfosComplementairesSurNumNom($nn);
330
					if (is_array($infos_nom) && !empty($infos_nom)) {
231
					if (is_array($infos_nom) && !empty($infos_nom)) {
331
						$infos_nom = $infos_nom[0];
-
 
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
					}
334
				}
234
				}
335
			}
235
			}
336
		}
236
		}
337
		
237
		
338
		return $retour;
238
		return $retour;
339
	}
239
	}
340
}
240
}
341
?>
241
?>