Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 445 Rev 449
1
<?php
1
<?php
2
 
2
 
3
// In : utf8
3
// In : utf8
4
// Out : utf8
4
// Out : utf8
5
 
5
 
6
// Import depuis une feuille de calcul
6
// Import depuis une feuille de calcul
7
 
7
 
8
// Test fonction d'import
8
// Test fonction d'import
9
// Import de base
9
// Import de base
10
// TODO : soigner les controles ...
10
// TODO : soigner les controles ...
11
// Scenario avance
11
// Scenario avance
12
 
12
 
13
 
13
 
14
// Nom des colonnes 
14
// Nom des colonnes 
15
 
15
 
16
define('COMMUNE','commune'); // soit un nom de commune, soit un code INSEE (5 chiffres), ou "nom de commune (numero departement)"
16
define('COMMUNE','commune'); // soit un nom de commune, soit un code INSEE (5 chiffres), ou "nom de commune (numero departement)"
17
define('LIEUDIT','lieu-dit'); // Texte libre
17
define('LIEUDIT','lieu-dit'); // Texte libre
18
define('STATION','station'); // Texte libre
18
define('STATION','station'); // Texte libre
19
define('MILIEU','milieu'); // Texte libre
19
define('MILIEU','milieu'); // Texte libre
20
define('LATITUDE','latitude'); // En decimal systeme WGS84
20
define('LATITUDE','latitude'); // En decimal systeme WGS84
21
define('LONGITUDE','longitude'); // En decimal systeme WGS84 
21
define('LONGITUDE','longitude'); // En decimal systeme WGS84 
22
define('NOTES','notes'); // Texte libre
22
define('NOTES','notes'); // Texte libre
23
define('DATEOBS','date'); // date au format jj/mm/aaaa
23
define('DATEOBS','date'); // date au format jj/mm/aaaa
24
define('ESPECE','espece'); // texte libre, nom latin, ou code nomenclatural (format BDNFFnn999999)
24
define('ESPECE','espece'); // texte libre, nom latin, ou code nomenclatural (format BDNFFnn999999)
25
define('IMAGE','image'); //  nom des fichiers images préalablement uploadés sur le CEL séparés par des "/"
25
define('IMAGE','image'); //  nom des fichiers images préalablement uploadés sur le CEL séparés par des "/"
26
 
26
 
27
// Resultat analyse ligne // TODO : Classe ?
27
// Resultat analyse ligne // TODO : Classe ?
28
define('LIGNE_VIDE',1); //  
28
define('LIGNE_VIDE',1); //  
29
define('LIGNE_NORMALE',2); //  
29
define('LIGNE_NORMALE',2); //  
30
define('LIGNE_IMAGE_SEULEMENT',3); //  
30
define('LIGNE_IMAGE_SEULEMENT',3); //  
-
 
31
 
-
 
32
include_once('Decoupage.class.php'); // TODO : Autoload
31
 
33
include_once('DecoupageNomLatin.class.php');
32
 
34
 
33
// Element constituant une observation 
35
// Element constituant une observation 
34
 
36
 
35
Class InventoryImportExcel extends DBAccessor  {
37
Class InventoryImportExcel extends DBAccessor  {
36
 
38
 
37
// Element constituant une observation 
39
// Element constituant une observation 
38
 
40
 
39
	var $format_observation=array(COMMUNE ,LIEUDIT ,STATION ,MILIEU ,LATITUDE ,LONGITUDE ,NOTES ,DATEOBS ,ESPECE ,IMAGE );
41
	var $format_observation=array(COMMUNE ,LIEUDIT ,STATION ,MILIEU ,LATITUDE ,LONGITUDE ,NOTES ,DATEOBS ,ESPECE ,IMAGE );
40
	var $config;
42
	var $config;
41
	var $extendExcelReader;
43
	var $extendExcelReader;
42
 
44
 
43
	function InventoryImportExcel($config) {
45
	function InventoryImportExcel($config) {
44
 
46
 
45
		$this->config=$config;
47
		$this->config=$config;
46
		// Pas d'heritage multiple en php :(
48
		// Pas d'heritage multiple en php :(
47
 
49
 
48
		$this->extendExcelReader = new ExcelReader();
50
		$this->extendExcelReader = new ExcelReader();
49
		$this->extendExcelReader->initExcelReader();
51
		$this->extendExcelReader->initExcelReader();
50
	}
52
	}
51
 
53
 
52
 
54
 
53
	function createElement($pairs) {
55
	function createElement($pairs) {
54
 
56
 
55
		// uid[0] : utilisateur obligatoire
57
		// uid[0] : utilisateur obligatoire
56
 
58
 
57
			
59
			
58
		session_start();
60
		session_start();
59
                $this->controleUtilisateur($pairs['identifiant']);
61
                $this->controleUtilisateur($pairs['identifiant']);
60
 
62
 
61
                foreach($_FILES as $file) { // FIXME : est necessaire
63
                foreach($_FILES as $file) { // FIXME : est necessaire
62
 
64
 
63
                        $infos_fichier = $file ;
65
                        $infos_fichier = $file ;
64
                }
66
                }
65
 
67
 
66
 
68
 
67
// Chargement tableau en memoire FIXME : limiter le nombre de ligne ?
69
// Chargement tableau en memoire FIXME : limiter le nombre de ligne ?
68
 
70
 
69
		$data = new Spreadsheet_Excel_Reader($infos_fichier['tmp_name'], false); // false : pour menager la memoire.
71
		$data = new Spreadsheet_Excel_Reader($infos_fichier['tmp_name'], false); // false : pour menager la memoire.
70
 
72
 
71
		$arr = array();
73
		$arr = array();
72
		$rowcount=$data->rowcount(0);
74
		$rowcount=$data->rowcount(0);
73
		$colcount=$data->colcount(0);
75
		$colcount=$data->colcount(0);
74
 
76
 
75
		if ($rowcount<=1) { // TODO : retour erreur
77
		if ($rowcount<=1) { // TODO : retour erreur
76
			print "Tableau vide";
78
			print "Tableau vide";
77
			exit;
79
			exit;
78
		}
80
		}
79
 
81
 
80
	        for($row=1;$row<=$rowcount;$row++) 
82
	        for($row=1;$row<=$rowcount;$row++) 
81
        	        for($col=1;$col<=$colcount;$col++) 
83
        	        for($col=1;$col<=$colcount;$col++) 
82
                	        $arr[$col][$row] = $data->val($row,$col,0);
84
                	        $arr[$col][$row] = $data->val($row,$col,0);
83
 
85
 
84
 
86
 
85
		//print_r($arr);
87
		//print_r($arr);
86
                        
88
                        
87
// 1 : Traitement colonnes 
89
// 1 : Traitement colonnes 
88
 
90
 
89
		$line = array();
91
		$line = array();
90
 
92
 
91
/* Les colonnes ne sont pas forcemment dans l'ordre  : on les extrait pour traitement futur  */
93
/* Les colonnes ne sont pas forcemment dans l'ordre  : on les extrait pour traitement futur  */
92
 
94
 
93
                for($col=1;$col<=$colcount;$col++) {
95
                for($col=1;$col<=$colcount;$col++) {
94
			$colonne=strtolower($arr[$col][1]);
96
			$colonne=strtolower($arr[$col][1]);
95
			switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
97
			switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
96
				case COMMUNE:
98
				case COMMUNE:
97
				case LIEUDIT:
99
				case LIEUDIT:
98
				case STATION:
100
				case STATION:
99
				case MILIEU:
101
				case MILIEU:
100
				case LATITUDE:
102
				case LATITUDE:
101
				case LONGITUDE:
103
				case LONGITUDE:
102
				case NOTES:
104
				case NOTES:
103
				case DATEOBS:
105
				case DATEOBS:
104
				case ESPECE:
106
				case ESPECE:
105
				case IMAGE:
107
				case IMAGE:
106
					$selection=array_values($arr[$col]);
108
					$selection=array_values($arr[$col]);
107
					array_shift($selection); // On ne garde pas la premiere ligne, qui contient les intitules
109
					array_shift($selection); // On ne garde pas la premiere ligne, qui contient les intitules
108
					$line[$colonne]=$selection;
110
					$line[$colonne]=$selection;
109
					break;
111
					break;
110
 
112
 
111
			}
113
			}
112
		} 
114
		} 
113
 
115
 
114
	/*	
116
	/*	
115
		print_r($line[COMMUNE]);
117
		print_r($line[COMMUNE]);
116
		print_r($line[LIEUDIT]);
118
		print_r($line[LIEUDIT]);
117
		print_r($line[STATION]);
119
		print_r($line[STATION]);
118
		print_r($line[MILIEU]);
120
		print_r($line[MILIEU]);
119
		print_r($line[LATITUDE]);
121
		print_r($line[LATITUDE]);
120
		print_r($line[LONGITUDE]);
122
		print_r($line[LONGITUDE]);
121
		print_r($line[NOTES]);
123
		print_r($line[NOTES]);
122
		print_r($line[DATEOBS]);
124
		print_r($line[DATEOBS]);
123
		print_r($line[ESPECE]);
125
		print_r($line[ESPECE]);
124
		print_r($line[IMAGE]);
126
		print_r($line[IMAGE]);
125
	*/
127
	*/
126
 
128
 
127
// 1 : Traitement lignes
129
// 1 : Traitement lignes
128
 
130
 
129
		for ($i=0;$i<=$colcount-1;$i++) {
131
		for ($i=0;$i<=$colcount-1;$i++) {
130
			// On saute les lignes vides 
132
			// On saute les lignes vides 
131
			while (($this->analyserLigne($line,$i)==LIGNE_VIDE) && ($i<=$colcount)) {
133
			while (($this->analyserLigne($line,$i)==LIGNE_VIDE) && ($i<=$colcount)) {
132
				print "vide";
134
				print "vide";
133
				$i++;
135
				$i++;
134
			}
136
			}
135
			while (($this->analyserLigne($line,$i)==LIGNE_NORMALE) && ($i<=$colcount)) {
137
			while (($this->analyserLigne($line,$i)==LIGNE_NORMALE) && ($i<=$colcount)) {
136
				$this->traiterLigne($line,$i);
138
				$this->traiterLigne($line,$i);
137
				$i++;
139
				$i++;
138
				while ((in_array($retour_analyse=$this->analyserLigne($line,$i),array(LIGNE_IMAGE_SEULEMENT, LIGNE_VIDE))) && ($i<=$colcount)) {
140
				while ((in_array($retour_analyse=$this->analyserLigne($line,$i),array(LIGNE_IMAGE_SEULEMENT, LIGNE_VIDE))) && ($i<=$colcount)) {
139
					if  ($retour_analyse==LIGNE_IMAGE_SEULEMENT) {
141
					if  ($retour_analyse==LIGNE_IMAGE_SEULEMENT) {
140
						$this->traiterLigneComplement($line,$i);
142
						$this->traiterLigneComplement($line,$i);
141
					}
143
					}
142
					else {
144
					else {
143
						print "vide";
145
						print "vide";
144
					}
146
					}
145
					$i++;
147
					$i++;
146
				}	
148
				}	
147
			}
149
			}
148
			
150
			
149
			// Cas special : seul l'image est presente
151
			// Cas special : seul l'image est presente
150
	
152
	
151
		}
153
		}
152
 
154
 
153
	}
155
	}
154
 
156
 
155
function analyserLigne($line,$i) {
157
function analyserLigne($line,$i) {
156
	$ligne_vide=true;
158
	$ligne_vide=true;
157
	$ligne_image_seulement=true;
159
	$ligne_image_seulement=true;
158
	$ligne_normale=true;
160
	$ligne_normale=true;
159
	foreach ($this->format_observation as $colonne) {
161
	foreach ($this->format_observation as $colonne) {
160
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
162
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
161
			if ($colonne!=IMAGE) {
163
			if ($colonne!=IMAGE) {
162
				$ligne_image_seulement=false;
164
				$ligne_image_seulement=false;
163
				$ligne_vide=false;
165
				$ligne_vide=false;
164
				break;
166
				break;
165
			}		
167
			}		
166
			$ligne_vide=false;
168
			$ligne_vide=false;
167
		}
169
		}
168
	}
170
	}
169
	if ($ligne_vide) {
171
	if ($ligne_vide) {
170
		return LIGNE_VIDE;
172
		return LIGNE_VIDE;
171
	}
173
	}
172
	else {
174
	else {
173
		if ($ligne_image_seulement) {
175
		if ($ligne_image_seulement) {
174
			return LIGNE_IMAGE_SEULEMENT;
176
			return LIGNE_IMAGE_SEULEMENT;
175
		}
177
		}
176
		else {
178
		else {
177
			return LIGNE_NORMALE;
179
			return LIGNE_NORMALE;
178
		}
180
		}
179
	}
181
	}
180
	
182
	
181
 
183
 
182
}
184
}
183
 
185
 
184
function traiterLigne($line,$i) {
186
function traiterLigne($line,$i) {
185
	foreach ($this->format_observation as $colonne) {
187
	foreach ($this->format_observation as $colonne) {
186
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
188
		if (isset ($line[$colonne][$i]) && $line[$colonne][$i]!='') {
187
			switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
189
			switch ($colonne) {  // On ne garde que les colonnes que l'on souhaite traiter
188
				case COMMUNE:
190
				case COMMUNE:
189
					$info_commune=$this->traiterCommune($line[COMMUNE][$i]);
191
					$info_commune=$this->traiterCommune($line[COMMUNE][$i]);
190
					echo $info_commune['name'];	
192
					echo $info_commune['name'];	
191
					echo $info_commune['code'];	
193
					echo $info_commune['code'];	
192
					break;
194
					break;
193
				case LIEUDIT:
195
				case LIEUDIT:
194
					$this->traiterLieudit($line[LIEUDIT][$i]);
196
					$this->traiterLieudit($line[LIEUDIT][$i]);
195
					break;
197
					break;
196
				case STATION:
198
				case STATION:
197
					$this->traiterStation($line[STATION][$i]);
199
					$this->traiterStation($line[STATION][$i]);
198
					break;
200
					break;
199
				case MILIEU:
201
				case MILIEU:
200
					$this->traiterMilieu($line[MILIEU][$i]);
202
					$this->traiterMilieu($line[MILIEU][$i]);
201
					break;
203
					break;
202
				case LATITUDE:
204
				case LATITUDE:
203
					$this->traiterLatitude($line[LATITUDE][$i]);
205
					$this->traiterLatitude($line[LATITUDE][$i]);
204
					break;
206
					break;
205
				case LONGITUDE:
207
				case LONGITUDE:
206
					$this->traiterLongitude($line[LONGITUDE][$i]);
208
					$this->traiterLongitude($line[LONGITUDE][$i]);
207
					break;
209
					break;
208
				case NOTES:
210
				case NOTES:
209
					$this->traiterNotes($line[NOTES][$i]);
211
					$this->traiterNotes($line[NOTES][$i]);
210
					break;
212
					break;
211
				case DATEOBS:
213
				case DATEOBS:
212
					$this->traiterDateObs($line[DATEOBS][$i]);
214
					$this->traiterDateObs($line[DATEOBS][$i]);
213
					break;
215
					break;
214
				case ESPECE:
216
				case ESPECE:
215
					$this->traiterEspece($line[ESPECE][$i]);
217
					$this->traiterEspece($line[ESPECE][$i]);
216
					break;
218
					break;
217
				case IMAGE:
219
				case IMAGE:
218
					$this->traiterImage($line[IMAGE][$i]);
220
					$this->traiterImage($line[IMAGE][$i]);
219
					break;
221
					break;
220
			}
222
			}
221
			print "\n";
223
			print "\n";
222
		}
224
		}
223
	}
225
	}
224
 
226
 
225
}
227
}
226
 
228
 
227
function traiterLigneComplement($line,$i) {
229
function traiterLigneComplement($line,$i) {
228
	$this->traiterImage($line[IMAGE][$i]);
230
	$this->traiterImage($line[IMAGE][$i]);
229
	print "\n";
231
	print "\n";
230
 
232
 
231
}
233
}
232
function traiterCommune($identifiant_commune) {  // Recherche correspondance sur nom, si pas unique, correspondance dep. sinon code insee
234
function traiterCommune($identifiant_commune) {  // Recherche correspondance sur nom, si pas unique, correspondance dep. sinon code insee
233
 
235
 
234
 
236
 
235
	echo "traitement commune";
237
	echo "traitement commune";
236
 
238
 
237
        $identifiant_commune=ltrim($identifiant_commune);
239
        $identifiant_commune=ltrim($identifiant_commune);
238
 
240
 
239
        $identifiant_commune=utf8_encode($identifiant_commune); // FIXME : devrait deja etre en utf8 a ce niveau
241
        $identifiant_commune=utf8_encode($identifiant_commune); // FIXME : devrait deja etre en utf8 a ce niveau
240
 
242
 
241
	preg_match('/(.*)\((.*)\)/',$identifiant_commune,$elements);
243
	preg_match('/(.*)\((.*)\)/',$identifiant_commune,$elements);
242
 
244
 
243
        $DB=$this->connectDB($this->config,'database_cel'); // FIXME regarder si opportun ici
245
        $DB=$this->connectDB($this->config,'database_cel'); // FIXME regarder si opportun ici
244
 
246
 
245
	if ($elements[1]) { // departement present
247
	if ($elements[1]) { // departement present
246
		$nom_commune=$elements[1];
248
		$nom_commune=$elements[1];
247
		$code_commune=$elements[2];
249
		$code_commune=$elements[2];
248
 
250
 
249
 	        $query="SELECT DISTINCT name, code  FROM locations WHERE name = '".$DB->escapeSimple($nom_commune)."%' AND code ='".$DB->escapeSimple($code_commune)."'";
251
 	        $query="SELECT DISTINCT name, code  FROM locations WHERE name = '".$DB->escapeSimple($nom_commune)."%' AND code ='".$DB->escapeSimple($code_commune)."'";
250
 
252
 
251
	}
253
	}
252
	else {
254
	else {
253
		preg_match('/([0-9][0-9])|(2A[0-9][0-9]*)|(2B[0-9][0-9]*)/',$identifiant_commune,$elements);
255
		preg_match('/([0-9][0-9])|(2A[0-9][0-9]*)|(2B[0-9][0-9]*)/',$identifiant_commune,$elements);
254
		if ($elements[1]) { // code insee  commune
256
		if ($elements[1]) { // code insee  commune
255
			$code_insee_commune=$elements[1];
257
			$code_insee_commune=$elements[1];
256
 	        	$query="SELECT DISTINCT name, code  FROM locations WHERE insee_code ='".$DB->escapeSimple($code_insee_commune)."'";
258
 	        	$query="SELECT DISTINCT name, code  FROM locations WHERE insee_code ='".$DB->escapeSimple($code_insee_commune)."'";
257
		}	
259
		}	
258
		else {
260
		else {
259
		preg_match('/(.*)/',$identifiant_commune,$elements);
261
		preg_match('/(.*)/',$identifiant_commune,$elements);
260
			if ($elements[1]) { // commune 
262
			if ($elements[1]) { // commune 
261
				$nom_commune=$elements[1];
263
				$nom_commune=$elements[1];
262
	 	        	$query="SELECT DISTINCT name, code  FROM locations WHERE name = '".$DB->escapeSimple($nom_commune)."'";
264
	 	        	$query="SELECT DISTINCT name, code  FROM locations WHERE name = '".$DB->escapeSimple($nom_commune)."'";
263
			}
265
			}
264
		}
266
		}
265
	}
267
	}
266
 
268
 
267
	
269
	
268
	$res =& $DB->query($query);
270
	$res =& $DB->query($query);
269
 
271
 
270
        if (DB::isError($res)) {
272
        if (DB::isError($res)) {
271
		 die($res->getMessage());
273
		 die($res->getMessage());
272
	}
274
	}
273
 
275
 
274
	return $res->fetchrow(DB_FETCHMODE_ASSOC);
276
	return $res->fetchrow(DB_FETCHMODE_ASSOC);
275
 
277
 
276
	
278
	
277
 
279
 
278
 
280
 
279
}
281
}
280
 
282
 
281
function traiterLieudit($lieudit) { // texte libre
283
function traiterLieudit($lieudit) { // texte libre
282
 
284
 
283
	echo "traitement lieudit";
285
	echo "traitement lieudit";
284
	return utf8_encode(ltrim($lieudit));
286
	return utf8_encode(ltrim($lieudit));
285
}
287
}
286
 
288
 
287
function traiterStation($station) { // texte libre
289
function traiterStation($station) { // texte libre
288
	echo "traitement station";
290
	echo "traitement station";
289
	return utf8_encode(ltrim($station));
291
	return utf8_encode(ltrim($station));
290
}
292
}
291
 
293
 
292
function traiterMilieu($milieu) { // texte libre
294
function traiterMilieu($milieu) { // texte libre
293
	echo "traitement milieu";
295
	echo "traitement milieu";
294
	return utf8_encode(ltrim($milieu));
296
	return utf8_encode(ltrim($milieu));
295
}
297
}
296
 
298
 
297
function traiterLatitude($latitude) {	//  verifier formal decimal + limite france ? TODO 
299
function traiterLatitude($latitude) {	//  verifier formal decimal + limite france ? TODO 
298
	echo "traitement latitude";
300
	echo "traitement latitude";
299
	return ltrim($latitude);
301
	return ltrim($latitude);
300
}
302
}
301
 
303
 
302
function traiterLongitude($longitude) { // verifier format decimal + limite france ? TODO 
304
function traiterLongitude($longitude) { // verifier format decimal + limite france ? TODO 
303
	echo "traitement longitude";
305
	echo "traitement longitude";
304
	return ltrim($longitude);
306
	return ltrim($longitude);
305
}
307
}
306
 
308
 
307
function traiterNotes($notes) { // texte libre
309
function traiterNotes($notes) { // texte libre
308
	echo "traitement notes";
310
	echo "traitement notes";
309
	return utf8_encode(ltrim($notes));
311
	return utf8_encode(ltrim($notes));
310
}
312
}
311
 
313
 
312
function traiterDateObs($dateobs) { // verifier jj/mm/aaaa sinon date vide TODO 
314
function traiterDateObs($dateobs) { // verifier jj/mm/aaaa sinon date vide TODO 
313
	echo "traitement dateobs";
315
	echo "traitement dateobs";
314
	return ltrim($notes);
316
	return ltrim($notes);
315
}
317
}
316
 
318
 
317
function traiterEspece($identifiant_espece) {  // texte libre, nom latin, ou code nomenclatural (format BDNFFnn999999)
319
function traiterEspece($identifiant_espece) {  // texte libre, nom scientifique , ou code nomenclatural (format BDNFFnn999999)
-
 
320
 
318
/*
321
	echo "traitement  espece";
319
        $identifiant_espece=ltrim($identifiant_espece);
322
        $identifiant_espece=ltrim($identifiant_espece);
320
 
323
 
321
        $identifiant_espece=utf8_encode($identifiant_espece); // FIXME : devrait deja etre en utf8 a ce niveau
324
        $identifiant_espece=utf8_encode($identifiant_espece); // FIXME : devrait deja etre en utf8 a ce niveau
322
 
325
 
323
	preg_match('/B(.*)\((.*)\)/',$identifiant_commune,$elements);
-
 
-
 
326
	preg_match('/BDNFFnn([0-9][0-9]*)/',$identifiant_espece,$elements);
-
 
327
 
-
 
328
		if ($elements[1]) { // Numero nomenclatural 
-
 
329
 
-
 
330
	 	$DB=$this->connectDB($this->config);
-
 
331
 
-
 
332
                    $query = "SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
-
 
333
                                        "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
-
 
334
                                        " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
-
 
335
                                        " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
-
 
336
                                        " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
-
 
337
                                        " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom" .
-
 
338
                                        " FROM eflore_nom, eflore_nom_rang, eflore_selection_nom a,  " .
-
 
339
                                        "         eflore_naturaliste_intitule_abreviation AS auteur_bex ".
-
 
340
                                            "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
-
 
341
                                            "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
-
 
342
                                            "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
-
 
343
                             " WHERE a.esn_id_nom= '".$elements[1]. "'".
-
 
344
                             " AND a.esn_id_version_projet_taxon = 25 ".
-
 
345
                             " AND en_ce_rang = enrg_id_rang" .
-
 
346
                             " AND en_id_nom = a.esn_id_nom" .
-
 
347
                             " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
-
 
348
	                     " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
324
	preg_match('/(.*)\((.*)\)/',$identifiant_commune,$elements);
349
        	             " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
-
 
350
                	     " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
-
 
351
                             " AND a.esn_id_version_projet_taxon=en_id_version_projet_nom ";
-
 
352
		}
-
 
353
 
-
 
354
		else { // Nom scientifique
-
 
355
 
-
 
356
 
-
 
357
			$decoupageNomLatin=new DecoupageNomLatin();
-
 
358
			$nom_latin_decoupe=$decoupageNomLatin->decouper($identifiant_espece);
-
 
359
			print_r($nom_latin_decoupe);
-
 
360
			
-
 
361
/*
-
 
362
 
-
 
363
    [nom_genre] => Acer
-
 
364
    [nom_sp] => monspessulanum
-
 
365
    [auteur_sp] => 
-
 
366
    [nom_complement] => 
-
 
367
    [type_infrasp] => 
-
 
368
    [nom_infrasp] => 
-
 
369
    [num_nomenc] => 
-
 
370
    [num_taxo] => 
-
 
371
    [rang_taxonomique] => 250
-
 
372
    [nom_courant] => monspessulanum
-
 
373
    [nom_superieur] => Acer
-
 
374
    [agg] => 
-
 
375
    [nom_complet] => Acer monspessulanum
-
 
376
 
-
 
377
/*
-
 
378
 
-
 
379
  [nom_genre] => Acer
-
 
380
    [nom_sp] => monspessulanum
-
 
381
    [auteur_sp] => 
-
 
382
    [nom_complement] => 
-
 
383
    [type_infrasp] => subsp.
-
 
384
    [nom_infrasp] => monspessulanum
-
 
385
    [num_nomenc] => 
-
 
386
    [num_taxo] => 
-
 
387
    [rang_taxonomique] => 280
-
 
388
    [nom_courant] => monspessulanum
-
 
389
    [nom_superieur] => monspessulanum
325
 
-
 
-
 
390
    [agg] => 
-
 
391
    [nom_complet] => Acer monspessulanum subsp. monspessulanum
-
 
392
 
-
 
393
*/
326
        $DB=$this->connectDB($this->config,'database_cel'); // FIXME regarder si opportun ici
394
/*
327
 
395
 
328
	if ($elements[1]) { // departeme
396
 
329
                      $query="SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
397
                      	$query="SELECT DISTINCT en_nom_genre, en_epithete_espece, en_nom_supra_generique, en_epithete_infra_generique,".
330
                                        "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
398
                                        "   auteur_bex.enaia_intitule_abrege AS abreviation_auteur_basio_ex ".
331
                                        " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
399
                                        " , auteur_b.enaia_intitule_abrege AS abreviation_auteur_basio ".
332
                                        " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
400
                                        " , auteur_mex.enaia_intitule_abrege AS abreviation_auteur_modif_ex ".
333
                                        " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
401
                                        " , auteur_m.enaia_intitule_abrege AS abreviation_auteur_modif ".
334
                                        " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom, esn_ce_statut" .
402
                                        " , en_epithete_espece, en_epithete_infra_specifique, enrg_abreviation_rang, en_id_nom, esn_ce_statut" .
335
                                        " FROM eflore_nom, eflore_nom_rang, " .
403
                                        " FROM eflore_nom, eflore_nom_rang, " .
336
                                        "         eflore_naturaliste_intitule_abreviation AS auteur_bex ".
404
                                        "         eflore_naturaliste_intitule_abreviation AS auteur_bex ".
337
                                        "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
405
                                        "   , eflore_naturaliste_intitule_abreviation AS auteur_b ".
338
                                        "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
406
                                        "   , eflore_naturaliste_intitule_abreviation AS auteur_mex ".
339
                                        "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
407
                                        "   , eflore_naturaliste_intitule_abreviation AS auteur_m ".
340
                                "   , eflore_selection_nom".
408
                                "   , eflore_selection_nom".
341
                                        " WHERE en_id_version_projet_nom = '25' AND en_nom_genre LIKE '".$DB->escapeSimple($genre)."%' " .
409
                                        " WHERE en_id_version_projet_nom = '25' AND en_nom_genre = '".$DB->escapeSimple($nom_latin_decoupe['nom_genre'])."' " .
342
                                        " AND en_ce_rang > 160 " .
410
                                        " AND en_ce_rang = '".$DB->escapeSimple($nom_latin_decoupe['rang_taxonomique'])."' " .
343
                                        " AND en_epithete_espece like '".$DB->escapeSimple($espece)."%' AND en_ce_rang = enrg_id_rang " .
411
                                        " AND en_epithete_espece =  '".$DB->escapeSimple($nom_latin_decoupe['nom_sp'])."' AND en_ce_rang = enrg_id_rang " .
344
                                        " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
412
                                        " AND en_ce_auteur_basio_ex = auteur_bex.enaia_id_intitule_naturaliste_abrege ".
345
                                        " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
413
                                        " AND en_ce_auteur_basio = auteur_b.enaia_id_intitule_naturaliste_abrege  ".
346
                                        " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
414
                                        " AND en_ce_auteur_modif_ex = auteur_mex.enaia_id_intitule_naturaliste_abrege ".
347
                                        " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
415
                                        " AND en_ce_auteur_modif = auteur_m.enaia_id_intitule_naturaliste_abrege ".
348
                                        " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
416
                                        " AND esn_id_version_projet_taxon=en_id_version_projet_nom " .
349
                                        " AND esn_id_nom= en_id_nom ".
417
                                        " AND esn_id_nom= en_id_nom ".
350
                                        " ORDER BY esn_ce_statut, en_ce_rang, en_epithete_espece, en_nom_genre LIMIT 50";
418
                                        " ORDER BY esn_ce_statut, en_ce_rang, en_epithete_espece, en_nom_genre LIMIT 50";
351
 
-
 
352
 
-
 
353
 
-
 
354
	echo "traitement  espece";
419
 
-
 
420
*/
-
 
421
			}
355
*/
422
 
356
}
423
}
357
 
424
 
358
 
425
 
359
 
426
 
360
function traiterImage($image) { // recherche id image de ce nom et creation table correspondance
427
function traiterImage($image) { // recherche id image de ce nom et creation table correspondance
361
	echo "traitement  image";
428
	echo "traitement  image";
362
}
429
}
363
 
430
 
-
 
431
 
-
 
432
// utilitaire : FIXME mutualiser avec autres scripts
-
 
433
 
-
 
434
function formaterNom($rawnom) {
-
 
435
                // Constitution du nom:
-
 
436
                $nom = '';
-
 
437
 
-
 
438
                if ($rawnom['en_nom_supra_generique'] != '') {
-
 
439
                    $nom .= $rawnom['en_nom_supra_generique'];
-
 
440
                } else if ($rawnom['en_epithete_infra_generique'] != '') {
-
 
441
                    $nom .= $rawnom['en_epithete_infra_generique'];
-
 
442
                } else {
-
 
443
                        if ($rawnom['en_nom_genre'] != '') {
-
 
444
                            $nom .=  $rawnom['en_nom_genre'];
-
 
445
                        }
-
 
446
                        if ($rawnom['en_epithete_espece']!= '') {
-
 
447
                            $nom .= ' '.$rawnom['en_epithete_espece'];
-
 
448
                        }
-
 
449
                        if ($rawnom['en_epithete_infra_specifique'] != '') {
-
 
450
                                if (!empty($rawnom['enrg_abreviation_rang'])) {
-
 
451
                                        $nom .= ' '.$rawnom['enrg_abreviation_rang'].'';
-
 
452
                                }
-
 
453
                                $nom .= ' '.$rawnom['en_epithete_infra_specifique'];
-
 
454
                        }
-
 
455
 
-
 
456
                }
-
 
457
                return $nom.$this->retournerAuteur($rawnom) ;
-
 
458
}
-
 
459
 
-
 
460
function retournerAuteur($rawnom) {
-
 
461
	$auteurs = '';
-
 
462
	$auteur_basio = '';
-
 
463
	$auteur_modif = '';
-
 
464
	if (!empty($rawnom['abreviation_auteur_basio_ex']) && $rawnom['abreviation_auteur_basio_ex']!='-' )  {
-
 
465
	    $auteur_basio .= $rawnom['abreviation_auteur_basio_ex'];
-
 
466
	    if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
-
 
467
		$auteur_basio .= ' ex '.$rawnom['abreviation_auteur_basio'];
-
 
468
	    }
-
 
469
	} else if (!empty($rawnom['abreviation_auteur_basio']) && $rawnom['abreviation_auteur_basio']!='-') {
-
 
470
	    $auteur_basio .= $rawnom['abreviation_auteur_basio'];
-
 
471
	}
-
 
472
 
-
 
473
	if (!empty($rawnom['abreviation_auteur_modif_ex']) && $rawnom['abreviation_auteur_modif_ex']!='-') {
-
 
474
	    $auteur_modif .= $rawnom['abreviation_auteur_modif_ex'];
-
 
475
	    if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-') {
-
 
476
		$auteur_modif .= ' ex '.$rawnom['abreviation_auteur_modif'];
-
 
477
	    }
-
 
478
	} else if (!empty($rawnom['abreviation_auteur_modif']) && $rawnom['abreviation_auteur_modif']!='-')  {
-
 
479
	    $auteur_modif .= $rawnom['abreviation_auteur_modif'];
-
 
480
	}
-
 
481
 
-
 
482
	if (!empty($auteur_modif)) {
-
 
483
	    $auteurs = ' ('.$auteur_basio.') '.$auteur_modif;
-
 
484
	} elseif (!empty($auteur_basio)) {
-
 
485
	    $auteurs = ' '.$auteur_basio;
-
 
486
	}
-
 
487
 
-
 
488
	return $auteurs ;
-
 
489
}
364
 
490
 
365
 
491
 
366
 
492
 
367
}
493
}
368
 
494
 
369
 
495
 
370
 
496
 
371
/* +--Fin du code ---------------------------------------------------------------------------------------+
497
/* +--Fin du code ---------------------------------------------------------------------------------------+
372
* $Log$
498
* $Log$
373
*
499
*
374
*
500
*
375
*/
501
*/
376
 
502
 
377
 
503
 
378
?>
504
?>