Subversion Repositories eFlore/Applications.cel

Rev

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

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