Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

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