Subversion Repositories eFlore/Applications.cel

Rev

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

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