Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 996 Rev 1081
1
<?php
1
<?php
2
// In : utf8
2
// In : utf8
3
// Out : utf8
3
// Out : utf8
4
 
4
 
5
 
5
 
6
// TODO : traiter image multilignes
6
// TODO : traiter image multilignes
7
// TODO : doublons
7
// TODO : doublons
8
 
8
 
9
/*
9
/*
10
 
10
 
11
Octobre 2010 David Delon.
11
Octobre 2010 David Delon.
12
Import d'observations dans le carnet en ligne à partir d'un fichier excel chargé par l'utilisateur
12
Import d'observations dans le carnet en ligne à partir d'un fichier excel chargé par l'utilisateur
13
et liaison d'images déjà chargee aux observations ainsi crées.
13
et liaison d'images déjà chargee aux observations ainsi crées.
14
 
14
 
15
Nom des colonnes imposé, mais présence de toutes les colonnes non obligatoires, ordre non imposé
15
Nom des colonnes imposé, mais présence de toutes les colonnes non obligatoires, ordre non imposé
16
Aucune valeur dans les colonnes n'est obligatoire
16
Aucune valeur dans les colonnes n'est obligatoire
17
Pour une ligne donnée, si tous les champs vides on ne fait rien, ou si seul le champ image est présent.
17
Pour une ligne donnée, si tous les champs vides on ne fait rien, ou si seul le champ image est présent.
18
Si la seule différence entre deux lignes est la valeur de la colonne image, on considère que c'est la même observation à laquelle on associe plusieurs images.
18
Si la seule différence entre deux lignes est la valeur de la colonne image, on considère que c'est la même observation à laquelle on associe plusieurs images.
19
Si au moins deux lignes (ou plus) sont complètement identiques on prend en compte une seule ligne (les doublons sont éliminés).
19
Si au moins deux lignes (ou plus) sont complètement identiques on prend en compte une seule ligne (les doublons sont éliminés).
20
 
20
 
21
*/
21
*/
22
 
22
 
23
 
23
 
24
// Nom des colonnes
24
// Nom des colonnes
25
 
25
 
26
define('COMMUNE','commune'); // soit un nom de commune, soit un code INSEE (5 chiffres), ou "nom de commune (numero departement)"
26
define('COMMUNE','commune'); // soit un nom de commune, soit un code INSEE (5 chiffres), ou "nom de commune (numero departement)"
27
define('LIEUDIT','lieu-dit'); // Texte libre
27
define('LIEUDIT','lieu-dit'); // Texte libre
28
define('STATION','station'); // Texte libre
28
define('STATION','station'); // Texte libre
29
define('MILIEU','milieu'); // Texte libre
29
define('MILIEU','milieu'); // Texte libre
30
define('LATITUDE','latitude'); // En decimal systeme WGS84
30
define('LATITUDE','latitude'); // En decimal systeme WGS84
31
define('LONGITUDE','longitude'); // En decimal systeme WGS84 
31
define('LONGITUDE','longitude'); // En decimal systeme WGS84 
32
define('NOTES','notes'); // Texte libre
32
define('NOTES','notes'); // Texte libre
33
define('DATEOBS','date'); // date au format jj/mm/aaaa
33
define('DATEOBS','date'); // date au format jj/mm/aaaa
34
define('ESPECE','espece'); // texte libre, nom latin, ou code nomenclatural (format BDNFFnn999999)
34
define('ESPECE','espece'); // texte libre, nom latin, ou code nomenclatural (format BDNFFnn999999)
35
define('IMAGE','image'); //  nom des fichiers images préalablement uploadés sur le CEL séparés par des "/"
35
define('IMAGE','image'); //  nom des fichiers images préalablement uploadés sur le CEL séparés par des "/"
36
define('DEPARTEMENT','departement'); //  Texte libre
36
define('DEPARTEMENT','departement'); //  Texte libre
37
define('TRANSMETTRE','transmettre'); //  "1" ou "oui", toute autre valeur (y compris vide) sera consideree comme "non""
37
define('TRANSMETTRE','transmettre'); //  "1" ou "oui", toute autre valeur (y compris vide) sera consideree comme "non""
38
 
38
 
39
 
39
 
40
// Resultat de l'analyse d'une ligne
40
// Resultat de l'analyse d'une ligne
41
define('LIGNE_VIDE',1); //  
41
define('LIGNE_VIDE',1); //  
42
define('LIGNE_NORMALE',2); //  
42
define('LIGNE_NORMALE',2); //  
43
define('LIGNE_IMAGE_SEULEMENT',3); //  
43
define('LIGNE_IMAGE_SEULEMENT',3); //  
44
 
44
 
45
class InventoryImportExcel extends Cel  {
45
class InventoryImportExcel extends Cel  {
46
 
46
 
47
// Element constituant une observation 
47
// Element constituant une observation 
48
 
48
 
49
	var $format_observation=array(COMMUNE ,LIEUDIT ,STATION , DEPARTEMENT, MILIEU ,LATITUDE ,LONGITUDE ,NOTES ,DATEOBS ,ESPECE ,TRANSMETTRE, IMAGE );
49
	var $format_observation=array(COMMUNE ,LIEUDIT ,STATION , DEPARTEMENT, MILIEU ,LATITUDE ,LONGITUDE ,NOTES ,DATEOBS ,ESPECE ,TRANSMETTRE, IMAGE );
50
 
50
 
51
// Fichier configuration
51
// Fichier configuration
52
	var $config;
52
	var $config;
53
 
53
 
54
// Encapsulation classe lecture fichier excel
54
// Encapsulation classe lecture fichier excel
55
	var $extendExcelReader;
55
	var $extendExcelReader;
56
 
56
 
57
// Dernier numero d'ordre utilise
57
// Dernier numero d'ordre utilise
58
	var $dernier_ordre=1;
58
	var $dernier_ordre=1;
59
	
59
	
60
	var $cpt_images_liees=0;
60
	var $cpt_images_liees=0;
61
 
61
 
62
/**
62
/**
63
 Constructeur
63
 Constructeur
64
**/
64
**/
65
	function InventoryImportExcel($config) {
65
	function InventoryImportExcel($config) {
66
 
66
 
67
		$this->config=$config;
67
		$this->config=$config;
68
		// Pas d'heritage multiple en php :(
68
		// Pas d'heritage multiple en php :(
69
 
69
 
70
		$this->extendExcelReader = new ExcelReader();
70
		$this->extendExcelReader = new ExcelReader();
71
		$this->extendExcelReader->initExcelReader();
71
		$this->extendExcelReader->initExcelReader();
72
	}
72
	}
73
 
73
 
74
/**
74
/**
75
 Sur post
75
 Sur post
76
**/
76
**/
77
	function createElement($pairs) {
77
	function createElement($pairs) {
78
 
78
 
79
 
79
 
80
		$pairs['utilisateur']=$_POST['identifiant'];
80
		$pairs['utilisateur']=$_POST['identifiant'];
81
        $this->controleUtilisateur($pairs['utilisateur']);
81
        $this->controleUtilisateur($pairs['utilisateur']);
82
 
82
 
83
 
83
 
84
        foreach($_FILES as $file) { // C'est le plus simple
84
        foreach($_FILES as $file) { // C'est le plus simple
85
            $infos_fichier = $file ;
85
            $infos_fichier = $file ;
86
        }
86
        }
87
 
87
 
88
 
88
 
89
// Chargement tableau en memoire
89
// Chargement tableau en memoire
90
		$data = new Spreadsheet_Excel_Reader($infos_fichier['tmp_name'], false); // false : pour menager la memoire.
90
		$data = new Spreadsheet_Excel_Reader($infos_fichier['tmp_name'], false); // false : pour menager la memoire.
91
		$arr = array();
91
		$arr = array();
92
 
92
 
93
		$rowcount=$data->rowcount(0);
93
		$rowcount=$data->rowcount(0);
94
		$colcount=$data->colcount(0);
94
		$colcount=$data->colcount(0);
95
 
95
 
96
		if ($rowcount<=1) { // TODO : retour erreur
96
		if ($rowcount<=1) { // TODO : retour erreur
97
			print "Tableau vide";
97
			print "Tableau vide";
98
			exit;
98
			exit;
99
		}
99
		}
100
 
100
 
101
// Chargement tableau 
101
// Chargement tableau 
102
        for($row=1;$row<=$rowcount;$row++) 
102
        for($row=1;$row<=$rowcount;$row++) 
103
            for($col=1;$col<=$colcount;$col++) 
103
            for($col=1;$col<=$colcount;$col++) 
104
                $arr[$col][$row] = $data->val($row,$col,0); // Attention, inversion voulue
104
                $arr[$col][$row] = $data->val($row,$col,0); // Attention, inversion voulue
105
              
105
              
106
// 1 : Traitement intitules
106
// 1 : Traitement intitules
107
 
107
 
108
		$line = array();
108
		$line = array();
109
 
109
 
110
/* Les colonnes ne sont pas forcemment dans l'ordre  : on les extrait pour traitement futur  */
110
/* Les colonnes ne sont pas forcemment dans l'ordre  : on les extrait pour traitement futur  */
111
 
111
 
112
        for($col=1;$col<=$colcount;$col++) {
112
        for($col=1;$col<=$colcount;$col++) {
113
            $colonne=strtolower($arr[$col][1]);
113
            $colonne=strtolower($arr[$col][1]);
114
            $colonne=trim($colonne);
114
            $colonne=trim($colonne);
115
            $colonne=cp1252_to_utf8($colonne);
115
            $colonne=cp1252_to_utf8($colonne);
116
            $colonne=remove_accent($colonne);
116
            $colonne=remove_accent($colonne);
117
            switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
117
            switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
118
                case COMMUNE:
118
                case COMMUNE:
119
                case LIEUDIT:
119
                case LIEUDIT:
120
                case STATION:
120
                case STATION:
121
                case MILIEU:
121
                case MILIEU:
122
                case DEPARTEMENT:
122
                case DEPARTEMENT:
123
                case LATITUDE:
123
                case LATITUDE:
124
                case LONGITUDE:
124
                case LONGITUDE:
125
                case NOTES:
125
                case NOTES:
126
                case DATEOBS:
126
                case DATEOBS:
127
                case ESPECE:
127
                case ESPECE:
128
                case TRANSMETTRE:
128
                case TRANSMETTRE:
129
                case IMAGE:
129
                case IMAGE:
130
                    $selection=array_values($arr[$col]);
130
                    $selection=array_values($arr[$col]);
131
                    array_shift($selection); // On ne garde pas la premiere ligne, qui contient les intitules
131
                    array_shift($selection); // On ne garde pas la premiere ligne, qui contient les intitules
132
                    $line[$colonne]=$selection;
132
                    $line[$colonne]=$selection;
133
                    break;
133
                    break;
134
 
134
 
135
            }
135
            }
136
        } 
136
        } 
137
 
-
 
138
//	print_r($line[COMMUNE]);
-
 
139
//		print_r($line[LIEUDIT]);
-
 
140
//		print_r($line[STATION]);
-
 
141
//		print_r($line[MILIEU]);
-
 
142
//		print_r($line[DEPARTEMENT]);
-
 
143
//		print_r($line[LATITUDE]);
-
 
144
//		print_r($line[LONGITUDE]);
-
 
145
//		print_r($line[NOTES]);
-
 
146
//		print_r($line[DATEOBS]);
-
 
147
//		print_r($line[ESPECE]);
-
 
148
//		print_r($line[IMAGE]);
-
 
149
	
-
 
150
 
-
 
151
// 1 : Traitement lignes
137
		// 1 : Traitement lignes
152
 
-
 
153
		$cpt_obs=0;
138
		$cpt_obs=0;
154
		$cpt_img=0;
139
		$cpt_img=0;
155
 
-
 
156
 
140
 
157
        /* Recherche dernier numero d'ordre utilise : pas de mise a jour concurente a priori */
-
 
158
 
-
 
159
 
141
        /* Recherche dernier numero d'ordre utilise : pas de mise a jour concurente a priori */
160
        $DB=$this->connectDB($this->config,'database_cel'); 
142
        $DB=$this->connectDB($this->config,'database_cel'); 
161
        $query="SELECT MAX(ordre) AS ordre FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($pairs['utilisateur'])."' ";
143
        $query="SELECT MAX(ordre) AS ordre FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($pairs['utilisateur'])."' ";
162
 
144
 
163
        $res =& $DB->query($query);
145
        $res =& $DB->query($query);
164
        if (DB::isError($res)) {
146
        if (DB::isError($res)) {
165
            die($res->getMessage());
147
            die($res->getMessage());
166
        }
148
        }
167
 
149
 
168
        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
150
        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
169
            $this->dernier_ordre=$row['ordre']; // 1  par defaut
151
            $this->dernier_ordre=$row['ordre']; // 1  par defaut
170
        }
152
        }
171
 
153
 
172
		for ($i=0;$i<=$rowcount-1;$i++) {
154
		for ($i=0;$i<=$rowcount-1;$i++) {
173
			// On saute les eventuelles lignes vides du debut et les lignes contenant des information sur image uniquement
155
			// On saute les eventuelles lignes vides du debut et les lignes contenant des information sur image uniquement
174
			while ((in_array($retour_analyse=$this->analyserLigne($line,$i),array(LIGNE_IMAGE_SEULEMENT, LIGNE_VIDE))) && ($i<=$rowcount)) {
156
			while ((in_array($retour_analyse=$this->analyserLigne($line,$i),array(LIGNE_IMAGE_SEULEMENT, LIGNE_VIDE))) && ($i<=$rowcount)) {
175
				if  ($retour_analyse==LIGNE_IMAGE_SEULEMENT) {
157
				if  ($retour_analyse==LIGNE_IMAGE_SEULEMENT) {
176
	//				print "image non rattachee a une observation";
158
	//				print "image non rattachee a une observation";
177
				}
159
				}
178
				else {
160
				else {
179
	//				print "vide";
161
	//				print "vide";
180
				}
162
				}
181
				$i++;
163
				$i++;
182
			}
164
			}
183
			while (($this->analyserLigne($line,$i)==LIGNE_NORMALE) && ($i<=$rowcount)) {
165
			while (($this->analyserLigne($line,$i)==LIGNE_NORMALE) && ($i<=$rowcount)) {
184
				$ordre=$this->traiterLigne($line,$i,$pairs['utilisateur'],$DB);
166
				$ordre=$this->traiterLigne($line,$i,$pairs['utilisateur'],$DB);
185
				if ($ordre>0) {
167
				if ($ordre>0) {
186
					$cpt_obs++; // Compteur d'observations crees
168
					$cpt_obs++; // Compteur d'observations crees
187
				}
169
				}
188
				$i++;
170
				$i++;
189
				// On saute les lignes vide ou on traite les lignes suivantes contenant des informations sur image seulement
171
				// On saute les lignes vide ou on traite les lignes suivantes contenant des informations sur image seulement
190
				while ((in_array($retour_analyse=$this->analyserLigne($line,$i),array(LIGNE_IMAGE_SEULEMENT, LIGNE_VIDE))) && ($i<=$rowcount)) {
172
				while ((in_array($retour_analyse=$this->analyserLigne($line,$i),array(LIGNE_IMAGE_SEULEMENT, LIGNE_VIDE))) && ($i<=$rowcount)) {
191
					if  ($retour_analyse==LIGNE_IMAGE_SEULEMENT) {
173
					if  ($retour_analyse==LIGNE_IMAGE_SEULEMENT) {
192
						$this->traiterLigneComplement($line,$i,$pairs['utilisateur'],$ordre); // images supplementaires
174
						$this->traiterLigneComplement($line,$i,$pairs['utilisateur'],$ordre); // images supplementaires
193
					}
175
					}
194
					else {
176
					else {
195
	//					print "vide";
177
	//					print "vide";
196
					}
178
					}
197
					$i++;
179
					$i++;
198
				}	
180
				}	
199
			}
181
			}
200
			
182
			
201
	
183
	
202
		}
184
		}
203
		//print $cpt_obs ." nouvelle(s) observation(s) !";
-
 
204
		$message = '';
185
		$message = '';
205
		
186
		
206
		if($this->cpt_images_liees > 0) {
187
		if($this->cpt_images_liees > 0) {
207
			$message = $this->cpt_images_liees.' images liees pour ';
188
			$message = $this->cpt_images_liees.' images liees pour ';
208
		}
189
		}
209
		
190
		
210
		$message .= $cpt_obs;
191
		$message .= $cpt_obs;
211
		print $message;
192
		print $message;
212
 
193
 
213
	}
194
	}
214
 
195
 
215
function analyserLigne($line,$i) {
196
function analyserLigne($line,$i) {
216
	
197
	
217
	$ligne_vide=true;
198
	$ligne_vide=true;
218
	$ligne_image_seulement=true;
199
	$ligne_image_seulement=true;
219
	$ligne_normale=true;
200
	$ligne_normale=true;
220
	
201
	
221
	$ligne_identique_sauf_image = true;
202
	$ligne_identique_sauf_image = true;
222
	
203
	
223
	foreach ($this->format_observation as $colonne) {
204
	foreach ($this->format_observation as $colonne) {
224
		
205
		
225
		if($i < 1) {
206
		if($i < 1) {
226
			$ligne_identique_sauf_image = false;
207
			$ligne_identique_sauf_image = false;
227
		} else {
208
		} else {
-
 
209
			
228
			
210
			if($colonne!= IMAGE && isset($line[$colonne]) && isset($line[$colonne][$i - 1]) && isset($line[$colonne][$i]) 
229
			if($colonne!= IMAGE && $line[$colonne][$i - 1] != $line[$colonne][$i] && $line[$colonne][$i] != '') {
211
				&& $line[$colonne][$i - 1] != $line[$colonne][$i] && $line[$colonne][$i] != '') {
230
				$ligne_identique_sauf_image = false;
212
				$ligne_identique_sauf_image = false;
231
			}
213
			}
232
		} 
214
		} 
233
		
215
		
234
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
216
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
235
			if ($colonne!=IMAGE) {
217
			if ($colonne!=IMAGE) {
236
				$ligne_image_seulement=false;
218
				$ligne_image_seulement=false;
237
				$ligne_vide=false;
219
				$ligne_vide=false;
238
			}		
220
			}		
239
			$ligne_vide=false;
221
			$ligne_vide=false;
240
		}		
222
		}		
241
	}
223
	}
242
	
224
	
243
	if ($ligne_vide) {
225
	if ($ligne_vide) {
244
		return LIGNE_VIDE;
226
		return LIGNE_VIDE;
245
	}
227
	}
246
	else {
228
	else {
247
		if ($ligne_image_seulement || $ligne_identique_sauf_image) {
229
		if ($ligne_image_seulement || $ligne_identique_sauf_image) {
248
			return LIGNE_IMAGE_SEULEMENT;
230
			return LIGNE_IMAGE_SEULEMENT;
249
		}
231
		}
250
		else {
232
		else {
251
			return LIGNE_NORMALE;
233
			return LIGNE_NORMALE;
252
		}
234
		}
253
	}
235
	}
254
	
236
	
255
 
237
 
256
}
238
}
257
 
239
 
258
function traiterLigne($line,$i,$utilisateur,$DB) { // Controle donnee et insertion
240
function traiterLigne($line,$i,$utilisateur,$DB) { // Controle donnee et insertion
259
	
241
	
260
	$info_image=array();
242
	$info_image=array();
261
	$info_transmettre = "0";
243
	$info_transmettre = "0";
262
	
244
	
263
	foreach ($this->format_observation as $colonne) {
245
	foreach ($this->format_observation as $colonne) {
264
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
246
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
265
			switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
247
			switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
266
				case COMMUNE:
248
				case COMMUNE:
267
					$info_commune=$this->traiterCommune($line[COMMUNE][$i]);
249
					$info_commune=$this->traiterCommune($line[COMMUNE][$i]);
268
					break;
250
					break;
269
				case LIEUDIT:
251
				case LIEUDIT:
270
					$info_lieudit=$this->traiterLieudit($line[LIEUDIT][$i]);
252
					$info_lieudit=$this->traiterLieudit($line[LIEUDIT][$i]);
271
					break;
253
					break;
272
				case STATION:
254
				case STATION:
273
					$info_station=$this->traiterStation($line[STATION][$i]);
255
					$info_station=$this->traiterStation($line[STATION][$i]);
274
					break;
256
					break;
275
				case MILIEU:
257
				case MILIEU:
276
					$info_milieu=$this->traiterMilieu($line[MILIEU][$i]);
258
					$info_milieu=$this->traiterMilieu($line[MILIEU][$i]);
277
					break;
259
					break;
278
                case DEPARTEMENT:
260
                case DEPARTEMENT:
279
					$info_commune['code']=$this->traiterDepartement($line[DEPARTEMENT][$i]);
261
					$info_commune['code']=$this->traiterDepartement($line[DEPARTEMENT][$i]);
280
					break;
262
					break;
281
				case LATITUDE:
263
				case LATITUDE:
282
					$info_latitude=$this->traiterLatitude($line[LATITUDE][$i]);
264
					$info_latitude=$this->traiterLatitude($line[LATITUDE][$i]);
283
					break;
265
					break;
284
				case LONGITUDE:
266
				case LONGITUDE:
285
					$info_longitude=$this->traiterLongitude($line[LONGITUDE][$i]);
267
					$info_longitude=$this->traiterLongitude($line[LONGITUDE][$i]);
286
					break;
268
					break;
287
				case NOTES:
269
				case NOTES:
288
					$info_notes=$this->traiterNotes($line[NOTES][$i]);
270
					$info_notes=$this->traiterNotes($line[NOTES][$i]);
289
					break;
271
					break;
290
				case DATEOBS:
272
				case DATEOBS:
291
					$info_dateobs=$this->traiterDateObs($line[DATEOBS][$i]);
273
					$info_dateobs=$this->traiterDateObs($line[DATEOBS][$i]);
292
					break;
274
					break;
293
				case TRANSMETTRE:
275
				case TRANSMETTRE:
294
					$info_transmettre=$this->traiterTransmettre($line[TRANSMETTRE][$i]);
276
					$info_transmettre=$this->traiterTransmettre($line[TRANSMETTRE][$i]);
295
				break;
277
				break;
296
				case ESPECE:
278
				case ESPECE:
297
					$info_espece=$this->traiterEspece($line[ESPECE][$i]);
279
					$info_espece=$this->traiterEspece($line[ESPECE][$i]);
298
                    if (isset($info_espece['en_id_nom']) && $info_espece['en_id_nom']!='') {
280
                    if (isset($info_espece['en_id_nom']) && $info_espece['en_id_nom']!='') {
299
                        $complement=$this->rechercherInformationsComplementaires($info_espece['en_id_nom']);
281
                        $complement=$this->rechercherInformationsComplementaires($info_espece['en_id_nom']);
300
                        $info_espece['nom_ret']=$complement['Nom_Retenu'];
282
                        $info_espece['nom_ret']=$complement['Nom_Retenu'];
301
                        $info_espece['num_nom_ret']=$complement['Num_Nom_Retenu'];
283
                        $info_espece['num_nom_ret']=$complement['Num_Nom_Retenu'];
302
                        $info_espece['num_taxon']=$complement['Num_Taxon'];
284
                        $info_espece['num_taxon']=$complement['Num_Taxon'];
303
                        $info_espece['famille']=$complement['Famille'];
285
                        $info_espece['famille']=$complement['Famille'];
304
                    }
286
                    }
305
                    break;
287
                    break;
306
				case IMAGE:
288
				case IMAGE:
307
					$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / +  utilisateur
289
					$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / +  utilisateur
308
					break;
290
					break;
309
			}
291
			}
310
		}
292
		}
311
		else {	
293
		else {	
312
		 	switch($colonne) {
294
		 	switch($colonne) {
313
				case COMMUNE:
295
				case COMMUNE:
314
					$info_commune['name']="000null";
296
					$info_commune['name']="000null";
315
					$info_commune['code']="000null";
-
 
316
					break;
297
					break;
317
				case LIEUDIT:
298
				case LIEUDIT:
318
					$info_lieudit="000null";
299
					$info_lieudit="000null";
319
					break;
300
					break;
320
				case STATION:
301
				case STATION:
321
					$info_station="000null";
302
					$info_station="000null";
322
					break;
303
					break;
323
				case MILIEU:
304
				case MILIEU:
324
					$info_milieu="000null";
305
					$info_milieu="000null";
325
					break;
306
					break;
326
				case DEPARTEMENT:
307
				case DEPARTEMENT:
327
		            /*if (!isset ($info_commune['code']) || $info_commune['code']=='') {
308
		            if (!isset ($info_commune['code']) || $info_commune['code']=='') {
328
					    $info_commune['code']="000null";
309
					    $info_commune['code']="000null";
329
                    }*/
310
                    }
330
					break;
311
					break;
331
				case LATITUDE:
312
				case LATITUDE:
332
					$info_latitude="000null";
313
					$info_latitude="000null";
333
					break;
314
					break;
334
				case LONGITUDE:
315
				case LONGITUDE:
335
					$info_longitude="000null";
316
					$info_longitude="000null";
336
					break;
317
					break;
-
 
318
				case NOTES:
-
 
319
					$info_notes='';
337
					
320
					break;
338
				case TRANSMETTRE:
321
				case TRANSMETTRE:
339
					$info_transmettre = "0";
322
					$info_transmettre = "0";
340
				break;
323
				break;
341
 
324
 
342
			}
325
			}
343
 
326
 
344
		}
327
		}
345
	}
328
	}
346
 
329
 
347
                $this->dernier_ordre++;
330
                $this->dernier_ordre++;
348
 
331
 
349
                list($jour,$mois,$annee)=explode("/",$info_dateobs);
332
                list($jour,$mois,$annee)=explode("/",$info_dateobs);
350
                $info_dateobs=$annee."-".$mois."-".$jour." 0:0:0";
333
                $info_dateobs=$annee."-".$mois."-".$jour." 0:0:0";
351
                $query  = "INSERT INTO cel_inventory (identifiant,ordre,nom_sel,num_nom_sel,nom_ret,num_nom_ret,num_taxon,famille,location,id_location,date_observation,lieudit,station, milieu, commentaire, transmission, date_creation,date_modification,coord_x,coord_y) " .
334
                $query  = "INSERT INTO cel_inventory (identifiant,ordre,nom_sel,num_nom_sel,nom_ret,num_nom_ret,num_taxon,famille,location,id_location,date_observation,lieudit,station, milieu, commentaire, transmission, date_creation,date_modification,coord_x,coord_y) " .
352
                    " VALUES('".$DB->escapeSimple($utilisateur)."','".
335
                    " VALUES('".$DB->escapeSimple($utilisateur)."','".
353
                    $DB->escapeSimple($this->dernier_ordre)."','".
336
                    $DB->escapeSimple($this->dernier_ordre)."','".
354
                    $DB->escapeSimple($info_espece['nom_sel'])."','".
337
                    $DB->escapeSimple($info_espece['nom_sel'])."','".
355
                    $DB->escapeSimple($info_espece['en_id_nom'])."','".
338
                    $DB->escapeSimple($info_espece['en_id_nom'])."','".
356
                    $DB->escapeSimple($info_espece['nom_ret'])."','".
339
                    $DB->escapeSimple($info_espece['nom_ret'])."','".
357
                    $DB->escapeSimple($info_espece['num_nom_ret'])."','".
340
                    $DB->escapeSimple($info_espece['num_nom_ret'])."','".
358
                    $DB->escapeSimple($info_espece['num_taxon'])."','".
341
                    $DB->escapeSimple($info_espece['num_taxon'])."','".
359
                    $DB->escapeSimple($info_espece['famille'])."','".
342
                    $DB->escapeSimple($info_espece['famille'])."','".
360
                    $DB->escapeSimple($info_commune['name'])."','".
343
                    $DB->escapeSimple($info_commune['name'])."','".
361
                    $DB->escapeSimple($info_commune['code'])."','".
344
                    $DB->escapeSimple($info_commune['code'])."','".
362
                    $DB->escapeSimple($info_dateobs)."','".
345
                    $DB->escapeSimple($info_dateobs)."','".
363
                    $DB->escapeSimple($info_lieudit)."','".
346
                    $DB->escapeSimple($info_lieudit)."','".
364
                    $DB->escapeSimple($info_station)."','".
347
                    $DB->escapeSimple($info_station)."','".
365
                    $DB->escapeSimple($info_milieu)."','".
348
                    $DB->escapeSimple($info_milieu)."','".
366
                    $DB->escapeSimple($info_notes)."','".
349
                    $DB->escapeSimple($info_notes)."','".
367
                    $DB->escapeSimple($info_transmettre)."',".
350
                    $DB->escapeSimple($info_transmettre)."',".
368
                    "now() , now(),'".
351
                    "now() , now(),'".
369
                    $DB->escapeSimple($info_latitude)."','".
352
                    $DB->escapeSimple($info_latitude)."','".
370
                    $DB->escapeSimple($info_longitude)."')";
353
                    $DB->escapeSimple($info_longitude)."')";
371
//		print "\n";
354
//		print "\n";
372
		   $res =& $DB->query($query);
355
		   $res =& $DB->query($query);
373
 
356
 
374
                if (PEAR::isError($res)) {
357
                if (PEAR::isError($res)) {
375
                        return false;
358
                        return false;
376
                }
359
                }
377
	
360
	
378
	// creation lien image
361
	// creation lien image
379
	foreach ($info_image as $pic) {
362
	foreach ($info_image as $pic) {
380
 
363
 
381
		$query = 'INSERT INTO cel_obs_images (coi_ce_image, coi_ce_utilisateur, coi_ce_observation ) VALUES ("'.$DB->escapeSimple($pic['ci_id_image']).'","'.$DB->escapeSimple($utilisateur).'",    "'.$DB->escapeSimple($this->dernier_ordre).'") ON DUPLICATE KEY UPDATE coi_ce_image = coi_ce_image' ;	
364
		$query = 'INSERT INTO cel_obs_images (coi_ce_image, coi_ce_utilisateur, coi_ce_observation ) VALUES ("'.$DB->escapeSimple($pic['ci_id_image']).'","'.$DB->escapeSimple($utilisateur).'",    "'.$DB->escapeSimple($this->dernier_ordre).'") ON DUPLICATE KEY UPDATE coi_ce_image = coi_ce_image' ;	
382
 
365
 
383
		$res =& $DB->query($query);
366
		$res =& $DB->query($query);
384
 
367
 
385
                if (PEAR::isError($res)) {
368
                if (PEAR::isError($res)) {
386
                        return false;
369
                        return false;
387
                } else {
370
                } else {
388
                	$this->cpt_images_liees++;
371
                	$this->cpt_images_liees++;
389
                }
372
                }
390
	}
373
	}
391
 
-
 
392
 
-
 
393
 
374
 
394
		return $this->dernier_ordre;
375
		return $this->dernier_ordre;
395
 
376
 
396
 
377
 
397
}
378
}
398
 
379
 
399
function traiterLigneComplement($line,$i,$utilisateur, $ordre = null) {
380
function traiterLigneComplement($line,$i,$utilisateur, $ordre = null) {
400
 
381
 
401
	$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / +  utilisateur
382
	$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / +  utilisateur
402
	
383
	
403
	// creation lien image
384
	// creation lien image
404
	foreach ($info_image as $pic) {
385
	foreach ($info_image as $pic) {
405
 
386
 
406
		$DB=$this->connectDB($this->config,'cel_db');
387
		$DB=$this->connectDB($this->config,'cel_db');
407
		$query = 'INSERT INTO cel_obs_images (coi_ce_image, coi_ce_utilisateur, coi_ce_observation) VALUES ("'.$DB->escapeSimple($pic['ci_id_image']).'","'.$DB->escapeSimple($utilisateur).'",    "'.$DB->escapeSimple($this->dernier_ordre).'") ON DUPLICATE KEY UPDATE coi_ce_image = coi_ce_image' ;	
388
		$query = 'INSERT INTO cel_obs_images (coi_ce_image, coi_ce_utilisateur, coi_ce_observation) VALUES ("'.$DB->escapeSimple($pic['ci_id_image']).'","'.$DB->escapeSimple($utilisateur).'",    "'.$DB->escapeSimple($this->dernier_ordre).'") ON DUPLICATE KEY UPDATE coi_ce_image = coi_ce_image' ;	
408
 
389
 
409
		$res =& $DB->query($query);
390
		$res =& $DB->query($query);
410
 
391
 
411
    	if (PEAR::isError($res)) {
392
    	if (PEAR::isError($res)) {
412
            return false;
393
            return false;
413
    	} else {
394
    	} else {
414
    		$this->cpt_images_liees++;
395
    		$this->cpt_images_liees++;
415
    	}
396
    	}
416
	}
397
	}
417
}
398
}
418
function traiterCommune($identifiant_commune) {  // Recherche correspondance sur nom, si pas unique, correspondance dep. sinon code insee
399
function traiterCommune($identifiant_commune) {  // Recherche correspondance sur nom, si pas unique, correspondance dep. sinon code insee
-
 
400
 
-
 
401
    $identifiant_commune=trim($identifiant_commune);
419
 
-
 
420
 
-
 
421
        $identifiant_commune=trim($identifiant_commune);
-
 
422
 
-
 
423
        $identifiant_commune=utf8_encode($identifiant_commune); // FIXME : devrait deja etre en utf8 a ce niveau
402
    $identifiant_commune=utf8_encode($identifiant_commune); // FIXME : devrait deja etre en utf8 a ce niveau
424
 
403
 
425
		preg_match('/(.*) \(([0-9][0-9]*)\)/',$identifiant_commune,$elements);
404
	preg_match('/(.*) \(([0-9][0-9]*)\)/',$identifiant_commune,$elements);
426
 
405
 
427
        $DB=$this->connectDB($this->config,'database_cel'); // FIXME regarder si opportun ici
406
    $DB=$this->connectDB($this->config,'database_cel'); // FIXME regarder si opportun ici
428
 
-
 
429
	if ($elements[1]) { // commune + departement : montpellier (34)
407
 
430
		$nom_commune=$elements[1];
-
 
431
		$code_commune=$elements[2];
408
	if (isset($elements[1])) { // commune + departement : montpellier (34)
432
 
409
		$nom_commune=$elements[1];
433
 	        $query="SELECT DISTINCT name, code  FROM locations WHERE name = '".$DB->escapeSimple($nom_commune)."' AND code ='".$DB->escapeSimple($code_commune)."'";
410
		$code_commune=$elements[2];
434
 
411
 	    $query="SELECT DISTINCT name, code  FROM locations WHERE name = '".$DB->escapeSimple($nom_commune)."' AND code ='".$DB->escapeSimple($code_commune)."'";
435
	}
412
	}
436
	else { // Code insee seul 
413
	else { // Code insee seul 
437
        preg_match('/([0-9][0-9]*)|(2A[0-9][0-9]*)|(2B[0-9][0-9]*)/',$identifiant_commune,$elements);
414
        preg_match('/([0-9][0-9]*)|(2A[0-9][0-9]*)|(2B[0-9][0-9]*)/',$identifiant_commune,$elements);
438
        if ($elements[1]) { // code insee  commune
415
        if (isset($elements[1])) { // code insee  commune
439
            $code_insee_commune=$elements[1];
416
            $code_insee_commune=$elements[1];
440
            $query="SELECT DISTINCT name, code  FROM locations WHERE insee_code ='".$DB->escapeSimple($code_insee_commune)."'";
417
            $query="SELECT DISTINCT name, code  FROM locations WHERE insee_code ='".$DB->escapeSimple($code_insee_commune)."'";
441
        }	
418
        }	
442
        else { // Commune seule (le departement sera recupere dans la colonne departement si elle est presente, on prend le risque ici de retourner une mauvaise
419
        else { // Commune seule (le departement sera recupere dans la colonne departement si elle est presente, on prend le risque ici de retourner une mauvaise
443
               // Commune
420
               // Commune
444
            preg_match('/(.*)/',$identifiant_commune,$elements);
421
            preg_match('/(.*)/',$identifiant_commune,$elements);
445
            if ($elements[1]) { // commune 
422
            if (isset($elements[1])) { // commune 
446
                $nom_commune=$elements[1];
423
                $nom_commune=$elements[1];
447
                $nom_commune=trim($nom_commune);
424
                $nom_commune=trim($nom_commune);
448
                $nom_commune=utf8_decode($nom_commune);
425
                $nom_commune=utf8_decode($nom_commune);
449
                $nom_commune=cp1252_to_utf8($nom_commune);
426
                $nom_commune=cp1252_to_utf8($nom_commune);
450
                $nom_commune=remove_accent($nom_commune);
427
                $nom_commune=remove_accent($nom_commune);
451
                $nom_commune=preg_replace("/ /","%",$nom_commune);
428
                $nom_commune=preg_replace("/ /","%",$nom_commune);
452
                $query="SELECT DISTINCT name, code  FROM locations WHERE name like '".$DB->escapeSimple($nom_commune)."'";
429
                $query="SELECT DISTINCT name, code  FROM locations WHERE name like '".$DB->escapeSimple($nom_commune)."'";
453
            }
430
            }
454
        }
431
        }
455
	}
432
	}
456
 
433
 
457
	$res =& $DB->query($query);
434
	$res =& $DB->query($query);
458
 
-
 
459
        if (DB::isError($res)) {
435
    if (DB::isError($res)) {
460
		 die($res->getMessage());
436
		 die($res->getMessage());
461
	}
437
	}
462
 
-
 
463
	return $res->fetchrow(DB_FETCHMODE_ASSOC);
-
 
464
 
-
 
-
 
438
	
465
	
439
	$commune_code = $res->fetchrow(DB_FETCHMODE_ASSOC);
-
 
440
	
-
 
441
	// cas de la commune introuvable dans le référentiel
-
 
442
	if(!is_array($commune_code) || count($commune_code) == 0) {
-
 
443
		$commune_code['name'] = fix_latin($identifiant_commune);
466
 
444
		$commune_code['code'] = '000null';
-
 
445
	}
467
 
446
	return $commune_code;
468
}
447
}
469
 
448
 
470
function traiterLieudit($lieudit) { // texte libre
449
function traiterLieudit($lieudit) { // texte libre
471
 
450
 
472
	//echo "traitement lieudit";
451
	//echo "traitement lieudit";
473
    $lieudit=fix_latin($lieudit);
452
    $lieudit=fix_latin($lieudit);
474
	return trim($lieudit);
453
	return trim($lieudit);
475
}
454
}
476
 
455
 
477
function traiterStation($station) { // texte libre
456
function traiterStation($station) { // texte libre
478
//	echo "traitement station";
457
//	echo "traitement station";
479
    $station=fix_latin($station);
458
    $station=fix_latin($station);
480
	return trim($station);
459
	return trim($station);
481
}
460
}
482
 
461
 
483
function traiterMilieu($milieu) { // texte libre
462
function traiterMilieu($milieu) { // texte libre
484
//	echo "traitement milieu";
463
//	echo "traitement milieu";
485
    $milieu=fix_latin($milieu);
464
    $milieu=fix_latin($milieu);
486
	return trim($milieu);
465
	return trim($milieu);
487
}
466
}
488
 
467
 
489
function traiterDepartement($departement) { // texte libre
468
function traiterDepartement($departement) { // texte libre
490
 
469
 
491
	if(is_numeric($departement) && strlen($departement) == 5) {
470
	if(is_numeric($departement) && strlen($departement) == 5) {
492
		$departement = substr($departement,0,2);
471
		$departement = substr($departement,0,2);
493
	}
472
	}
494
	
473
	
495
	if(is_numeric($departement) && strlen($departement) == 4) {
474
	if(is_numeric($departement) && strlen($departement) == 4) {
496
		$departement = substr($departement,0,1);
475
		$departement = substr($departement,0,1);
497
		$departement = "0"+$departement;
476
		$departement = "0"+$departement;
498
	}
477
	}
-
 
478
 
-
 
479
	if(is_numeric($departement) && $departement <= 9) {
-
 
480
		$departement = "0"+$departement;
-
 
481
	}
499
	return utf8_encode(trim($departement));
482
	return utf8_encode(trim($departement));
500
}
483
}
501
 
484
 
502
function traiterLatitude($latitude) {	//  verifier formal decimal + limite france ? TODO 
485
function traiterLatitude($latitude) {	//  verifier formal decimal + limite france ? TODO 
503
//	echo "traitement latitude";
486
//	echo "traitement latitude";
504
	return trim($latitude);
487
	return trim($latitude);
505
}
488
}
506
 
489
 
507
function traiterLongitude($longitude) { // verifier format decimal + limite france ? TODO 
490
function traiterLongitude($longitude) { // verifier format decimal + limite france ? TODO 
508
//	echo "traitement longitude";
491
//	echo "traitement longitude";
509
	return trim($longitude);
492
	return trim($longitude);
510
}
493
}
511
 
494
 
512
function traiterNotes($notes) { // texte libre
495
function traiterNotes($notes) { // texte libre
513
//	echo "traitement notes";
496
//	echo "traitement notes";
514
    $notes=remove_accent($notes);
497
    $notes=remove_accent($notes);
515
	return utf8_encode(trim($notes));
498
	return utf8_encode(trim($notes));
516
}
499
}
517
 
500
 
518
function traiterDateObs($dateobs) { // verifier jj/mm/aaaa sinon date vide TODO 
501
function traiterDateObs($dateobs) { // verifier jj/mm/aaaa sinon date vide TODO 
519
//	echo "traitement dateobs";
502
//	echo "traitement dateobs";
520
	return trim($dateobs);
503
	return trim($dateobs);
521
}
504
}
522
 
505
 
523
function traiterTransmettre($transmettre) {
506
function traiterTransmettre($transmettre) {
524
	
507
	
525
	$transmission = '0';
508
	$transmission = '0';
526
	
509
	
527
	if (trim($transmettre) == "1" || trim($transmettre) == "oui") {	
510
	if (trim($transmettre) == "1" || trim($transmettre) == "oui") {	
528
		$transmission = '1';
511
		$transmission = '1';
529
	}
512
	}
530
	
513
	
531
	return $transmission;
514
	return $transmission;
532
}
515
}
533
 
516
 
534
function traiterEspece($identifiant_espece) {  // texte libre, nom scientifique , ou code nomenclatural (format BDNFFnn999999) ou code taxonomique (format BDNFFnt999999)
517
function traiterEspece($identifiant_espece) {  // texte libre, nom scientifique , ou code nomenclatural (format BDNFFnn999999) ou code taxonomique (format BDNFFnt999999)
535
 
518
 
536
//	echo "traitement  espece";
519
//	echo "traitement  espece";
537
        $identifiant_espece=trim($identifiant_espece);
520
        $identifiant_espece=trim($identifiant_espece);
538
 
521
 
539
        $identifiant_espece=utf8_encode($identifiant_espece); // FIXME : devrait deja etre en utf8 a ce niveau
522
        $identifiant_espece=utf8_encode($identifiant_espece); // FIXME : devrait deja etre en utf8 a ce niveau
540
 
523
 
541
	    preg_match('/BDNFFnn([0-9][0-9]*)/',$identifiant_espece,$elements);
524
	    preg_match('/BDNFFnn([0-9][0-9]*)/',$identifiant_espece,$elements);
542
	
525
	
543
		if ($elements[1]) { // Numero nomenclatural 
526
		if (isset($elements[1])) { // Numero nomenclatural 
544
 
527
 
545
 
528
 
546
            // Recherche du nom associe
529
            // Recherche du nom associe
547
            $DB=$this->connectDB($this->config); // FIXME : gerer cache de connection
530
            $DB=$this->connectDB($this->config); // FIXME : gerer cache de connection
548
            $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
531
            $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
549
                "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
532
                "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
550
                " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
533
                " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
551
                " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
534
                " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
552
                " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
535
                " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
553
                " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
536
                " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
554
                " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom a,  " .
537
                " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom a,  " .
555
                " eflore_naturaliste_intitule_abreviation AS auteur_bex ".
538
                " eflore_naturaliste_intitule_abreviation AS auteur_bex ".
556
                " , eflore_naturaliste_intitule_abreviation AS auteur_b ".
539
                " , eflore_naturaliste_intitule_abreviation AS auteur_b ".
557
                " , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
540
                " , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
558
                " , eflore_naturaliste_intitule_abreviation AS auteur_m ".
541
                " , eflore_naturaliste_intitule_abreviation AS auteur_m ".
559
                " WHERE a.esn_id_nom= '".$elements[1]. "'".
542
                " WHERE a.esn_id_nom= '".$elements[1]. "'".
560
                " AND a.esn_id_version_projet_taxon = 25 ".
543
                " AND a.esn_id_version_projet_taxon = 25 ".
561
                " AND en_ce_rang = enrg_id_rang" .
544
                " AND en_ce_rang = enrg_id_rang" .
562
                " AND en_id_nom = a.esn_id_nom" .
545
                " AND en_id_nom = a.esn_id_nom" .
563
                " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
546
                " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
564
                " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
547
                " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
565
                " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
548
                " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
566
                " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
549
                " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
567
                " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
550
                " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
568
 
551
 
569
            $res =& $DB->query($query);
552
            $res =& $DB->query($query);
570
 
553
 
571
 
554
 
572
            if (DB::isError($res)) {
555
            if (DB::isError($res)) {
573
                die($res->getMessage());
556
                die($res->getMessage());
574
            }
557
            }
575
 
558
 
576
            $row =& $res->fetchrow(DB_FETCHMODE_ASSOC);
559
            $row =& $res->fetchrow(DB_FETCHMODE_ASSOC);
577
            return array("nom_sel"=>$this->formaterNom($row),"en_id_nom"=>$elements[1]);
560
            return array("nom_sel"=>$this->formaterNom($row),"en_id_nom"=>$elements[1]);
578
 
561
 
579
		}
562
		}
580
 
563
 
581
		else { //  Numero taxonomique ou nom scientifique
564
		else { //  Numero taxonomique ou nom scientifique
582
	        preg_match('/BDNFFnt([0-9][0-9]*)/',$identifiant_espece,$elements);
565
	        preg_match('/BDNFFnt([0-9][0-9]*)/',$identifiant_espece,$elements);
583
			
566
			
584
		    if ($elements[1]) { // Numero taxonomique
567
		    if (isset($elements[1])) { // Numero taxonomique
585
    
568
    
586
                $DB=$this->connectDB($this->config);
569
                $DB=$this->connectDB($this->config);
587
 
570
 
588
                $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
571
                $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
589
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
572
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
590
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
573
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
591
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
574
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
592
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
575
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
593
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
576
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
594
                    " FROM eflore_nom, eflore_nom_rang," .
577
                    " FROM eflore_nom, eflore_nom_rang," .
595
                    "     eflore_naturaliste_intitule_abreviation AS auteur_bex ".
578
                    "     eflore_naturaliste_intitule_abreviation AS auteur_bex ".
596
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
579
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
597
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
580
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
598
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
581
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
599
                    " , eflore_selection_nom ".
582
                    " , eflore_selection_nom ".
600
                    " WHERE esn_id_taxon = '".$elements[1]. "'".
583
                    " WHERE esn_id_taxon = '".$elements[1]. "'".
601
                    " AND esn_id_version_projet_taxon = 25 ".
584
                    " AND esn_id_version_projet_taxon = 25 ".
602
                    " AND esn_ce_statut=3 ".
585
                    " AND esn_ce_statut=3 ".
603
                    " AND en_id_nom = esn_id_nom" .
586
                    " AND en_id_nom = esn_id_nom" .
604
                    " AND en_ce_rang = enrg_id_rang" .
587
                    " AND en_ce_rang = enrg_id_rang" .
605
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
588
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
606
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
589
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
607
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
590
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
608
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
591
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
609
                    " AND esn_id_version_projet_taxon=en_id_version_projet_nom ";
592
                    " AND esn_id_version_projet_taxon=en_id_version_projet_nom ";
610
 
593
 
611
                $res =& $DB->query($query);
594
                $res =& $DB->query($query);
612
 
595
 
613
                if (DB::isError($res)) {
596
                if (DB::isError($res)) {
614
                    die($res->getMessage());
597
                    die($res->getMessage());
615
                }
598
                }
616
 
599
 
617
                $row =& $res->fetchrow(DB_FETCHMODE_ASSOC);
600
                $row =& $res->fetchrow(DB_FETCHMODE_ASSOC);
618
                return array("nom_sel"=>$this->formaterNom($row),"en_id_nom"=>$row['en_id_nom']);
601
                return array("nom_sel"=>$this->formaterNom($row),"en_id_nom"=>$row['en_id_nom']);
619
 
602
 
620
 
603
 
621
            }
604
            }
622
 
605
 
623
            else { // Nom scientifique
606
            else { // Nom scientifique
624
                $nameparser=new NameParser();
607
                $nameparser=new NameParser();
625
                $nom_latin_decoupe=$nameparser->parse($identifiant_espece);
608
                $nom_latin_decoupe=$nameparser->parse($identifiant_espece);
626
 
609
 
627
//print_r($nom_latin_decoupe);
610
//print_r($nom_latin_decoupe);
628
                    $DB=$this->connectDB($this->config); // FIXME regarder si opportun ici
611
                    $DB=$this->connectDB($this->config); // FIXME regarder si opportun ici
629
 
612
 
630
                        // requete sous espece (on privilegie les noms retenu cf tri par esn_ce_statut) 
613
                        // requete sous espece (on privilegie les noms retenu cf tri par esn_ce_statut) 
631
                        if (isset($nom_latin_decoupe['infra']) && $nom_latin_decoupe['infra']!="") {
614
                        if (isset($nom_latin_decoupe['infra']) && $nom_latin_decoupe['infra']!="") {
632
                            $query="SELECT DISTINCT en_id_nom, esn_ce_statut" .
615
                            $query="SELECT DISTINCT en_id_nom, esn_ce_statut" .
633
                                            " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
616
                                            " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
634
                                            " WHERE en_id_version_projet_nom = '25' AND en_nom_genre = '".$DB->escapeSimple($nom_latin_decoupe['genus'])."' " .
617
                                            " WHERE en_id_version_projet_nom = '25' AND en_nom_genre = '".$DB->escapeSimple($nom_latin_decoupe['genus'])."' " .
635
                                            " AND enrg_abreviation_rang = '".$DB->escapeSimple($nom_latin_decoupe['infra_type'])."' " .
618
                                            " AND enrg_abreviation_rang = '".$DB->escapeSimple($nom_latin_decoupe['infra_type'])."' " .
636
                                            " AND en_epithete_infra_specifique = '".$DB->escapeSimple($nom_latin_decoupe['infra'])."' " .
619
                                            " AND en_epithete_infra_specifique = '".$DB->escapeSimple($nom_latin_decoupe['infra'])."' " .
637
                                            " AND esn_id_nom= en_id_nom ".
620
                                            " AND esn_id_nom= en_id_nom ".
638
                                            " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
621
                                            " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
639
                                            " AND en_epithete_espece =  '".$DB->escapeSimple($nom_latin_decoupe['species'])."' AND en_ce_rang = enrg_id_rang " .
622
                                            " AND en_epithete_espece =  '".$DB->escapeSimple($nom_latin_decoupe['species'])."' AND en_ce_rang = enrg_id_rang " .
640
                                            " ORDER BY esn_ce_statut ".
623
                                            " ORDER BY esn_ce_statut ".
641
                                            " LIMIT 1";
624
                                            " LIMIT 1";
642
                        }
625
                        }
643
                        else { // espece  (on privilegie les noms retenu cf tri par esn_ce_statut)
626
                        else { // espece  (on privilegie les noms retenu cf tri par esn_ce_statut)
644
                             $query="SELECT DISTINCT en_id_nom, esn_ce_statut" .
627
                             $query="SELECT DISTINCT en_id_nom, esn_ce_statut" .
645
                                            " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
628
                                            " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom " .
646
                                            " WHERE en_id_version_projet_nom = '25' AND en_nom_genre = '".$DB->escapeSimple($nom_latin_decoupe['genus'])."' " .
629
                                            " WHERE en_id_version_projet_nom = '25' AND en_nom_genre = '".$DB->escapeSimple($nom_latin_decoupe['genus'])."' " .
647
                                            " AND enrg_abreviation_rang = 'sp.' " .
630
                                            " AND enrg_abreviation_rang = 'sp.' " .
648
                                            " AND esn_id_nom= en_id_nom ".
631
                                            " AND esn_id_nom= en_id_nom ".
649
                                            " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
632
                                            " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
650
                                            " AND en_epithete_espece =  '".$DB->escapeSimple($nom_latin_decoupe['species'])."' AND en_ce_rang = enrg_id_rang " .
633
                                            " AND en_epithete_espece =  '".$DB->escapeSimple($nom_latin_decoupe['species'])."' AND en_ce_rang = enrg_id_rang " .
651
                                            " ORDER BY esn_ce_statut ".
634
                                            " ORDER BY esn_ce_statut ".
652
                                            " LIMIT 1";
635
                                            " LIMIT 1";
653
                        
636
                        
654
                        }
637
                        }
655
                $res =& $DB->query($query);
638
                $res =& $DB->query($query);
656
                if (DB::isError($res)) {
639
                if (DB::isError($res)) {
657
                     die($res->getMessage());
640
                     die($res->getMessage());
658
                }
641
                }
659
 
642
 
660
                $id_nom=$res->fetchrow(DB_FETCHMODE_ASSOC);
643
                $id_nom=$res->fetchrow(DB_FETCHMODE_ASSOC);
661
 
644
 
662
                // Recherche du nom associe
645
                // Recherche du nom associe
663
                $DB=$this->connectDB($this->config); // FIXME : gerer cache de connection
646
                $DB=$this->connectDB($this->config); // FIXME : gerer cache de connection
664
                $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
647
                $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
665
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
648
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
666
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
649
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
667
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
650
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
668
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
651
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
669
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
652
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
670
                    " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom a,  " .
653
                    " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom a,  " .
671
                    "         eflore_naturaliste_intitule_abreviation AS auteur_bex ".
654
                    "         eflore_naturaliste_intitule_abreviation AS auteur_bex ".
672
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
655
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
673
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
656
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
674
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
657
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
675
                    " WHERE a.esn_id_nom= '".$id_nom['en_id_nom']. "'".
658
                    " WHERE a.esn_id_nom= '".$id_nom['en_id_nom']. "'".
676
                    " AND a.esn_id_version_projet_taxon = 25 ".
659
                    " AND a.esn_id_version_projet_taxon = 25 ".
677
                    " AND en_ce_rang = enrg_id_rang" .
660
                    " AND en_ce_rang = enrg_id_rang" .
678
                    " AND en_id_nom = a.esn_id_nom" .
661
                    " AND en_id_nom = a.esn_id_nom" .
679
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
662
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
680
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
663
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
681
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
664
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
682
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
665
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
683
                    " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
666
                    " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
684
                $res =& $DB->query($query);
667
                $res =& $DB->query($query);
685
 
668
 
686
 
669
 
687
                if (DB::isError($res)) {
670
                if (DB::isError($res)) {
688
                    die($res->getMessage());
671
                    die($res->getMessage());
689
                }
672
                }
690
 
673
 
691
                if ($res->numRows() > 0 ) {
674
                if ($res->numRows() > 0 ) {
692
                    $row =& $res->fetchrow(DB_FETCHMODE_ASSOC);
675
                    $row =& $res->fetchrow(DB_FETCHMODE_ASSOC);
693
                    return array("nom_sel"=>$this->formaterNom($row),"en_id_nom"=>$id_nom['en_id_nom']);
676
                    return array("nom_sel"=>$this->formaterNom($row),"en_id_nom"=>$id_nom['en_id_nom']);
694
                }
677
                }
695
                else {
678
                else {
696
                    return array("nom_sel"=>$identifiant_espece);
679
                    return array("nom_sel"=>$identifiant_espece);
697
                }
680
                }
698
 
681
 
699
 
682
 
700
                }
683
                }
701
            }
684
            }
702
	
685
	
703
 
686
 
704
}
687
}
705
 
688
 
706
 
689
 
707
 
690
 
708
function traiterImage($images,$utilisateur) { // recherche id image de ce nom 
691
function traiterImage($images,$utilisateur) { // recherche id image de ce nom 
709
 
692
 
710
        $DB=$this->connectDB($this->config,'cel_db');
693
        $DB=$this->connectDB($this->config,'cel_db');
711
 
694
 
712
	$liste_images = explode("/",$images) ;
695
	$liste_images = explode("/",$images) ;
713
 
696
 
714
	$row =array();
697
	$row =array();
715
        foreach($liste_images as $image) {
698
        foreach($liste_images as $image) {
716
 
699
 
717
		$query="SELECT * FROM cel_images WHERE ci_ce_utilisateur='".$DB->escapeSimple($utilisateur)."' AND ci_nom_original='".$DB->escapeSimple($image)."'";
700
		$query="SELECT * FROM cel_images WHERE ci_ce_utilisateur='".$DB->escapeSimple($utilisateur)."' AND ci_nom_original='".$DB->escapeSimple($image)."'";
718
 
701
 
719
	        $res  =& $DB->query($query);
702
	        $res  =& $DB->query($query);
720
		$row [] =& $res->fetchrow(DB_FETCHMODE_ASSOC);
703
		$row [] =& $res->fetchrow(DB_FETCHMODE_ASSOC);
721
 
704
 
722
	        if (DB::isError($res)) {
705
	        if (DB::isError($res)) {
723
        	    die($res->getMessage());
706
        	    die($res->getMessage());
724
	        }
707
	        }
725
 
708
 
726
	}
709
	}
727
	return $row;
710
	return $row;
728
 
711
 
729
 
712
 
730
}
713
}
731
 
714
 
732
       function rechercherInformationsComplementaires($numNom) { // Num taxon, Num retenu ...
715
       function rechercherInformationsComplementaires($numNom) { // Num taxon, Num retenu ...
733
 
716
 
734
                $DB=$this->connectDB($this->config);
717
                $DB=$this->connectDB($this->config);
735
 
718
 
736
                $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
719
                $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
737
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
720
                    "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
738
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
721
                    " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
739
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
722
                    " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
740
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
723
                    " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
741
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, b.esn_id_taxon, b.esn_id_nom" .
724
                    " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, b.esn_id_taxon, b.esn_id_nom" .
742
                    " FROM eflore_nom, eflore_nom_rang," .
725
                    " FROM eflore_nom, eflore_nom_rang," .
743
                    "     eflore_naturaliste_intitule_abreviation AS auteur_bex ".
726
                    "     eflore_naturaliste_intitule_abreviation AS auteur_bex ".
744
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
727
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
745
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
728
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
746
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
729
                    "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
747
                    " ,eflore_selection_nom a, eflore_selection_nom b".
730
                    " ,eflore_selection_nom a, eflore_selection_nom b".
748
                    " WHERE a.esn_id_nom= ".$numNom.
731
                    " WHERE a.esn_id_nom= ".$numNom.
749
                    " AND a.esn_id_version_projet_taxon = 25 ".
732
                    " AND a.esn_id_version_projet_taxon = 25 ".
750
                    " AND a.esn_id_taxon=b.esn_id_taxon ".
733
                    " AND a.esn_id_taxon=b.esn_id_taxon ".
751
                    " AND b.esn_ce_statut=3 ".
734
                    " AND b.esn_ce_statut=3 ".
752
                    " AND a.esn_id_version_projet_taxon=b.esn_id_version_projet_taxon" .
735
                    " AND a.esn_id_version_projet_taxon=b.esn_id_version_projet_taxon" .
753
                    " AND en_ce_rang = enrg_id_rang" .
736
                    " AND en_ce_rang = enrg_id_rang" .
754
                    " AND en_id_nom = b.esn_id_nom" .
737
                    " AND en_id_nom = b.esn_id_nom" .
755
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
738
                    " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
756
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
739
                    " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
757
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
740
                    " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
758
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
741
                    " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
759
                    " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
742
                    " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
760
 
743
 
761
 
744
 
762
                $res =& $DB->query($query);
745
                $res =& $DB->query($query);
763
 
746
 
764
 
747
 
765
 
748
 
766
                if (DB::isError($res)) {
749
                if (DB::isError($res)) {
767
                    die($res->getMessage());
750
                    die($res->getMessage());
768
                }
751
                }
769
 
752
 
770
                // Nom retenu, Num Nomenclatural nom retenu, Num Taxon,
753
                // Nom retenu, Num Nomenclatural nom retenu, Num Taxon,
771
 
754
 
772
                $value=array('Nom_Retenu'=>"",'Num_Nom_Retenu'=>"0",'Num_Taxon'=>"0",'Famille'=>"");
755
                $value=array('Nom_Retenu'=>"",'Num_Nom_Retenu'=>"0",'Num_Taxon'=>"0",'Famille'=>"");
773
 
756
 
774
                while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
757
                while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
775
                    $fam=$this->rechercherFamille($row['esn_id_taxon'],$DB);
758
                    $fam=$this->rechercherFamille($row['esn_id_taxon'],$DB);
776
 
759
 
777
                    // Recherche Famille 
760
                    // Recherche Famille 
778
                    while (($fam['en_ce_rang']!='fin') && ($fam['en_ce_rang'] !=120)) {
761
                    while (($fam['en_ce_rang']!='fin') && ($fam['en_ce_rang'] !=120)) {
779
                        $fam=$this->rechercherFamille($fam['etr_id_taxon_2'],$DB);
762
                        $fam=$this->rechercherFamille($fam['etr_id_taxon_2'],$DB);
780
                    }
763
                    }
781
                    if ($fam['en_ce_rang']==120) {
764
                    if ($fam['en_ce_rang']==120) {
782
                        $famille=$fam['en_nom_supra_generique'];
765
                        $famille=$fam['en_nom_supra_generique'];
783
                    }
766
                    }
784
                    else {
767
                    else {
785
                        $famille="Famille inconnue";
768
                        $famille="Famille inconnue";
786
                    }
769
                    }
787
 
770
 
788
                    $value=array('Nom_Retenu'=>$this->formaterNom($row),'Num_Nom_Retenu'=>$row['esn_id_nom'],'Num_Taxon'=>$row['esn_id_taxon'],'Famille'=>$famille);
771
                    $value=array('Nom_Retenu'=>$this->formaterNom($row),'Num_Nom_Retenu'=>$row['esn_id_nom'],'Num_Taxon'=>$row['esn_id_taxon'],'Famille'=>$famille);
789
                }
772
                }
790
 
773
 
791
                return $value;
774
                return $value;
792
 
775
 
793
 
776
 
794
 
777
 
795
        }
778
        }
796
 
779
 
797
function formaterNom($rawnom) {
780
function formaterNom($rawnom) {
798
 
781
 
799
 
782
 
800
                // Constitution du nom:
783
                // Constitution du nom:
801
                $nom = '';
784
                $nom = '';
802
 
785
 
803
                if ($rawnom['en_nom_supra_generique'] != '') {
786
                if ($rawnom['en_nom_supra_generique'] != '') {
804
                    $nom .= $rawnom['en_nom_supra_generique'];
787
                    $nom .= $rawnom['en_nom_supra_generique'];
805
                } else if ($rawnom['en_epithete_infra_generique'] != '') {
788
                } else if ($rawnom['en_epithete_infra_generique'] != '') {
806
                    $nom .= $rawnom['en_epithete_infra_generique'];
789
                    $nom .= $rawnom['en_epithete_infra_generique'];
807
                } else {
790
                } else {
808
                        if ($rawnom['en_nom_genre'] != '') {
791
                        if ($rawnom['en_nom_genre'] != '') {
809
                            $nom .=  $rawnom['en_nom_genre'];
792
                            $nom .=  $rawnom['en_nom_genre'];
810
                        }
793
                        }
811
                        if ($rawnom['en_epithete_espece']!= '') {
794
                        if ($rawnom['en_epithete_espece']!= '') {
812
                            $nom .= ' '.$rawnom['en_epithete_espece'];
795
                            $nom .= ' '.$rawnom['en_epithete_espece'];
813
                        }
796
                        }
814
                        if ($rawnom['en_epithete_infra_specifique'] != '') {
797
                        if ($rawnom['en_epithete_infra_specifique'] != '') {
815
                                if (!empty($rawnom['enrg_abreviation_rang'])) {
798
                                if (!empty($rawnom['enrg_abreviation_rang'])) {
816
                                        $nom .= ' '.$rawnom['enrg_abreviation_rang'].'';
799
                                        $nom .= ' '.$rawnom['enrg_abreviation_rang'].'';
817
                                }
800
                                }
818
                                $nom .= ' '.$rawnom['en_epithete_infra_specifique'];
801
                                $nom .= ' '.$rawnom['en_epithete_infra_specifique'];
819
                        }
802
                        }
820
 
803
 
821
                }
804
                }
822
 
805
 
823
                return $nom .$this->retournerAuteur($rawnom) ;
806
                return $nom .$this->retournerAuteur($rawnom) ;
824
 
807
 
825
 }
808
 }
826
 
809
 
827
 
810
 
828
function rechercherFamille($taxon,&$DB) {
811
function rechercherFamille($taxon,&$DB) {
829
 
812
 
830
    $row=array();
813
    $row=array();
831
 
814
 
832
    $query="SELECT DISTINCT en_ce_rang, etr_id_taxon_2, en_id_nom, en_nom_supra_generique ".
815
    $query="SELECT DISTINCT en_ce_rang, etr_id_taxon_2, en_id_nom, en_nom_supra_generique ".
833
        " FROM eflore_taxon_relation, eflore_selection_nom, eflore_nom ".
816
        " FROM eflore_taxon_relation, eflore_selection_nom, eflore_nom ".
834
        " WHERE etr_id_taxon_1 = ".$taxon.
817
        " WHERE etr_id_taxon_1 = ".$taxon.
835
        " AND etr_id_version_projet_taxon_1 = 25 ".
818
        " AND etr_id_version_projet_taxon_1 = 25 ".
836
        " AND etr_id_categorie_taxon = 3 ".
819
        " AND etr_id_categorie_taxon = 3 ".
837
        " AND etr_id_valeur_taxon = 3 ".
820
        " AND etr_id_valeur_taxon = 3 ".
838
        " AND esn_id_taxon =  etr_id_taxon_2 ".
821
        " AND esn_id_taxon =  etr_id_taxon_2 ".
839
        " AND esn_ce_statut = 3 ".
822
        " AND esn_ce_statut = 3 ".
840
        " AND esn_id_version_projet_taxon = etr_id_version_projet_taxon_1 ".
823
        " AND esn_id_version_projet_taxon = etr_id_version_projet_taxon_1 ".
841
        " AND en_id_nom = esn_id_nom ".
824
        " AND en_id_nom = esn_id_nom ".
842
        " AND esn_id_version_projet_taxon=en_id_version_projet_nom  ";
825
        " AND esn_id_version_projet_taxon=en_id_version_projet_nom  ";
843
    $res =& $DB->query($query);
826
    $res =& $DB->query($query);
844
 
827
 
845
    if (DB::isError($res)) {
828
    if (DB::isError($res)) {
846
        die($res->getMessage());
829
        die($res->getMessage());
847
    }
830
    }
848
 
831
 
849
    if ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
832
    if ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
850
        return $row;
833
        return $row;
851
    }
834
    }
852
    else {
835
    else {
853
        $row['en_ce_rang']='fin';
836
        $row['en_ce_rang']='fin';
854
        return $row;
837
        return $row;
855
    }
838
    }
856
 
839
 
857
}
840
}
858
 
841
 
859
 
842
 
860
function retournerAuteur($rawnom) {
843
function retournerAuteur($rawnom) {
861
 
844
 
862
    $auteurs = '';
845
    $auteurs = '';
863
    $auteur_basio = '';
846
    $auteur_basio = '';
864
    $auteur_modif = '';
847
    $auteur_modif = '';
865
    if (!empty($rawnom['abreviation_auteur_basio_ex']) && $rawnom['abreviation_auteur_basio_ex']!='-' )  {
848
    if (!empty($rawnom['abreviation_auteur_basio_ex']) && $rawnom['abreviation_auteur_basio_ex']!='-' )  {
866
        $auteur_basio .= $rawnom['abreviation_auteur_basio_ex'];
849
        $auteur_basio .= $rawnom['abreviation_auteur_basio_ex'];
867
        if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
850
        if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
868
            $auteur_basio .= ' ex '.$rawnom['abreviation_auteur_basio'];
851
            $auteur_basio .= ' ex '.$rawnom['abreviation_auteur_basio'];
869
        }
852
        }
870
    } else if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
853
    } else if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
871
        $auteur_basio .= $rawnom['abreviation_auteur_basio'];
854
        $auteur_basio .= $rawnom['abreviation_auteur_basio'];
872
    }
855
    }
873
 
856
 
874
    if (!empty($rawnom['abreviation_auteur_modif_ex']) && $rawnom['abreviation_auteur_modif_ex']!='-') {
857
    if (!empty($rawnom['abreviation_auteur_modif_ex']) && $rawnom['abreviation_auteur_modif_ex']!='-') {
875
        $auteur_modif .= $rawnom['abreviation_auteur_modif_ex'];
858
        $auteur_modif .= $rawnom['abreviation_auteur_modif_ex'];
876
        if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-') {
859
        if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-') {
877
            $auteur_modif .= ' ex '.$rawnom['abreviation_auteur_modif'];
860
            $auteur_modif .= ' ex '.$rawnom['abreviation_auteur_modif'];
878
        }
861
        }
879
    } else if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-')  {
862
    } else if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-')  {
880
        $auteur_modif .= $rawnom['abreviation_auteur_modif'];
863
        $auteur_modif .= $rawnom['abreviation_auteur_modif'];
881
    }
864
    }
882
 
865
 
883
    if (!empty($auteur_modif)) {
866
    if (!empty($auteur_modif)) {
884
        $auteurs = ' ('.$auteur_basio.') '.$auteur_modif;
867
        $auteurs = ' ('.$auteur_basio.') '.$auteur_modif;
885
    } elseif (!empty($auteur_basio)) {
868
    } elseif (!empty($auteur_basio)) {
886
        $auteurs = ' '.$auteur_basio;
869
        $auteurs = ' '.$auteur_basio;
887
    }
870
    }
888
 
871
 
889
    return $auteurs ;
872
    return $auteurs ;
890
}
873
}
891
 
874
 
892
 
875
 
893
 
876
 
894
 
877
 
895
}
878
}
896
 
879
 
897
function init_byte_map(){
880
function init_byte_map(){
898
    $byte_map = array();
881
    $byte_map = array();
899
    for($x=128;$x<256;++$x){
882
    for($x=128;$x<256;++$x){
900
        $byte_map[chr($x)]=utf8_encode(chr($x));
883
        $byte_map[chr($x)]=utf8_encode(chr($x));
901
    }
884
    }
902
    $cp1252_map=array(
885
    $cp1252_map=array(
903
            "\x80"=>"\xE2\x82\xAC",    // EURO SIGN
886
            "\x80"=>"\xE2\x82\xAC",    // EURO SIGN
904
            "\x82" => "\xE2\x80\x9A",  // SINGLE LOW-9 QUOTATION MARK
887
            "\x82" => "\xE2\x80\x9A",  // SINGLE LOW-9 QUOTATION MARK
905
            "\x83" => "\xC6\x92",      // LATIN SMALL LETTER F WITH HOOK
888
            "\x83" => "\xC6\x92",      // LATIN SMALL LETTER F WITH HOOK
906
            "\x84" => "\xE2\x80\x9E",  // DOUBLE LOW-9 QUOTATION MARK
889
            "\x84" => "\xE2\x80\x9E",  // DOUBLE LOW-9 QUOTATION MARK
907
            "\x85" => "\xE2\x80\xA6",  // HORIZONTAL ELLIPSIS
890
            "\x85" => "\xE2\x80\xA6",  // HORIZONTAL ELLIPSIS
908
            "\x86" => "\xE2\x80\xA0",  // DAGGER
891
            "\x86" => "\xE2\x80\xA0",  // DAGGER
909
            "\x87" => "\xE2\x80\xA1",  // DOUBLE DAGGER
892
            "\x87" => "\xE2\x80\xA1",  // DOUBLE DAGGER
910
            "\x88" => "\xCB\x86",      // MODIFIER LETTER CIRCUMFLEX ACCENT
893
            "\x88" => "\xCB\x86",      // MODIFIER LETTER CIRCUMFLEX ACCENT
911
            "\x89" => "\xE2\x80\xB0",  // PER MILLE SIGN
894
            "\x89" => "\xE2\x80\xB0",  // PER MILLE SIGN
912
            "\x8A" => "\xC5\xA0",      // LATIN CAPITAL LETTER S WITH CARON
895
            "\x8A" => "\xC5\xA0",      // LATIN CAPITAL LETTER S WITH CARON
913
            "\x8B" => "\xE2\x80\xB9",  // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
896
            "\x8B" => "\xE2\x80\xB9",  // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
914
            "\x8C" => "\xC5\x92",      // LATIN CAPITAL LIGATURE OE
897
            "\x8C" => "\xC5\x92",      // LATIN CAPITAL LIGATURE OE
915
            "\x8E" => "\xC5\xBD",      // LATIN CAPITAL LETTER Z WITH CARON
898
            "\x8E" => "\xC5\xBD",      // LATIN CAPITAL LETTER Z WITH CARON
916
            "\x91" => "\xE2\x80\x98",  // LEFT SINGLE QUOTATION MARK
899
            "\x91" => "\xE2\x80\x98",  // LEFT SINGLE QUOTATION MARK
917
            "\x92" => "\xE2\x80\x99",  // RIGHT SINGLE QUOTATION MARK
900
            "\x92" => "\xE2\x80\x99",  // RIGHT SINGLE QUOTATION MARK
918
            "\x93" => "\xE2\x80\x9C",  // LEFT DOUBLE QUOTATION MARK
901
            "\x93" => "\xE2\x80\x9C",  // LEFT DOUBLE QUOTATION MARK
919
            "\x94" => "\xE2\x80\x9D",  // RIGHT DOUBLE QUOTATION MARK
902
            "\x94" => "\xE2\x80\x9D",  // RIGHT DOUBLE QUOTATION MARK
920
            "\x95" => "\xE2\x80\xA2",  // BULLET
903
            "\x95" => "\xE2\x80\xA2",  // BULLET
921
            "\x96" => "\xE2\x80\x93",  // EN DASH
904
            "\x96" => "\xE2\x80\x93",  // EN DASH
922
            "\x97" => "\xE2\x80\x94",  // EM DASH
905
            "\x97" => "\xE2\x80\x94",  // EM DASH
923
            "\x98" => "\xCB\x9C",      // SMALL TILDE
906
            "\x98" => "\xCB\x9C",      // SMALL TILDE
924
            "\x99" => "\xE2\x84\xA2",  // TRADE MARK SIGN
907
            "\x99" => "\xE2\x84\xA2",  // TRADE MARK SIGN
925
            "\x9A" => "\xC5\xA1",      // LATIN SMALL LETTER S WITH CARON
908
            "\x9A" => "\xC5\xA1",      // LATIN SMALL LETTER S WITH CARON
926
            "\x9B" => "\xE2\x80\xBA",  // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
909
            "\x9B" => "\xE2\x80\xBA",  // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
927
            "\x9C" => "\xC5\x93",      // LATIN SMALL LIGATURE OE
910
            "\x9C" => "\xC5\x93",      // LATIN SMALL LIGATURE OE
928
            "\x9E" => "\xC5\xBE",      // LATIN SMALL LETTER Z WITH CARON
911
            "\x9E" => "\xC5\xBE",      // LATIN SMALL LETTER Z WITH CARON
929
            "\x9F" => "\xC5\xB8"       // LATIN CAPITAL LETTER Y WITH DIAERESIS
912
            "\x9F" => "\xC5\xB8"       // LATIN CAPITAL LETTER Y WITH DIAERESIS
930
                );
913
                );
931
    foreach($cp1252_map as $k=>$v){
914
    foreach($cp1252_map as $k=>$v){
932
        $byte_map[$k]=$v;
915
        $byte_map[$k]=$v;
933
    }
916
    }
934
    
917
    
935
    return $byte_map;
918
    return $byte_map;
936
}
919
}
937
 
920
 
938
function fix_latin($instr){
921
function fix_latin($instr){
939
    
922
    
940
    $byte_map = init_byte_map();
923
    $byte_map = init_byte_map();
941
    
924
    
942
    $ascii_char='[\x00-\x7F]';
925
    $ascii_char='[\x00-\x7F]';
943
    $cont_byte='[\x80-\xBF]';
926
    $cont_byte='[\x80-\xBF]';
944
    $utf8_2='[\xC0-\xDF]'.$cont_byte;
927
    $utf8_2='[\xC0-\xDF]'.$cont_byte;
945
    $utf8_3='[\xE0-\xEF]'.$cont_byte.'{2}';
928
    $utf8_3='[\xE0-\xEF]'.$cont_byte.'{2}';
946
    $utf8_4='[\xF0-\xF7]'.$cont_byte.'{3}';
929
    $utf8_4='[\xF0-\xF7]'.$cont_byte.'{3}';
947
    $utf8_5='[\xF8-\xFB]'.$cont_byte.'{4}';
930
    $utf8_5='[\xF8-\xFB]'.$cont_byte.'{4}';
948
    
931
    
949
    $nibble_good_chars = "@^($ascii_char+|$utf8_2|$utf8_3|$utf8_4|$utf8_5)(.*)$@s";
932
    $nibble_good_chars = "@^($ascii_char+|$utf8_2|$utf8_3|$utf8_4|$utf8_5)(.*)$@s";
950
 
933
 
951
    if(mb_check_encoding($instr,'UTF-8'))return $instr; // no need for the rest if it's all valid UTF-8 already
934
    if(mb_check_encoding($instr,'UTF-8'))return $instr; // no need for the rest if it's all valid UTF-8 already
952
    $outstr='';
935
    $outstr='';
953
    $char='';
936
    $char='';
954
    $rest='';
937
    $rest='';
955
    while((strlen($instr))>0){
938
    while((strlen($instr))>0){
956
        if(1==@preg_match($nibble_good_chars,$instr,$match)){
939
        if(1==@preg_match($nibble_good_chars,$instr,$match)){
957
            $char=$match[1];
940
            $char=$match[1];
958
            $rest=$match[2];
941
            $rest=$match[2];
959
            $outstr.=$char;
942
            $outstr.=$char;
960
        }elseif(1==@preg_match('@^(.)(.*)$@s',$instr,$match)){
943
        }elseif(1==@preg_match('@^(.)(.*)$@s',$instr,$match)){
961
            $char=$match[1];
944
            $char=$match[1];
962
            $rest=$match[2];
945
            $rest=$match[2];
963
            $outstr.=$byte_map[$char];
946
            $outstr.=$byte_map[$char];
964
        }
947
        }
965
        $instr=$rest;
948
        $instr=$rest;
966
    }
949
    }
967
    return $outstr;
950
    return $outstr;
968
}
951
}
969
 
952
 
970
 
953
 
971
function remove_accent($str)
954
function remove_accent($str)
972
{
955
{
973
  $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î',
956
  $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î',
974
             'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß',
957
             'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß',
975
             'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î',
958
             'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î',
976
             'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā',
959
             'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā',
977
             'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď',
960
             'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď',
978
             'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ',
961
             'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ',
979
             'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ',
962
             'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ',
980
             'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ',
963
             'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ',
981
             'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ',
964
             'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ',
982
             'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ',
965
             'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ',
983
             'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ',
966
             'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ',
984
             'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż',
967
             'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż',
985
             'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ',
968
             'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ',
986
             'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ');
969
             'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ');
987
             
970
             
988
  $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I',
971
  $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I',
989
             'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's',
972
             'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's',
990
             'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i',
973
             'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i',
991
             'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a',
974
             'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a',
992
             'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd',
975
             'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd',
993
             'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g',
976
             'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g',
994
             'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i',
977
             'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i',
995
             'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l',
978
             'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l',
996
             'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R',
979
             'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R',
997
             'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't',
980
             'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't',
998
             'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y',
981
             'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y',
999
             'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I',
982
             'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I',
1000
             'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
983
             'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
1001
  return str_replace($a, $b, $str);
984
  return str_replace($a, $b, $str);
1002
}
985
}
1003
 
986
 
1004
 
987
 
1005
function cp1252_to_utf8($str) {
988
function cp1252_to_utf8($str) {
1006
$cp1252_map = array ("\xc2\x80" => "\xe2\x82\xac",
989
$cp1252_map = array ("\xc2\x80" => "\xe2\x82\xac",
1007
"\xc2\x82" => "\xe2\x80\x9a",
990
"\xc2\x82" => "\xe2\x80\x9a",
1008
"\xc2\x83" => "\xc6\x92",    
991
"\xc2\x83" => "\xc6\x92",    
1009
"\xc2\x84" => "\xe2\x80\x9e",
992
"\xc2\x84" => "\xe2\x80\x9e",
1010
"\xc2\x85" => "\xe2\x80\xa6",
993
"\xc2\x85" => "\xe2\x80\xa6",
1011
"\xc2\x86" => "\xe2\x80\xa0",
994
"\xc2\x86" => "\xe2\x80\xa0",
1012
"\xc2\x87" => "\xe2\x80\xa1",
995
"\xc2\x87" => "\xe2\x80\xa1",
1013
"\xc2\x88" => "\xcb\x86",
996
"\xc2\x88" => "\xcb\x86",
1014
"\xc2\x89" => "\xe2\x80\xb0",
997
"\xc2\x89" => "\xe2\x80\xb0",
1015
"\xc2\x8a" => "\xc5\xa0",
998
"\xc2\x8a" => "\xc5\xa0",
1016
"\xc2\x8b" => "\xe2\x80\xb9",
999
"\xc2\x8b" => "\xe2\x80\xb9",
1017
"\xc2\x8c" => "\xc5\x92",
1000
"\xc2\x8c" => "\xc5\x92",
1018
"\xc2\x8e" => "\xc5\xbd",
1001
"\xc2\x8e" => "\xc5\xbd",
1019
"\xc2\x91" => "\xe2\x80\x98",
1002
"\xc2\x91" => "\xe2\x80\x98",
1020
"\xc2\x92" => "\xe2\x80\x99",
1003
"\xc2\x92" => "\xe2\x80\x99",
1021
"\xc2\x93" => "\xe2\x80\x9c",
1004
"\xc2\x93" => "\xe2\x80\x9c",
1022
"\xc2\x94" => "\xe2\x80\x9d",
1005
"\xc2\x94" => "\xe2\x80\x9d",
1023
"\xc2\x95" => "\xe2\x80\xa2",
1006
"\xc2\x95" => "\xe2\x80\xa2",
1024
"\xc2\x96" => "\xe2\x80\x93",
1007
"\xc2\x96" => "\xe2\x80\x93",
1025
"\xc2\x97" => "\xe2\x80\x94",
1008
"\xc2\x97" => "\xe2\x80\x94",
1026
 
1009
 
1027
"\xc2\x98" => "\xcb\x9c",
1010
"\xc2\x98" => "\xcb\x9c",
1028
"\xc2\x99" => "\xe2\x84\xa2",
1011
"\xc2\x99" => "\xe2\x84\xa2",
1029
"\xc2\x9a" => "\xc5\xa1",
1012
"\xc2\x9a" => "\xc5\xa1",
1030
"\xc2\x9b" => "\xe2\x80\xba",
1013
"\xc2\x9b" => "\xe2\x80\xba",
1031
"\xc2\x9c" => "\xc5\x93",
1014
"\xc2\x9c" => "\xc5\x93",
1032
"\xc2\x9e" => "\xc5\xbe",
1015
"\xc2\x9e" => "\xc5\xbe",
1033
"\xc2\x9f" => "\xc5\xb8"
1016
"\xc2\x9f" => "\xc5\xb8"
1034
);
1017
);
1035
return strtr ( utf8_encode ( $str ), $cp1252_map );
1018
return strtr ( utf8_encode ( $str ), $cp1252_map );
1036
}
1019
}
1037
 
1020
 
1038
/* +--Fin du code ---------------------------------------------------------------------------------------+
1021
/* +--Fin du code ---------------------------------------------------------------------------------------+
1039
* $Log$
1022
* $Log$
1040
*
1023
*
1041
*
1024
*
1042
*/
1025
*/
1043
 
1026
 
1044
 
1027
 
1045
?>
1028
?>