Subversion Repositories eFlore/Applications.cel

Rev

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

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