Subversion Repositories eFlore/Applications.cel

Rev

Rev 602 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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