Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 1125 Rev 1198
1
<?php
1
<?php
2
// /opt/lampp/bin/php cli.php chorodep -a chargerVersions
2
// /opt/lampp/bin/php cli.php chorodep -a chargerVersions
3
class Chorodep extends EfloreScript {
3
class Chorodep extends EfloreScript {
4
	protected $nbre_dep = 0;
4
	protected $nbre_dep = 0;
5
	private $type_donnee = '';
5
	private $type_donnee = '';
6
	protected $aso_num_nomenc = array();
6
	protected $aso_num_nomenc = array();
7
	protected $nbre_ligne = 0;
7
	protected $nbre_ligne = 0;
8
	protected $nbre_plte_presente = 0;
8
	protected $nbre_plte_presente = 0;
9
	protected $nbre_plte_a_confirmer = 0;
9
	protected $nbre_plte_a_confirmer = 0;
10
	protected $nbre_plte_douteux = 0;
10
	protected $nbre_plte_douteux = 0;
11
	protected $nbre_plte_erreur = 0;
11
	protected $nbre_plte_erreur = 0;
12
	protected $nbre_plte_disparue = 0;
12
	protected $nbre_plte_disparue = 0;
13
	protected $nbre_plte_erreur_a_confirmer = 0;
13
	protected $nbre_plte_erreur_a_confirmer = 0;
14
	protected $nc_autres_valeur_champ = 0;
14
	protected $nc_autres_valeur_champ = 0;
15
	protected $nc_nbre_plte_presente = 0;
15
	protected $nc_nbre_plte_presente = 0;
16
	protected $nc_nbre_plte_a_confirmer = 0;
16
	protected $nc_nbre_plte_a_confirmer = 0;
17
	protected $nc_nbre_plte_douteux = 0;
17
	protected $nc_nbre_plte_douteux = 0;
18
	protected $nc_nbre_plte_disparue = 0;
18
	protected $nc_nbre_plte_disparue = 0;
19
	protected $nc_nbre_plte_erreur = 0;
19
	protected $nc_nbre_plte_erreur = 0;
20
	protected $nc_nbre_plte_erreur_a_confirmer = 0;
20
	protected $nc_nbre_plte_erreur_a_confirmer = 0;
21
 
21
 
22
	protected $aso_totaux_dep = array();
22
	protected $aso_totaux_dep = array();
23
	private $fichier_verif = './chorodep_verif.html';
23
	private $fichier_verif = './chorodep_verif.html';
24
 
24
 
25
	public function executer() {
25
	public function executer() {
26
		try {
26
		try {
27
			$this->initialiserProjet('chorodep');
27
			$this->initialiserProjet('chorodep');
28
 
28
 
29
			// Lancement de l'action demandée
29
			// Lancement de l'action demandée
30
			$cmd = $this->getParametre('a');
30
			$cmd = $this->getParametre('a');
31
			switch ($cmd) {
31
			switch ($cmd) {
32
 
32
 
33
				case 'chargerTous' :
33
				case 'chargerTous' :
34
					$this->chargerStructureSql();
34
					$this->chargerStructureSql();
35
					$this->chargerVersions();
35
					$this->chargerVersions();
36
					$this->chargerChorodepContributeurs();
36
					$this->chargerChorodepContributeurs();
37
					$this->chargerChorodepSources();
37
					$this->chargerChorodepSources();
38
					$this->chargerChorodepOntologies();
38
					$this->chargerChorodepOntologies();
39
					break;
39
					break;
40
				case 'chargerStructureSql' :
40
				case 'chargerStructureSql' :
41
					$this->chargerStructureSql();
41
					$this->chargerStructureSql();
42
					break;
42
					break;
43
				case 'chargerVersions' :
43
				case 'chargerVersions' :
44
					$this->chargerVersions();
44
					$this->chargerVersions();
45
					break;
45
					break;
46
				case 'chargerChorodep' :
46
				case 'chargerChorodep' :
47
					$this->chargerChorodepContributeurs();
47
					$this->chargerChorodepContributeurs();
48
					$this->chargerChorodepSources();
48
					$this->chargerChorodepSources();
49
					$this->chargerChorodepOntologies();
49
					$this->chargerChorodepOntologies();
50
					break;
50
					break;
51
				case 'verifierDonnees' :
51
				case 'verifierDonnees' :
52
					$this->initialiserTraitement();
52
					$this->initialiserTraitement();
53
					$this->verifierDonnees();
53
					$this->verifierDonnees();
54
					break;
54
					break;
55
				case 'supprimerTous' :
55
				case 'supprimerTous' :
56
					$this->supprimerTous();
56
					$this->supprimerTous();
57
					break;
57
					break;
58
				// noms vernaculaires et statuts de protection
58
				// noms vernaculaires et statuts de protection
59
				case 'NVSP' :
59
				case 'NVSP' :
60
					$this->nettoyageNVSP();
60
					$this->nettoyageNVSP();
61
					$this->chargerStructureNVSP();
61
					$this->chargerStructureNVSP();
62
					$this->rabouterNomsVernaculaires();
62
					$this->rabouterNomsVernaculaires();
63
					$this->rabouterStatutsProtection();
63
					$this->rabouterStatutsProtection();
64
					break;
64
					break;
65
				case 'nettoyageNVSP' :
65
				case 'nettoyageNVSP' :
66
					$this->nettoyageNVSP();
66
					$this->nettoyageNVSP();
67
					break;
67
					break;
68
				case 'chargerStructureNVSP' :
68
				case 'chargerStructureNVSP' :
69
					$this->chargerStructureNVSP();
69
					$this->chargerStructureNVSP();
70
					break;
70
					break;
71
				case 'nomsVernaculaires' :
71
				case 'nomsVernaculaires' :
72
					$this->rabouterNomsVernaculaires();
72
					$this->rabouterNomsVernaculaires();
73
					break;
73
					break;
74
				case 'statutsProtection' :
74
				case 'statutsProtection' :
75
					$this->rabouterStatutsProtection();
75
					$this->rabouterStatutsProtection();
76
					break;
76
					break;
77
				default :
77
				default :
78
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
78
					throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
79
			}
79
			}
80
		} catch (Exception $e) {
80
		} catch (Exception $e) {
81
			$this->traiterErreur($e->getMessage());
81
			$this->traiterErreur($e->getMessage());
82
		}
82
		}
83
	}
83
	}
84
 
84
 
85
	private function chargerChorodepContributeurs() {
85
	private function chargerChorodepContributeurs() {
86
		$chemin = Config::get('chemins.chorodepContributeurs');
86
		$chemin = Config::get('chemins.chorodepContributeurs');
87
		$table = Config::get('tables.chorodepContributeurs');
87
		$table = Config::get('tables.chorodepContributeurs');
88
		$requete = "LOAD DATA INFILE '$chemin' ".
88
		$requete = "LOAD DATA INFILE '$chemin' ".
89
						"REPLACE INTO TABLE $table ".
89
						"REPLACE INTO TABLE $table ".
90
						'CHARACTER SET utf8 '.
90
						'CHARACTER SET utf8 '.
91
						'FIELDS '.
91
						'FIELDS '.
92
						"	TERMINATED BY '\t' ".
92
						"	TERMINATED BY '\t' ".
93
						"	ENCLOSED BY '' ".
93
						"	ENCLOSED BY '' ".
94
						"	ESCAPED BY '\\\' ".
94
						"	ESCAPED BY '\\\' ".
95
						'IGNORE 2 LINES';
95
						'IGNORE 2 LINES';
96
		$this->getBdd()->requeter($requete);
96
		$this->getBdd()->requeter($requete);
97
	}
97
	}
98
 
98
 
99
	private function chargerChorodepSources() {
99
	private function chargerChorodepSources() {
100
		$chemin = Config::get('chemins.chorodepSources');
100
		$chemin = Config::get('chemins.chorodepSources');
101
		$table = Config::get('tables.chorodepSources');
101
		$table = Config::get('tables.chorodepSources');
102
		$requete = "LOAD DATA INFILE '$chemin' ".
102
		$requete = "LOAD DATA INFILE '$chemin' ".
103
							"REPLACE INTO TABLE $table ".
103
							"REPLACE INTO TABLE $table ".
104
							'CHARACTER SET utf8 '.
104
							'CHARACTER SET utf8 '.
105
							'FIELDS '.
105
							'FIELDS '.
106
							"	TERMINATED BY '\t' ".
106
							"	TERMINATED BY '\t' ".
107
							"	ENCLOSED BY '' ".
107
							"	ENCLOSED BY '' ".
108
							"	ESCAPED BY '\\\' ".
108
							"	ESCAPED BY '\\\' ".
109
							'IGNORE 2 LINES';
109
							'IGNORE 2 LINES';
110
		$this->getBdd()->requeter($requete);
110
		$this->getBdd()->requeter($requete);
111
	}
111
	}
112
 
112
 
113
	private function chargerChorodepOntologies() {
113
	private function chargerChorodepOntologies() {
114
		$chemin = Config::get('chemins.chorodepOntologies');
114
		$chemin = Config::get('chemins.chorodepOntologies');
115
		$table = Config::get('tables.chorodepOntologies');
115
		$table = Config::get('tables.chorodepOntologies');
116
		$requete = "LOAD DATA INFILE '$chemin' ".
116
		$requete = "LOAD DATA INFILE '$chemin' ".
117
								"REPLACE INTO TABLE $table ".
117
								"REPLACE INTO TABLE $table ".
118
								'CHARACTER SET utf8 '.
118
								'CHARACTER SET utf8 '.
119
								'FIELDS '.
119
								'FIELDS '.
120
								"	TERMINATED BY '\t' ".
120
								"	TERMINATED BY '\t' ".
121
								"	ENCLOSED BY '' ".
121
								"	ENCLOSED BY '' ".
122
								"	ESCAPED BY '\\\' ".
122
								"	ESCAPED BY '\\\' ".
123
								'IGNORE 1 LINES';
123
								'IGNORE 1 LINES';
124
		$this->getBdd()->requeter($requete);
124
		$this->getBdd()->requeter($requete);
125
	}
125
	}
126
 
126
 
127
	private function chargerVersions() {
127
	private function chargerVersions() {
128
		$versions = explode(',', Config::get('versions'));
128
		$versions = explode(',', Config::get('versions'));
129
		$versionsDonnees = explode(',', Config::get('versionsDonnees'));
129
		$versionsDonnees = explode(',', Config::get('versionsDonnees'));
130
		foreach ($versions as $id => $version) {
130
		foreach ($versions as $id => $version) {
131
			$versionDonnees = $versionsDonnees[$id];
131
			$versionDonnees = $versionsDonnees[$id];
132
			$this->chargerStructureSqlVersion($versionDonnees);
132
			$this->chargerStructureSqlVersion($versionDonnees);
133
			$this->chargerDonneesVersion($versionDonnees, $version);
133
			$this->chargerDonneesVersion($versionDonnees, $version);
134
		}
134
		}
135
	}
135
	}
136
 
136
 
137
	private function chargerStructureSqlVersion($versionDonnees) {
137
	private function chargerStructureSqlVersion($versionDonnees) {
138
		$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
138
		$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
139
		$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $versionDonnees);
139
		$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $versionDonnees);
140
		$contenuSql = $this->recupererContenu($fichierSql);
140
		$contenuSql = $this->recupererContenu($fichierSql);
141
		$this->executerScripSql($contenuSql);
141
		$this->executerScripSql($contenuSql);
142
	}
142
	}
143
 
143
 
144
	private function chargerDonneesVersion($versionDonnees, $version) {
144
	private function chargerDonneesVersion($versionDonnees, $version) {
145
		$fichierTsvTpl = Config::get('chemins.chorodepTpl');
145
		$fichierTsvTpl = Config::get('chemins.chorodepTpl');
146
		$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $versionDonnees);
146
		$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $versionDonnees);
147
		$tableTpl = Config::get('tables.chorodepTpl');
147
		$tableTpl = Config::get('tables.chorodepTpl');
148
		$table = sprintf($tableTpl, $version);
148
		$table = sprintf($tableTpl, $version);
149
		$champs = Config::get('chorodepChamps'.$version);
149
		$champs = Config::get('chorodepChamps'.$version);
150
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
150
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
151
						"REPLACE INTO TABLE $table ".
151
						"REPLACE INTO TABLE $table ".
152
						'CHARACTER SET utf8 '.
152
						'CHARACTER SET utf8 '.
153
						'FIELDS '.
153
						'FIELDS '.
154
						"	TERMINATED BY '\t' ".
154
						"	TERMINATED BY '\t' ".
155
						"	ENCLOSED BY '' ".
155
						"	ENCLOSED BY '' ".
156
						"	ESCAPED BY '\\\' ".
156
						"	ESCAPED BY '\\\' ".
157
						"($champs) ";
157
						"($champs) ";
158
		$this->getBdd()->requeter($requete);
158
		$this->getBdd()->requeter($requete);
159
	}
159
	}
160
 
160
 
161
	private function initialiserTraitement() {
161
	private function initialiserTraitement() {
162
		//------------------------------------------------------------------------------------------------------------//
162
		//------------------------------------------------------------------------------------------------------------//
163
		// Récupération des informations à vérifier
163
		// Récupération des informations à vérifier
164
		$table = $this->getNomTableDerniereVersion();
164
		$table = $this->getNomTableDerniereVersion();
165
		$requete = 	'SELECT * '.
165
		$requete = 	'SELECT * '.
166
					"FROM $table ";
166
					"FROM $table ";
167
		$taxons = $this->getBdd()->recupererTous($requete);
167
		$taxons = $this->getBdd()->recupererTous($requete);
168
		$tax_col = $taxons[1];
168
		$tax_col = $taxons[1];
169
		$col = array_keys($tax_col);
169
		$col = array_keys($tax_col);
170
		$this->initialiserTableaux($col);
170
		$this->initialiserTableaux($col);
171
		//------------------------------------------------------------------------------------------------------------//
171
		//------------------------------------------------------------------------------------------------------------//
172
		// Analyse des données
172
		// Analyse des données
173
		echo 'Traitement de la ligne n° :';
173
		echo 'Traitement de la ligne n° :';
174
		$i = 0;
174
		$i = 0;
175
		$j = 0;
175
		$j = 0;
176
		$aso_departements_analyses = array();
176
		$aso_departements_analyses = array();
177
		$this->nbre_ligne_avec_guillemet = 0;
177
		$this->nbre_ligne_avec_guillemet = 0;
178
		foreach ($taxons as $aso_champs) {
178
		foreach ($taxons as $aso_champs) {
179
			$nom = $aso_champs['nom_sci'];
179
			$nom = $aso_champs['nom_sci'];
180
			$num_taxo = $aso_champs['num_tax'];
180
			$num_taxo = $aso_champs['num_tax'];
181
			$num_nomenc = $aso_champs['num_nom'];
181
			$num_nomenc = $aso_champs['num_nom'];
182
			if ($num_nomenc == 'nc') {
182
			if ($num_nomenc == 'nc') {
183
				$this->nc_nbre_nom++;
183
				$this->nc_nbre_nom++;
184
			} else if ($num_nomenc != 'nc') {
184
			} else if ($num_nomenc != 'nc') {
185
				$this->nbre_nom++;
185
				$this->nbre_nom++;
186
				// Vérification de la nom duplication des numéros nomenclaturaux
186
				// Vérification de la nom duplication des numéros nomenclaturaux
187
				if ( !array_key_exists($num_nomenc, (array) $this->aso_num_nomenc) ) {
187
				if ( !array_key_exists($num_nomenc, (array) $this->aso_num_nomenc) ) {
188
					$this->aso_num_nomenc[$num_nomenc]['compteur'] = 1;
188
					$this->aso_num_nomenc[$num_nomenc]['compteur'] = 1;
189
					$this->aso_num_nomenc[$num_nomenc]['ligne'] = ($this->nbre_ligne+1);
189
					$this->aso_num_nomenc[$num_nomenc]['ligne'] = ($this->nbre_ligne+1);
190
				} else {
190
				} else {
191
					$this->aso_num_nomenc[$num_nomenc]['compteur']++;
191
					$this->aso_num_nomenc[$num_nomenc]['compteur']++;
192
					$this->aso_num_nomenc[$num_nomenc]['ligne'] .= ' - '.($this->nbre_ligne+1);
192
					$this->aso_num_nomenc[$num_nomenc]['ligne'] .= ' - '.($this->nbre_ligne+1);
193
				}
193
				}
194
			}
194
			}
195
			foreach ($aso_champs as $cle => $val ) {# Pour chaque département du taxon, on regarde la valeur
195
			foreach ($aso_champs as $cle => $val ) {# Pour chaque département du taxon, on regarde la valeur
196
				$this->nbre_ligne_avec_guillemet += preg_match('/"/', $val);
196
				$this->nbre_ligne_avec_guillemet += preg_match('/"/', $val);
197
				if ( preg_match('/^\d{2}$/', $cle) ) {# Nous vérifions que le nom du champs comprend bien le numéro du département entre ()
197
				if ( preg_match('/^\d{2}$/', $cle) ) {# Nous vérifions que le nom du champs comprend bien le numéro du département entre ()
198
					$nd = $cle;# Numéro du département
198
					$nd = $cle;# Numéro du département
199
					// Nous comptons le nombre de département en base de données
199
					// Nous comptons le nombre de département en base de données
200
					if (!isset($aso_departements_analyses[$nd])) {
200
					if (!isset($aso_departements_analyses[$nd])) {
201
						$this->nbre_dep_analyse++;
201
						$this->nbre_dep_analyse++;
202
						$aso_departements_analyses[$nd] = $nd;
202
						$aso_departements_analyses[$nd] = $nd;
203
					}
203
					}
204
					if ( $num_nomenc != 'nc' && isset($val) && $val != '') {# Si le taxon n'est pas abscent du département
204
					if ( $num_nomenc != 'nc' && isset($val) && $val != '') {# Si le taxon n'est pas abscent du département
205
						if ($val == '1') {# Présent
205
						if ($val == '1') {# Présent
206
							// Calcul du nombre de plante ayant un statut "Présent"
206
							// Calcul du nombre de plante ayant un statut "Présent"
207
							$this->nbre_plte_presente++;
207
							$this->nbre_plte_presente++;
208
							// Stockage par département du nombre de plante ayant un statut "Présent"
208
							// Stockage par département du nombre de plante ayant un statut "Présent"
209
							$this->aso_totaux_dep[$nd]['plte_presente']++;
209
							$this->aso_totaux_dep[$nd]['plte_presente']++;
210
							// Stockage des informations
210
							// Stockage des informations
211
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 3, $this->id_donnee_choro++);
211
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 3, $this->id_donnee_choro++);
212
						} else if ($val == '1?') {# Présence à confirmer
212
						} else if ($val == '1?') {# Présence à confirmer
213
							// Calcul du nombre de plante ayant un statut "Présence à confirmer"
213
							// Calcul du nombre de plante ayant un statut "Présence à confirmer"
214
							$this->nbre_plte_a_confirmer++;
214
							$this->nbre_plte_a_confirmer++;
215
							// Stockage par département du nombre de plante ayant un statut "Présence à confirmer"
215
							// Stockage par département du nombre de plante ayant un statut "Présence à confirmer"
216
							$this->aso_totaux_dep[$nd]['plte_a_confirmer']++;
216
							$this->aso_totaux_dep[$nd]['plte_a_confirmer']++;
217
							// Stockage des informations
217
							// Stockage des informations
218
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 4, $this->id_donnee_choro++);
218
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 4, $this->id_donnee_choro++);
219
						} else if (preg_match('/^\s*(?:\?)\s*$/', $val)) {# Douteux
219
						} else if (preg_match('/^\s*(?:\?)\s*$/', $val)) {# Douteux
220
							// Calcul du nombre de plante ayant un statut "Disparu ou douteux"
220
							// Calcul du nombre de plante ayant un statut "Disparu ou douteux"
221
							$this->nbre_plte_douteux++;
221
							$this->nbre_plte_douteux++;
222
							// Stockage par département du nombre de plante ayant un statut "Douteux"
222
							// Stockage par département du nombre de plante ayant un statut "Douteux"
223
							$this->aso_totaux_dep[$nd]['plte_douteux']++;
223
							$this->aso_totaux_dep[$nd]['plte_douteux']++;
224
							// Stockage des informations
224
							// Stockage des informations
225
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 5, $this->id_donnee_choro++);
225
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 5, $this->id_donnee_choro++);
226
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
226
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
227
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
227
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
228
								$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
228
								$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
229
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
229
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
230
							}
230
							}
231
						} elseif (preg_match('/^\s*(?:#)\s*$/', $val)) {# Erreur
231
						} elseif (preg_match('/^\s*(?:#)\s*$/', $val)) {# Erreur
232
	                        # Calcul du nombre de plante ayant un statut "Erreur"
232
	                        # Calcul du nombre de plante ayant un statut "Erreur"
233
	                        $this->nbre_plte_erreur++;
233
	                        $this->nbre_plte_erreur++;
234
	                        # Stockage par département du nombre de plante ayant un statut "Erreur"
234
	                        # Stockage par département du nombre de plante ayant un statut "Erreur"
235
	                        $this->aso_totaux_dep[$nd]['plte_erreur']++;
235
	                        $this->aso_totaux_dep[$nd]['plte_erreur']++;
236
	                        # Stockage des informations
236
	                        # Stockage des informations
237
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
237
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
238
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
238
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
239
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
239
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
240
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
240
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
241
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
241
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
242
	                        }
242
	                        }
243
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
243
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
244
	                        # Calcul du nombre de plante ayant un statut "Disparu"
244
	                        # Calcul du nombre de plante ayant un statut "Disparu"
245
	                        $this->nbre_plte_disparue++;
245
	                        $this->nbre_plte_disparue++;
246
	                        # Stockage par département du nombre de plante ayant un statut "Disparu"
246
	                        # Stockage par département du nombre de plante ayant un statut "Disparu"
247
	                        $this->aso_totaux_dep[$nd]['plte_disparue']++;
247
	                        $this->aso_totaux_dep[$nd]['plte_disparue']++;
248
	                        # Stockage des informations
248
	                        # Stockage des informations
249
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
249
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
250
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
250
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
251
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
251
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
252
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
252
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
253
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
253
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
254
	                        }
254
	                        }
255
                    	} elseif (preg_match('/^\s*(?:#\?)\s*$/', $val)) {# Erreur à confirmer
255
                    	} elseif (preg_match('/^\s*(?:#\?)\s*$/', $val)) {# Erreur à confirmer
256
	                        # Calcul du nombre de plante ayant un statut "Erreur à confirmer"
256
	                        # Calcul du nombre de plante ayant un statut "Erreur à confirmer"
257
	                        $this->nbre_plte_erreur_a_confirmer++;
257
	                        $this->nbre_plte_erreur_a_confirmer++;
258
	                        # Stockage par département du nombre de plante ayant un statut "Erreur à confirmer"
258
	                        # Stockage par département du nombre de plante ayant un statut "Erreur à confirmer"
259
	                        $this->aso_totaux_dep[$nd]['plte_erreur_a_confirmer']++;
259
	                        $this->aso_totaux_dep[$nd]['plte_erreur_a_confirmer']++;
260
	                        # Stockage des informations
260
	                        # Stockage des informations
261
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
261
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
262
                    		if (preg_match('/^(?:\s+#\?|#\?\s+|\s+#\?\s+)$/', $val)) {# Erreur à confirmer avec espace
262
                    		if (preg_match('/^(?:\s+#\?|#\?\s+|\s+#\?\s+)$/', $val)) {# Erreur à confirmer avec espace
263
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#?".
263
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#?".
264
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
264
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
265
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
265
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
266
	                        }
266
	                        }
267
                    	} else {
267
                    	} else {
268
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
268
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
269
							$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
269
							$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
270
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
270
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
271
						}
271
						}
272
						$j++;
272
						$j++;
273
					} else if (isset($val) && $val != '') {
273
					} else if (isset($val) && $val != '') {
274
						if ($val == '1') {# Présent
274
						if ($val == '1') {# Présent
275
							// Calcul du nombre de plante 'nc' ayant un statut "Présent"
275
							// Calcul du nombre de plante 'nc' ayant un statut "Présent"
276
							$this->nc_nbre_plte_presente++;
276
							$this->nc_nbre_plte_presente++;
277
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présent"
277
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présent"
278
							$this->aso_totaux_dep[$nd]['nc_plte_presente']++;
278
							$this->aso_totaux_dep[$nd]['nc_plte_presente']++;
279
						} elseif ($val == '1?') {# Présence à confirmer
279
						} elseif ($val == '1?') {# Présence à confirmer
280
							// Calcul du nombre de plante 'nc' ayant un statut "Présence à confirmer"
280
							// Calcul du nombre de plante 'nc' ayant un statut "Présence à confirmer"
281
							$this->nc_nbre_plte_a_confirmer++;
281
							$this->nc_nbre_plte_a_confirmer++;
282
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présence à confirmer"
282
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présence à confirmer"
283
							$this->aso_totaux_dep[$nd]['nc_plte_a_confirmer']++;
283
							$this->aso_totaux_dep[$nd]['nc_plte_a_confirmer']++;
284
						} elseif (preg_match('/^(?:\?| \?|\? | \?)$/', $val)) {# Douteux
284
						} elseif (preg_match('/^(?:\?| \?|\? | \?)$/', $val)) {# Douteux
285
							// Calcul du nombre de plante 'nc' ayant un statut "Douteux"
285
							// Calcul du nombre de plante 'nc' ayant un statut "Douteux"
286
							$this->nc_nbre_plte_douteux++;
286
							$this->nc_nbre_plte_douteux++;
287
							// Stockage par département du nombre de plante 'nc' ayant un statut "Douteux"
287
							// Stockage par département du nombre de plante 'nc' ayant un statut "Douteux"
288
							$this->aso_totaux_dep[$nd]['nc_plte_douteux']++;
288
							$this->aso_totaux_dep[$nd]['nc_plte_douteux']++;
289
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
289
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
290
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
290
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
291
								$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
291
								$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
292
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
292
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
293
							}
293
							}
294
						} elseif (preg_match('/^(?:#| #|# | # )$/', $val)) {# Erreur
294
						} elseif (preg_match('/^(?:#| #|# | # )$/', $val)) {# Erreur
295
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur"
295
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur"
296
	                        $this->nc_nbre_plte_erreur++;
296
	                        $this->nc_nbre_plte_erreur++;
297
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur"
297
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur"
298
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur']++;
298
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur']++;
299
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
299
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
300
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
300
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
301
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
301
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
302
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
302
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
303
	                        }
303
	                        }
304
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
304
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
305
	                        # Calcul du nombre de plante 'nc' ayant un statut "Disparu"
305
	                        # Calcul du nombre de plante 'nc' ayant un statut "Disparu"
306
	                        $this->nc_nbre_plte_disparue++;
306
	                        $this->nc_nbre_plte_disparue++;
307
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Disparu"
307
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Disparu"
308
	                        $this->aso_totaux_dep[$nd]['nc_plte_disparue']++;
308
	                        $this->aso_totaux_dep[$nd]['nc_plte_disparue']++;
309
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
309
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
310
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
310
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
311
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
311
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
312
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
312
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
313
	                        }
313
	                        }
314
                    	} elseif (preg_match('/^\s*(?:#\?)\s*$/', $val)) {# Erreur à confirmer
314
                    	} elseif (preg_match('/^\s*(?:#\?)\s*$/', $val)) {# Erreur à confirmer
315
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur à confirmer"
315
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur à confirmer"
316
	                        $this->nc_nbre_plte_erreur_a_confirmer++;
316
	                        $this->nc_nbre_plte_erreur_a_confirmer++;
317
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur à confirmer"
317
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur à confirmer"
318
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur_a_confirmer']++;
318
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur_a_confirmer']++;
319
	                        if (preg_match('/^(?:\s+#\?|#\?\s+|\s+#\?\s+)$/', $val)) {# Erreur à confirmer avec espace
319
	                        if (preg_match('/^(?:\s+#\?|#\?\s+|\s+#\?\s+)$/', $val)) {# Erreur à confirmer avec espace
320
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#?".
320
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#?".
321
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
321
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
322
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
322
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
323
	                        }
323
	                        }
324
                    	} else {
324
                    	} else {
325
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
325
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
326
							$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
326
							$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
327
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
327
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
328
						}
328
						}
329
					}
329
					}
330
					// Affichage dans la console du numéro de l'enregistrement analysé.
330
					// Affichage dans la console du numéro de l'enregistrement analysé.
331
					//echo str_repeat(chr(8), ( strlen( $i ) + 1 ))."\t".$i++;
331
					//echo str_repeat(chr(8), ( strlen( $i ) + 1 ))."\t".$i++;
332
				}
332
				}
333
			}// fin du foreach
333
			}// fin du foreach
334
			// Affichage dans la console du numéro de l'enregistrement analysé.
334
			// Affichage dans la console du numéro de l'enregistrement analysé.
335
			echo str_repeat(chr(8), ( strlen( $this->nbre_ligne ) + 1 ))."\t".$this->nbre_ligne++;
335
			echo str_repeat(chr(8), ( strlen( $this->nbre_ligne ) + 1 ))."\t".$this->nbre_ligne++;
336
		}
336
		}
337
		echo "\n";
337
		echo "\n";
338
	}
338
	}
339
 
339
 
340
	private function initialiserTableaux($dep) {
340
	private function initialiserTableaux($dep) {
341
		foreach ($dep as $code_dep) {
341
		foreach ($dep as $code_dep) {
342
			if ( preg_match('/^\d{2}$/', $code_dep) ) {
342
			if ( preg_match('/^\d{2}$/', $code_dep) ) {
343
				$this->aso_totaux_dep[$code_dep]['plte_presente'] = 0;
343
				$this->aso_totaux_dep[$code_dep]['plte_presente'] = 0;
344
				$this->aso_totaux_dep[$code_dep]['plte_a_confirmer'] = 0;
344
				$this->aso_totaux_dep[$code_dep]['plte_a_confirmer'] = 0;
345
				$this->aso_totaux_dep[$code_dep]['plte_douteux'] = 0;
345
				$this->aso_totaux_dep[$code_dep]['plte_douteux'] = 0;
346
				$this->aso_totaux_dep[$code_dep]['plte_erreur'] = 0;
346
				$this->aso_totaux_dep[$code_dep]['plte_erreur'] = 0;
347
				$this->aso_totaux_dep[$code_dep]['plte_disparue'] = 0;
347
				$this->aso_totaux_dep[$code_dep]['plte_disparue'] = 0;
348
				$this->aso_totaux_dep[$code_dep]['plte_erreur_a_confirmer'] = 0;
348
				$this->aso_totaux_dep[$code_dep]['plte_erreur_a_confirmer'] = 0;
349
				$this->aso_totaux_dep[$code_dep]['autres_valeur_champ'] = 0;
349
				$this->aso_totaux_dep[$code_dep]['autres_valeur_champ'] = 0;
350
				$this->aso_totaux_dep[$code_dep]['nc_plte_presente'] = 0;
350
				$this->aso_totaux_dep[$code_dep]['nc_plte_presente'] = 0;
351
				$this->aso_totaux_dep[$code_dep]['nc_plte_a_confirmer'] = 0;
351
				$this->aso_totaux_dep[$code_dep]['nc_plte_a_confirmer'] = 0;
352
				$this->aso_totaux_dep[$code_dep]['nc_plte_douteux'] = 0;
352
				$this->aso_totaux_dep[$code_dep]['nc_plte_douteux'] = 0;
353
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur'] = 0;
353
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur'] = 0;
354
				$this->aso_totaux_dep[$code_dep]['nc_plte_disparue'] = 0;
354
				$this->aso_totaux_dep[$code_dep]['nc_plte_disparue'] = 0;
355
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur_a_confirmer'] = 0;
355
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur_a_confirmer'] = 0;
356
				$this->aso_totaux_dep[$code_dep]['nc_autres_valeur_champ'] = 0;
356
				$this->aso_totaux_dep[$code_dep]['nc_autres_valeur_champ'] = 0;
357
			}
357
			}
358
		}
358
		}
359
	}
359
	}
360
 
360
 
361
	private function verifierDonnees() {
361
	private function verifierDonnees() {
362
		// Ouverture du fichier contenant les résultats (sortie)
362
		// Ouverture du fichier contenant les résultats (sortie)
363
		if (!$handle = fopen($this->fichier_verif, 'w')) {
363
		if (!$handle = fopen($this->fichier_verif, 'w')) {
364
			echo "Impossible d'ouvrir le fichier ($this->fichier_verif)";
364
			echo "Impossible d'ouvrir le fichier ($this->fichier_verif)";
365
			exit;
365
			exit;
366
		}
366
		}
367
 
367
 
368
		// Création de la page
368
		// Création de la page
369
		$page = '<html>'."\n";
369
		$page = '<html>'."\n";
370
		$page .= '<head>'."\n";
370
		$page .= '<head>'."\n";
371
		$page .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n";
371
		$page .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\n";
372
		$page .= '<title>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</title>'."\n";
372
		$page .= '<title>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</title>'."\n";
373
		$page .= '</head>'."\n";
373
		$page .= '</head>'."\n";
374
		$page .= '<body>'."\n";
374
		$page .= '<body>'."\n";
375
		$page .= '<h1>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</h1>'."\n";
375
		$page .= '<h1>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</h1>'."\n";
376
		$page .= '<hr/>'."\n";
376
		$page .= '<hr/>'."\n";
377
		$page .= 	'<p>'.
377
		$page .= 	'<p>'.
378
						'Adresse fichier analysé : '.'<br />'."\n".
378
						'Adresse fichier analysé : '.'<br />'."\n".
379
						'</p>'."\n";
379
						'</p>'."\n";
380
		$page .= '<hr/>'."\n";
380
		$page .= '<hr/>'."\n";
381
		$page .= '<h2>RESULTATS PROGRAMME DE VERIFICATION</h2>'."\n";
381
		$page .= '<h2>RESULTATS PROGRAMME DE VERIFICATION</h2>'."\n";
382
		$page .= 	'<p>'.
382
		$page .= 	'<p>'.
383
						'Nom du programme générant ce fichier : '.__FILE__.'<br />'."\n".
383
						'Nom du programme générant ce fichier : '.__FILE__.'<br />'."\n".
384
						'Nombre de lignes analysées : '.$this->nbre_ligne.'<br />'."\n".
384
						'Nombre de lignes analysées : '.$this->nbre_ligne.'<br />'."\n".
385
						'Nbre de départements analysés : '.$this->nbre_dep_analyse.'<br />'."\n".
385
						'Nbre de départements analysés : '.$this->nbre_dep_analyse.'<br />'."\n".
386
						'Date d\'exécution du programme : '.date('d.m.Y').'<br />'."\n".
386
						'Date d\'exécution du programme : '.date('d.m.Y').'<br />'."\n".
387
						'</p>'."\n";
387
						'</p>'."\n";
388
		$page .= '<hr/>'."\n";
388
		$page .= '<hr/>'."\n";
389
		$page .= '<h2>RESULTATS ANALYSE CHOROLOGIE</h2>'."\n";
389
		$page .= '<h2>RESULTATS ANALYSE CHOROLOGIE</h2>'."\n";
390
		$page .= 	'<p>'.
390
		$page .= 	'<p>'.
391
						'Nombre de nom "nc" : '.$this->nc_nbre_nom.'<br />'."\n".
391
						'Nombre de nom "nc" : '.$this->nc_nbre_nom.'<br />'."\n".
392
						'Nombre de nom : '.$this->nbre_nom.'<br />'."\n".
392
						'Nombre de nom : '.$this->nbre_nom.'<br />'."\n".
393
						'Valeurs autres que 1, 1?, ?, #, #? et -|- : '.$this->autres_valeur_champ.'<br />'."\n".
393
						'Valeurs autres que 1, 1?, ?, #, #? et -|- : '.$this->autres_valeur_champ.'<br />'."\n".
394
						'Valeurs autres que 1, 1?, ?, #, #? et -|- pour les plantes nc : <br />'."\n".$this->nc_autres_valeur_champ.'</br>'."\n".
394
						'Valeurs autres que 1, 1?, ?, #, #? et -|- pour les plantes nc : <br />'."\n".$this->nc_autres_valeur_champ.'</br>'."\n".
395
						'</p>'."\n";
395
						'</p>'."\n";
396
		$page .= '<hr/>'."\n";
396
		$page .= '<hr/>'."\n";
397
		$page .= '<h2>RESULTATS ANALYSE des CHAMPS</h2>'."\n";
397
		$page .= '<h2>RESULTATS ANALYSE des CHAMPS</h2>'."\n";
398
		$page .= 	'<p>'.
398
		$page .= 	'<p>'.
399
						'Nombre de guillemets antislashés: '.$this->nbre_ligne_avec_guillemet.'<br />'."\n".
399
						'Nombre de guillemets antislashés: '.$this->nbre_ligne_avec_guillemet.'<br />'."\n".
400
						'</p>'."\n";
400
						'</p>'."\n";
401
		$page .= '<hr/>'."\n";
401
		$page .= '<hr/>'."\n";
402
		$page .= '<h2>TABLEAUX</h2>'."\n";
402
		$page .= '<h2>TABLEAUX</h2>'."\n";
403
 
403
 
404
		// Tableau des numéros nomenclaturaux dupliqués
404
		// Tableau des numéros nomenclaturaux dupliqués
405
		$table = '<table><thead><tr><th colspan="3">Tableau des numéros nomenclaturaux dupliqués </th></tr>';
405
		$table = '<table><thead><tr><th colspan="3">Tableau des numéros nomenclaturaux dupliqués </th></tr>';
406
		$table .= '<tr><th>Numéro nomenclatural</th><th>Nbre d\'itération</th><th>Lignes</th></tr></thead>';
406
		$table .= '<tr><th>Numéro nomenclatural</th><th>Nbre d\'itération</th><th>Lignes</th></tr></thead>';
407
		$afficher_tab_num_duplique = 0;
407
		$afficher_tab_num_duplique = 0;
408
		ksort($this->aso_num_nomenc);
408
		ksort($this->aso_num_nomenc);
409
		$table .= '<tbody style="text-align: center;">';
409
		$table .= '<tbody style="text-align: center;">';
410
		foreach ($this->aso_num_nomenc as $cle_nomenc => $val ) {
410
		foreach ($this->aso_num_nomenc as $cle_nomenc => $val ) {
411
			$ligne = '<tr><td>'.$cle_nomenc.'</td><td>'.$val['compteur'].'</td><td>'.$val['ligne'].'</td></tr>';
411
			$ligne = '<tr><td>'.$cle_nomenc.'</td><td>'.$val['compteur'].'</td><td>'.$val['ligne'].'</td></tr>';
412
			if ($val['compteur'] > 1) {
412
			if ($val['compteur'] > 1) {
413
				$table .= $ligne;
413
				$table .= $ligne;
414
				$afficher_tab_num_duplique = 1;
414
				$afficher_tab_num_duplique = 1;
415
			}
415
			}
416
		}
416
		}
417
		if ( $afficher_tab_num_duplique == 1 ) {
417
		if ( $afficher_tab_num_duplique == 1 ) {
418
			$page .= $table.'</tbody></table>';
418
			$page .= $table.'</tbody></table>';
419
		}
419
		}
420
 
420
 
421
		// Tableau des résultats par départements
421
		// Tableau des résultats par départements
422
		$table = '<table><thead><tr><th colspan="14">Tableau des résulats par départements</th></tr>';
422
		$table = '<table><thead><tr><th colspan="14">Tableau des résulats par départements</th></tr>';
423
		$table .= '<tr><th>Département</th><th>Nbre pltes présentes</th><th>Nbre pltes à confirmer</th>'.
423
		$table .= '<tr><th>Département</th><th>Nbre pltes présentes</th><th>Nbre pltes à confirmer</th>'.
424
			'<th>Nbre pltes douteuses</th><th>Nbre pltes disparues</th><th>Nbre pltes erreur</th><th>Nbre pltes erreur à confirmer</th>'.
424
			'<th>Nbre pltes douteuses</th><th>Nbre pltes disparues</th><th>Nbre pltes erreur</th><th>Nbre pltes erreur à confirmer</th>'.
425
			'<th>Total</th><th>Nbre pltes nc présentes</th><th>Nbre pltes nc à confirmer</th>'.
425
			'<th>Total</th><th>Nbre pltes nc présentes</th><th>Nbre pltes nc à confirmer</th>'.
426
			'<th>Nbre nc pltes douteuses</th><th>Nbre nc pltes disparues</th><th>Nbre nc pltes erreur</th><th>Nbre nc pltes erreur à confirmer</th></tr></thead>';
426
			'<th>Nbre nc pltes douteuses</th><th>Nbre nc pltes disparues</th><th>Nbre nc pltes erreur</th><th>Nbre nc pltes erreur à confirmer</th></tr></thead>';
427
		$table .= '<tbody style="text-align: center;">';
427
		$table .= '<tbody style="text-align: center;">';
428
		ksort($this->aso_totaux_dep);
428
		ksort($this->aso_totaux_dep);
429
		foreach ($this->aso_totaux_dep as $cle_dep => $val ) {
429
		foreach ($this->aso_totaux_dep as $cle_dep => $val ) {
430
			$plt_total = $val{'plte_presente'} + $val{'plte_a_confirmer'} + $val{'plte_douteux'} + $val{'plte_disparue'} + $val{'plte_erreur'} + $val{'plte_erreur_a_confirmer'};
430
			$plt_total = $val{'plte_presente'} + $val{'plte_a_confirmer'} + $val{'plte_douteux'} + $val{'plte_disparue'} + $val{'plte_erreur'} + $val{'plte_erreur_a_confirmer'};
431
			$table .= '<tr><td>'.ZgFrDepartements::getNom($cle_dep).' ('.ZgFrDepartements::getIdChaine($cle_dep).') </td>'.
431
			$table .= '<tr><td>'.ZgFrDepartements::getNom($cle_dep).' ('.ZgFrDepartements::getIdChaine($cle_dep).') </td>'.
432
				'<td>'.$val{'plte_presente'}.'</td><td>'.$val{'plte_a_confirmer'}.'</td><td>'.$val{'plte_douteux'}.'</td>'.
432
				'<td>'.$val{'plte_presente'}.'</td><td>'.$val{'plte_a_confirmer'}.'</td><td>'.$val{'plte_douteux'}.'</td>'.
433
				'<td>'.$val{'plte_disparue'}.'</td><td>'.$val{'plte_erreur'}.'</td><td>'.$val{'plte_erreur_a_confirmer'}.'</td><td>'.$plt_total.'</td>'.
433
				'<td>'.$val{'plte_disparue'}.'</td><td>'.$val{'plte_erreur'}.'</td><td>'.$val{'plte_erreur_a_confirmer'}.'</td><td>'.$plt_total.'</td>'.
434
				'<td>'.$val{'nc_plte_presente'}.'</td><td>'.$val{'nc_plte_a_confirmer'}.'</td><td>'.$val{'nc_plte_douteux'}.'</td>'.
434
				'<td>'.$val{'nc_plte_presente'}.'</td><td>'.$val{'nc_plte_a_confirmer'}.'</td><td>'.$val{'nc_plte_douteux'}.'</td>'.
435
				'<td>'.$val{'nc_plte_disparue'}.'</td><td>'.$val{'nc_plte_erreur'}.'</td><td>'.$val{'nc_plte_erreur_a_confirmer'}.'</td></tr>';
435
				'<td>'.$val{'nc_plte_disparue'}.'</td><td>'.$val{'nc_plte_erreur'}.'</td><td>'.$val{'nc_plte_erreur_a_confirmer'}.'</td></tr>';
436
		}
436
		}
437
 
437
 
438
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
438
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
439
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
439
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
440
		$plt_total = $this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur + $this->nbre_plte_erreur_a_confirmer;
440
		$plt_total = $this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur + $this->nbre_plte_erreur_a_confirmer;
441
		$table .= '<tr><td>Totaux : '.$this->nbre_dep_analyse.' départements</td><td>'.$this->nbre_plte_presente.'</td>'.
441
		$table .= '<tr><td>Totaux : '.$this->nbre_dep_analyse.' départements</td><td>'.$this->nbre_plte_presente.'</td>'.
442
			'<td>'.$this->nbre_plte_a_confirmer.'</td><td>'.$this->nbre_plte_douteux.'</td><td>'.$this->nbre_plte_disparue.'</td>'.
442
			'<td>'.$this->nbre_plte_a_confirmer.'</td><td>'.$this->nbre_plte_douteux.'</td><td>'.$this->nbre_plte_disparue.'</td>'.
443
			'<td>'.$this->nbre_plte_erreur.'</td><td>'.$this->nbre_plte_erreur_a_confirmer.'</td><td>'.$plt_total.'</td>'.
443
			'<td>'.$this->nbre_plte_erreur.'</td><td>'.$this->nbre_plte_erreur_a_confirmer.'</td><td>'.$plt_total.'</td>'.
444
			'<td>'.$this->nc_nbre_plte_presente.'</td>'.'<td>'.$this->nc_nbre_plte_a_confirmer.'</td>'.
444
			'<td>'.$this->nc_nbre_plte_presente.'</td>'.'<td>'.$this->nc_nbre_plte_a_confirmer.'</td>'.
445
			'<td>'.$this->nc_nbre_plte_douteux.'</td><td>'.$this->nc_nbre_plte_disparue.'</td><td>'.$this->nc_nbre_plte_erreur.'</td><td>'.$this->nc_nbre_plte_erreur_a_confirmer.'</td></tr>';
445
			'<td>'.$this->nc_nbre_plte_douteux.'</td><td>'.$this->nc_nbre_plte_disparue.'</td><td>'.$this->nc_nbre_plte_erreur.'</td><td>'.$this->nc_nbre_plte_erreur_a_confirmer.'</td></tr>';
446
 
446
 
447
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
447
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
448
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
448
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
449
		$total_nbre_plte = ($this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur + $this->nbre_plte_erreur_a_confirmer);
449
		$total_nbre_plte = ($this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur + $this->nbre_plte_erreur_a_confirmer);
450
		$total_nbre_plte_nc = ($this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nc_nbre_plte_douteux + $this->nc_nbre_plte_disparue + $this->nc_nbre_plte_erreur + $this->nc_nbre_plte_erreur_a_confirmer);
450
		$total_nbre_plte_nc = ($this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nc_nbre_plte_douteux + $this->nc_nbre_plte_disparue + $this->nc_nbre_plte_erreur + $this->nc_nbre_plte_erreur_a_confirmer);
451
		$table .= '<tr><td>Totaux plante / plante nc</td><td colspan="7">'.$total_nbre_plte.'</td>'.
451
		$table .= '<tr><td>Totaux plante / plante nc</td><td colspan="7">'.$total_nbre_plte.'</td>'.
452
			'<td colspan="6">'.$total_nbre_plte_nc.'</td></tr>';
452
			'<td colspan="6">'.$total_nbre_plte_nc.'</td></tr>';
453
 
453
 
454
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
454
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
455
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
455
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
456
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nbre_plte_a_confirmer;
456
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nbre_plte_a_confirmer;
457
		$table .= '<tr><td>Total plantes présentes et à confirmer</td><td colspan="13">'.$plt_total.'</td></tr>';
457
		$table .= '<tr><td>Total plantes présentes et à confirmer</td><td colspan="13">'.$plt_total.'</td></tr>';
458
 
458
 
459
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
459
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
460
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
460
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
461
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente;
461
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente;
462
		$table .= '<tr><td>Total plantes présentes</td><td colspan="13">'.$plt_total.'</td></tr>';
462
		$table .= '<tr><td>Total plantes présentes</td><td colspan="13">'.$plt_total.'</td></tr>';
463
 
463
 
464
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
464
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
465
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
465
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
466
		$plt_total = $total_nbre_plte + $total_nbre_plte_nc;
466
		$plt_total = $total_nbre_plte + $total_nbre_plte_nc;
467
		$table .= '<tr><td>Total données chorologiques</td><td colspan="13">'.$plt_total.'</td></tr>';
467
		$table .= '<tr><td>Total données chorologiques</td><td colspan="13">'.$plt_total.'</td></tr>';
468
 
468
 
469
		$table .= '</tbody></table>';
469
		$table .= '</tbody></table>';
470
		$page .= $table;
470
		$page .= $table;
471
 
471
 
472
		$page .= '<hr/>'."\n";
472
		$page .= '<hr/>'."\n";
473
		$page .= '<h2>NOTES</h2>'."\n";
473
		$page .= '<h2>NOTES</h2>'."\n";
474
		$page .= 	'<p>'.
474
		$page .= 	'<p>'.
475
						'1.- Chaque champ précédé par "ATTENTION" doit être vide.'."\n".
475
						'1.- Chaque champ précédé par "ATTENTION" doit être vide.'."\n".
476
						'S\'il ne l\'est pas, il y a une erreur'."\n".
476
						'S\'il ne l\'est pas, il y a une erreur'."\n".
477
						'</p>'."\n";
477
						'</p>'."\n";
478
		$page .= '</body>'."\n";
478
		$page .= '</body>'."\n";
479
		$page .= '</html>'."\n";
479
		$page .= '</html>'."\n";
480
		// Fermeture de la poignée sur le fichier de sortie
480
		// Fermeture de la poignée sur le fichier de sortie
481
		if (fwrite($handle, $page) === FALSE) {
481
		if (fwrite($handle, $page) === FALSE) {
482
			echo "Impossible d'écrire dans le fichier ($this->fichier_verif)";
482
			echo "Impossible d'écrire dans le fichier ($this->fichier_verif)";
483
			exit;
483
			exit;
484
		}
484
		}
485
		echo 'Ecriture du fichier de vérification de la chorologie réalisée!'."\n";
485
		echo 'Ecriture du fichier de vérification de la chorologie réalisée!'."\n";
486
		fclose($handle);
486
		fclose($handle);
487
	}
487
	}
488
 
488
 
489
	private function supprimerTous() {
489
	private function supprimerTous() {
490
		$tablesChorodep = implode(',', $this->getNomsTablesChorodep());
490
		$tablesChorodep = implode(',', $this->getNomsTablesChorodep());
491
		$tableContributeurs = Config::get('tables.chorodepContributeurs');
491
		$tableContributeurs = Config::get('tables.chorodepContributeurs');
492
		$tableSources = Config::get('tables.chorodepSources');
492
		$tableSources = Config::get('tables.chorodepSources');
493
		$tableOntologies = Config::get('tables.chorodepOntologies');
493
		$tableOntologies = Config::get('tables.chorodepOntologies');
494
		$requete = "DROP TABLE IF EXISTS chorodep_meta, $tablesChorodep, $tableContributeurs, $tableSources, $tableOntologies ";
494
		$requete = "DROP TABLE IF EXISTS chorodep_meta, $tablesChorodep, $tableContributeurs, $tableSources, $tableOntologies ";
495
		$this->getBdd()->requeter($requete);
495
		$this->getBdd()->requeter($requete);
496
	}
496
	}
497
 
497
 
498
	private function getNomsTablesChorodep() {
498
	private function getNomsTablesChorodep() {
499
		$versions = explode(',', Config::get('versions'));
499
		$versions = explode(',', Config::get('versions'));
500
		$tableTpl = Config::get('tables.chorodepTpl');
500
		$tableTpl = Config::get('tables.chorodepTpl');
501
		$tablesChorodep = array();
501
		$tablesChorodep = array();
502
		foreach ($versions as $version) {
502
		foreach ($versions as $version) {
503
			$tablesChorodep[] = sprintf($tableTpl, $version);
503
			$tablesChorodep[] = sprintf($tableTpl, $version);
504
		}
504
		}
505
		return $tablesChorodep;
505
		return $tablesChorodep;
506
	}
506
	}
507
 
507
 
508
	private function getNomTableDerniereVersion() {
508
	private function getNomTableDerniereVersion() {
509
		$version = $this->getDerniereVersion();
509
		$version = $this->getDerniereVersion();
510
		$table = sprintf(Config::get('tables.chorodepTpl'), $version);
510
		$table = sprintf(Config::get('tables.chorodepTpl'), $version);
511
		return $table;
511
		return $table;
512
	}
512
	}
513
 
513
 
514
	private function getDerniereVersion() {
514
	private function getDerniereVersion() {
515
		$version = array_pop(explode(',', Config::get('versions')));
515
		$version = array_pop(explode(',', Config::get('versions')));
516
		return $version;
516
		return $version;
517
	}
517
	}
518
 
518
 
519
	// ----------
519
	// ----------
520
	// intégration des noms vernaculaires et statuts de protection (NVSP) dans
520
	// intégration des noms vernaculaires et statuts de protection (NVSP) dans
521
	// une table dédiée, pour permettre le service intégratif de l'applciation "chorologie"
521
	// une table dédiée, pour permettre le service intégratif de l'applciation "chorologie"
522
	// (basé sur les scripts de "gentiana-services")
522
	// (basé sur les scripts de "gentiana-services")
523
	// ----------
523
	// ----------
524
 
524
 
525
	/**
525
	/**
526
	 * Dézingue tout le bousin
526
	 * Dézingue tout le bousin
527
	 * @TODO chaque méthode devrait s'autonettoyer au début afin d'être répétable
527
	 * @TODO chaque méthode devrait s'autonettoyer au début afin d'être répétable
528
	 * sans avoir à tout reprendre depuis le début (principe du dump)
528
	 * sans avoir à tout reprendre depuis le début (principe du dump)
529
	 */
529
	 */
530
	protected function nettoyageNVSP() {
530
	protected function nettoyageNVSP() {
531
		echo "---- suppression des tables\n";
531
		echo "---- suppression des tables\n";
532
		$tableStatutsProtection = Config::get('tables.statuts_protection');
532
		$tableStatutsProtection = Config::get('tables.statuts_protection');
533
		$tableNomsVernaculaires = Config::get('tables.noms_vernaculaires');
533
		$tableNomsVernaculaires = Config::get('tables.noms_vernaculaires');
534
		$req = "DROP TABLE IF EXISTS `" . $tableStatutsProtection . "`";
534
		$req = "DROP TABLE IF EXISTS `" . $tableStatutsProtection . "`";
535
		$this->getBdd()->requeter($req);
535
		$this->getBdd()->requeter($req);
536
		$req = "DROP TABLE IF EXISTS `" . $tableNomsVernaculaires . "`;";
536
		$req = "DROP TABLE IF EXISTS `" . $tableNomsVernaculaires . "`;";
537
		$this->getBdd()->requeter($req);
537
		$this->getBdd()->requeter($req);
538
	}
538
	}
539
 
539
 
540
	/**
540
	/**
541
	 * Crée les tables vides
541
	 * Crée les tables vides
542
	 */
542
	 */
543
	protected function chargerStructureNVSP() {
543
	protected function chargerStructureNVSP() {
544
		echo "---- création des tables\n";
544
		echo "---- création des tables\n";
545
		$contenuSql = $this->recupererContenu(Config::get('chemins.structureNVSP'));
545
		$contenuSql = $this->recupererContenu(Config::get('chemins.structureNVSP'));
546
		$this->executerScripSql($contenuSql);
546
		$this->executerScripSql($contenuSql);
547
	}
547
	}
548
 
548
 
549
	/**
549
	/**
550
	 * Va chercher les noms vernaculaires pour chaque espèce, et les rajoute
550
	 * Va chercher les noms vernaculaires pour chaque espèce, et les rajoute
551
	 * dans la table dédiée
551
	 * dans la table dédiée
552
	 */
552
	 */
553
	protected function rabouterNomsVernaculaires() {
553
	protected function rabouterNomsVernaculaires() {
554
		$tableNomsVernaculaires = Config::get('tables.noms_vernaculaires');
554
		$tableNomsVernaculaires = Config::get('tables.noms_vernaculaires');
555
		restore_error_handler();
555
		restore_error_handler();
556
		restore_exception_handler();
556
		restore_exception_handler();
557
		ini_set("display_errors", true);
557
		ini_set("display_errors", true);
558
		error_reporting(E_ALL);
558
		error_reporting(E_ALL);
559
		$squeletteUrlNvjfl = Config::get("url_nvjfl");
559
		$squeletteUrlNvjfl = Config::get("url_nvjfl");
560
		echo "---- récupération des noms vernaculaires depuis eFlore\n";
560
		echo "---- récupération des noms vernaculaires depuis eFlore\n";
561
		$depart = 0;
561
		$depart = 0;
562
		$nbInsertions = 0;
562
		$nbInsertions = 0;
563
		$yenaencore = true;
563
		$yenaencore = true;
564
		$tailleTranche = 1000;
564
		$tailleTranche = 1000;
565
		while ($yenaencore) {
565
		while ($yenaencore) {
566
			$url = sprintf($squeletteUrlNvjfl, $depart, $tailleTranche);
566
			$url = sprintf($squeletteUrlNvjfl, $depart, $tailleTranche);
567
			$noms = $this->chargerDonnees($url);
567
			$noms = $this->chargerDonnees($url);
568
			// Si quelqu'un parvient à dédoublonner les $valeurs, on enlève le IGNORE
568
			// Si quelqu'un parvient à dédoublonner les $valeurs, on enlève le IGNORE
569
			$req = "INSERT IGNORE INTO " . $tableNomsVernaculaires . " VALUES ";
569
			$req = "INSERT IGNORE INTO " . $tableNomsVernaculaires . " VALUES ";
570
			$valeurs = array();
570
			$valeurs = array();
571
			// insertion des données
571
			// insertion des données
572
			foreach ($noms['resultat'] as $res) {
572
			foreach ($noms['resultat'] as $res) {
573
				$numTaxons = explode(',', $res['num_taxon']);
573
				$numTaxons = explode(',', $res['num_taxon']);
574
				$nvP = $this->getBdd()->proteger($res['nom']);
574
				$nvP = $this->getBdd()->proteger($res['nom']);
575
				foreach ($numTaxons as $numTaxon) {
575
				foreach ($numTaxons as $numTaxon) {
576
					$valeurs[] = "(" . $numTaxon . ", " . $nvP  . ")";
576
					$valeurs[] = "(" . $numTaxon . ", " . $nvP  . ")";
577
				}
577
				}
578
			}
578
			}
579
			$req .= implode(",", $valeurs);
579
			$req .= implode(",", $valeurs);
580
			$this->getBdd()->executer($req);
580
			$this->getBdd()->executer($req);
581
			// prochain tour
581
			// prochain tour
582
			$nbInsertions += count($valeurs); // Faux car INSERT IGNORE - dédoublonner ou compter les insertions réelles
582
			$nbInsertions += count($valeurs); // Faux car INSERT IGNORE - dédoublonner ou compter les insertions réelles
583
			$depart += $tailleTranche;
583
			$depart += $tailleTranche;
584
			$total = $noms['entete']['total'];
584
			$total = $noms['entete']['total'];
585
			$yenaencore = $depart <= $total;
585
			$yenaencore = $depart <= $total;
586
			echo "insérés: " . min($depart, $total) . " noms, " . $nbInsertions . " attributions\n";
586
			echo "insérés: " . min($depart, $total) . " noms, " . $nbInsertions . " attributions\n";
587
		}
587
		}
588
	}
588
	}
589
 
589
 
590
	 /**
590
	 /**
591
	  * Va chercher les statuts de protection pour chaque espèce et les rajoute
591
	  * Va chercher les statuts de protection pour chaque espèce et les rajoute
592
	  * à la table; importe un fichier dump SQL des lois
592
	  * à la table; importe un fichier dump SQL des lois
593
	  */
593
	  */
594
	 protected function rabouterStatutsProtection() {
594
	 protected function rabouterStatutsProtection() {
595
	 	$tableChorologie = $this->getNomTableDerniereVersion();
595
	 	$tableChorologie = $this->getNomTableDerniereVersion();
596
	 	$tableStatutsProtection = Config::get('tables.statuts_protection');
596
	 	$tableStatutsProtection = Config::get('tables.statuts_protection');
597
	 	echo "---- récupération des statuts de protection depuis eFlore\n";
597
	 	echo "---- récupération des statuts de protection depuis eFlore\n";
598
	 	$req = "SELECT distinct num_nom FROM " . $tableChorologie;
598
	 	$req = "SELECT distinct num_nom FROM " . $tableChorologie;
599
	 	$resultat = $this->getBdd()->recupererTous($req);
599
	 	$resultat = $this->getBdd()->recupererTous($req);
600
	 	// pour chaque taxon mentionné (inefficace mais évite d'implémenter un
600
	 	// pour chaque taxon mentionné (inefficace mais évite d'implémenter un
601
	 	// mode liste sur le service eflore/sptb
601
	 	// mode liste sur le service eflore/sptb
602
	 	$squeletteUrlSptb = Config::get("url_sptb");
602
	 	$squeletteUrlSptb = Config::get("url_sptb");
-
 
603
	 	$statuts != array();
-
 
604
	 	
603
	 	foreach ($resultat as $res) {
605
	 	foreach ($resultat as $res) {
604
	 		$nn = $res['num_nom'];
606
	 		$nn = $res['num_nom'];
605
	 		//echo "NN: $nn\n";
607
	 		//echo "NN: $nn\n";
606
	 		if ($nn != 0) {
608
	 		if ($nn != 0) {
607
	 			$url = sprintf($squeletteUrlSptb, $nn);
609
	 			$url = sprintf($squeletteUrlSptb, $nn);
608
	 			//echo "URL: $url\n";
610
	 			//echo "URL: $url\n";
609
	 			$statuts = $this->chargerDonnees($url);
611
	 			$statuts = $this->chargerDonnees($url);
610
	 			//echo "STATUTS: " . print_r($statuts, true) . "\n";
612
	 			//echo "STATUTS: " . print_r($statuts, true) . "\n";
611
	 			if (count($statuts) > 0) {
613
	 			if ($statuts != array() && array_count_values($statuts) > 0) {
612
	 				$json = array();
614
	 				$json = array();
613
	 				foreach ($statuts as $statut) {
615
	 				foreach ($statuts as $statut) {
614
 						$nouveauStatut = array();
616
 						$nouveauStatut = array();
615
 						$nouveauStatut['zone'] = $statut['code_zone_application'];
617
 						$nouveauStatut['zone'] = $statut['code_zone_application'];
616
 						$nouveauStatut['lien'] = $statut['hyperlien_legifrance'];
-
 
617
 						$json[] =  $nouveauStatut;
618
 						$json[] =  $nouveauStatut;
618
	 				}
619
	 				}
619
	 				// Si au moins un statut
620
	 				// Si au moins un statut
620
	 				if (count($json) > 0) {
621
	 				if (count($json) > 0) {
621
	 					$json = json_encode($json);
622
	 					$json = json_encode($json);
622
	 					//echo "JSON: " . print_r($json, true) . "\n";
623
	 					//echo "JSON: " . print_r($json, true) . "\n";
623
	 					// Insertion d'un bout de JSON
624
	 					// Insertion d'un bout de JSON
624
	 					$jsonP = $this->getBdd()->proteger($json);
625
	 					$jsonP = $this->getBdd()->proteger($json);
625
	 					$nnP = $this->getBdd()->proteger($nn);
626
	 					$nnP = $this->getBdd()->proteger($nn);
626
	 					$reqIns = "INSERT INTO " . $tableStatutsProtection
627
	 					$reqIns = "INSERT INTO " . $tableStatutsProtection
627
	 					. " values($nnP, $jsonP)";
628
	 					. " values($nnP, $jsonP)";
628
	 					//echo "ReqIns: $reqIns\n";
629
	 					//echo "ReqIns: $reqIns\n";
629
	 					$this->getBdd()->executer($reqIns);
630
	 					$this->getBdd()->executer($reqIns);
630
	 				}
631
	 				}
631
	 			}
632
	 			}
632
	 		}
633
	 		}
633
	 	}
634
	 	}
634
	 }
635
	 }
635
}
636
}
636
 
637
 
637
class ZgFrDepartements {
638
class ZgFrDepartements {
638
	static private $departements =
639
	static private $departements =
639
        array(
640
        array(
640
        "01" => array("Ain", "01", 1),
641
        "01" => array("Ain", "01", 1),
641
        "02" => array("Aisne", "02", 2),
642
        "02" => array("Aisne", "02", 2),
642
        "03" => array("Allier", "03", 3),
643
        "03" => array("Allier", "03", 3),
643
        "04" => array("Alpes-de-Haute-Provence", "04", 4),
644
        "04" => array("Alpes-de-Haute-Provence", "04", 4),
644
        "05" => array("Hautes-Alpes", "05", 5),
645
        "05" => array("Hautes-Alpes", "05", 5),
645
        "06" => array("Alpes-Maritimes", "06", 6),
646
        "06" => array("Alpes-Maritimes", "06", 6),
646
        "07" => array("Ardèche", "07", 7),
647
        "07" => array("Ardèche", "07", 7),
647
        "08" => array("Ardennes", "08", 8),
648
        "08" => array("Ardennes", "08", 8),
648
        "09" => array("Ariège", "09", 9),
649
        "09" => array("Ariège", "09", 9),
649
        "10" => array("Aube", "10", 10),
650
        "10" => array("Aube", "10", 10),
650
        "11" => array("Aude", "11", 11),
651
        "11" => array("Aude", "11", 11),
651
        "12" => array("Aveyron", "12", 12),
652
        "12" => array("Aveyron", "12", 12),
652
        "13" => array("Bouches-du-Rhône", "13", 13),
653
        "13" => array("Bouches-du-Rhône", "13", 13),
653
        "14" => array("Calvados", "14", 14),
654
        "14" => array("Calvados", "14", 14),
654
        "15" => array("Cantal", "15", 15),
655
        "15" => array("Cantal", "15", 15),
655
        "16" => array("Charente", "16", 16),
656
        "16" => array("Charente", "16", 16),
656
        "17" => array("Charente-Maritime", "17", 17),
657
        "17" => array("Charente-Maritime", "17", 17),
657
        "18" => array("Cher", "18", 18),
658
        "18" => array("Cher", "18", 18),
658
        "19" => array("Corrèze", "19", 19),
659
        "19" => array("Corrèze", "19", 19),
659
        "20" => array("Corse", "20", 20),
660
        "20" => array("Corse", "20", 20),
660
        "2A" => array("Haute-Corse", "2A", 20),
661
        "2A" => array("Haute-Corse", "2A", 20),
661
        "2B" => array("Corse-du-Sud", "2B", 20),
662
        "2B" => array("Corse-du-Sud", "2B", 20),
662
        "21" => array("Côte-d'Or", "21", 21),
663
        "21" => array("Côte-d'Or", "21", 21),
663
        "22" => array("Côtes-d'Armor", "22", 22),
664
        "22" => array("Côtes-d'Armor", "22", 22),
664
        "23" => array("Creuse", "23", 23),
665
        "23" => array("Creuse", "23", 23),
665
        "24" => array("Dordogne", "24", 24),
666
        "24" => array("Dordogne", "24", 24),
666
        "25" => array("Doubs","25", 25),
667
        "25" => array("Doubs","25", 25),
667
        "26" => array("Drôme", "26", 26),
668
        "26" => array("Drôme", "26", 26),
668
        "27" => array("Eure", "27", 27),
669
        "27" => array("Eure", "27", 27),
669
        "28" => array("Eure-et-Loir", "28", 28),
670
        "28" => array("Eure-et-Loir", "28", 28),
670
        "29" => array("Finistère", "29", 29),
671
        "29" => array("Finistère", "29", 29),
671
        "30" => array("Gard", "30", 30),
672
        "30" => array("Gard", "30", 30),
672
        "31" => array("Haute-Garonne", "31", 31),
673
        "31" => array("Haute-Garonne", "31", 31),
673
        "32" => array("Gers", "32", 32),
674
        "32" => array("Gers", "32", 32),
674
        "33" => array("Gironde", "33", 33),
675
        "33" => array("Gironde", "33", 33),
675
        "34" => array("Hérault", "34", 34),
676
        "34" => array("Hérault", "34", 34),
676
        "35" => array("Ille-et-Vilaine", "35", 35),
677
        "35" => array("Ille-et-Vilaine", "35", 35),
677
        "36" => array("Indre", "36", 36),
678
        "36" => array("Indre", "36", 36),
678
        "37" => array("Indre-et-Loire", "37", 37),
679
        "37" => array("Indre-et-Loire", "37", 37),
679
        "38" => array("Isère", "38", 38),
680
        "38" => array("Isère", "38", 38),
680
        "39" => array("Jura", "39", 39),
681
        "39" => array("Jura", "39", 39),
681
        "40" => array("Landes", "40", 40),
682
        "40" => array("Landes", "40", 40),
682
        "41" => array("Loir-et-Cher", "41", 41),
683
        "41" => array("Loir-et-Cher", "41", 41),
683
        "42" => array("Loire", "42", 42),
684
        "42" => array("Loire", "42", 42),
684
        "43" => array("Haute-Loire", "43", 43),
685
        "43" => array("Haute-Loire", "43", 43),
685
        "44" => array("Loire-Atlantique", "44", 44),
686
        "44" => array("Loire-Atlantique", "44", 44),
686
        "45" => array("Loiret", "45", 45),
687
        "45" => array("Loiret", "45", 45),
687
        "46" => array("Lot", "46", 46),
688
        "46" => array("Lot", "46", 46),
688
        "47" => array("Lot-et-Garonne", "47", 47),
689
        "47" => array("Lot-et-Garonne", "47", 47),
689
        "48" => array("Lozére ", "48", 48),
690
        "48" => array("Lozére ", "48", 48),
690
        "49" => array("Maine-et-Loire", "49", 49),
691
        "49" => array("Maine-et-Loire", "49", 49),
691
        "50" => array("Manche", "50", 50),
692
        "50" => array("Manche", "50", 50),
692
        "51" => array("Marne", "51", 51),
693
        "51" => array("Marne", "51", 51),
693
        "52" => array("Haute-Marne", "52", 52),
694
        "52" => array("Haute-Marne", "52", 52),
694
        "53" => array("Mayenne", "53", 53),
695
        "53" => array("Mayenne", "53", 53),
695
        "54" => array("Meurthe-et-Moselle", "54", 54),
696
        "54" => array("Meurthe-et-Moselle", "54", 54),
696
        "55" => array("Meuse", "55", 55),
697
        "55" => array("Meuse", "55", 55),
697
        "56" => array("Morbihan", "56", 56),
698
        "56" => array("Morbihan", "56", 56),
698
        "57" => array("Moselle", "57", 57),
699
        "57" => array("Moselle", "57", 57),
699
        "58" => array("Nièvre", "58", 58),
700
        "58" => array("Nièvre", "58", 58),
700
        "59" => array("Nord", "59", 59),
701
        "59" => array("Nord", "59", 59),
701
        "60" => array("Oise", "60", 60),
702
        "60" => array("Oise", "60", 60),
702
        "61" => array("Orne", "61", 61),
703
        "61" => array("Orne", "61", 61),
703
        "62" => array("Pas-de-Calais", "62", 62),
704
        "62" => array("Pas-de-Calais", "62", 62),
704
        "63" => array("Puy-de-Dôme", "63", 63),
705
        "63" => array("Puy-de-Dôme", "63", 63),
705
        "64" => array("Pyrénées-Atlantiques", "64", 64),
706
        "64" => array("Pyrénées-Atlantiques", "64", 64),
706
        "65" => array("Hautes-Pyrénées", "65", 65),
707
        "65" => array("Hautes-Pyrénées", "65", 65),
707
        "66" => array("Pyrénées-Orientales", "66", 66),
708
        "66" => array("Pyrénées-Orientales", "66", 66),
708
        "67" => array("Bas-Rhin", "67", 67),
709
        "67" => array("Bas-Rhin", "67", 67),
709
        "68" => array("Haut-Rhin", "68", 68),
710
        "68" => array("Haut-Rhin", "68", 68),
710
        "69" => array("Rhône", "69", 69),
711
        "69" => array("Rhône", "69", 69),
711
        "70" => array("Haute-Saône", "70", 70),
712
        "70" => array("Haute-Saône", "70", 70),
712
        "71" => array("Saône-et-Loire", "71", 71),
713
        "71" => array("Saône-et-Loire", "71", 71),
713
        "72" => array("Sarthe", "72", 72),
714
        "72" => array("Sarthe", "72", 72),
714
        "73" => array("Savoie", "73", 73),
715
        "73" => array("Savoie", "73", 73),
715
        "74" => array("Haute-Savoie", "74", 74),
716
        "74" => array("Haute-Savoie", "74", 74),
716
        "75" => array("Paris", "75", 75),
717
        "75" => array("Paris", "75", 75),
717
        "76" => array("Seine-Maritime", "76", 76),
718
        "76" => array("Seine-Maritime", "76", 76),
718
        "77" => array("Seine-et-Marne", "77", 77),
719
        "77" => array("Seine-et-Marne", "77", 77),
719
        "78" => array("Yvelines", "78", 78),
720
        "78" => array("Yvelines", "78", 78),
720
        "79" => array("Deux-Sèvres", "79", 79),
721
        "79" => array("Deux-Sèvres", "79", 79),
721
        "80" => array("Somme", "80", 80),
722
        "80" => array("Somme", "80", 80),
722
        "81" => array("Tarn", "81", 81),
723
        "81" => array("Tarn", "81", 81),
723
        "82" => array("Tarn-et-Garonne", "82", 82),
724
        "82" => array("Tarn-et-Garonne", "82", 82),
724
        "83" => array("Var", "83", 83),
725
        "83" => array("Var", "83", 83),
725
        "84" => array("Vaucluse", "84", 84),
726
        "84" => array("Vaucluse", "84", 84),
726
        "85" => array("Vendée", "85", 85),
727
        "85" => array("Vendée", "85", 85),
727
        "86" => array("Vienne", "86", 86),
728
        "86" => array("Vienne", "86", 86),
728
        "87" => array("Haute-Vienne", "87", 87),
729
        "87" => array("Haute-Vienne", "87", 87),
729
        "88" => array("Vosges", "88", 88),
730
        "88" => array("Vosges", "88", 88),
730
        "89" => array("Yonne", "89", 89),
731
        "89" => array("Yonne", "89", 89),
731
        "90" => array("Territoire-de-Belfort", "90", 90),
732
        "90" => array("Territoire-de-Belfort", "90", 90),
732
        "91" => array("Essonne", "91", 91),
733
        "91" => array("Essonne", "91", 91),
733
        "92" => array("Hauts-de-Seine", "92", 92),
734
        "92" => array("Hauts-de-Seine", "92", 92),
734
        "93" => array("Seine-Saint-Denis", "93", 93),
735
        "93" => array("Seine-Saint-Denis", "93", 93),
735
        "94" => array("Val-de-Marne", "94", 94),
736
        "94" => array("Val-de-Marne", "94", 94),
736
        "95" => array("Val-d'Oise", "95", 95),
737
        "95" => array("Val-d'Oise", "95", 95),
737
        "96" => array("aaa", "96", 96),
738
        "96" => array("aaa", "96", 96),
738
        "971" => array("Guadeloupe", "971", 971),
739
        "971" => array("Guadeloupe", "971", 971),
739
        "972" => array("Martinique", "972", 972),
740
        "972" => array("Martinique", "972", 972),
740
        "973" => array("Guyane", "973", 973),
741
        "973" => array("Guyane", "973", 973),
741
        "974" => array("Réunion", "974", 974),
742
        "974" => array("Réunion", "974", 974),
742
        "99" => array("Etranger", "99", 99),
743
        "99" => array("Etranger", "99", 99),
743
        );
744
        );
744
 
745
 
745
	static public function get() {
746
	static public function get() {
746
		return self::$departements;
747
		return self::$departements;
747
	}
748
	}
748
 
749
 
749
    static public function getNom($n) {
750
    static public function getNom($n) {
750
		return self::$departements[$n][0];
751
		return self::$departements[$n][0];
751
	}
752
	}
752
 
753
 
753
	static public function getIdChaine($n) {
754
	static public function getIdChaine($n) {
754
		return self::$departements[$n][1];
755
		return self::$departements[$n][1];
755
	}
756
	}
756
 
757
 
757
	static public function getIdNumerique($n) {
758
	static public function getIdNumerique($n) {
758
		return (int)self::$departements[$n][2];
759
		return (int)self::$departements[$n][2];
759
	}
760
	}
760
 
761
 
761
	static public function getIdEflore($n) {
762
	static public function getIdEflore($n) {
762
		return (int)self::$departements[$n][3];
763
		return (int)self::$departements[$n][3];
763
	}
764
	}
764
}
765
}
765
?>
766
?>