Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 470 Rev 486
1
<?php
1
<?php
2
// commande : /opt/lampp/bin/php cli.php description_sp -a tester -n /home/jennifer/Tela-botanica_projets/Coste/descriptions/html
2
// commande : /opt/lampp/bin/php cli.php description_sp -a tester -n /home/jennifer/Tela-botanica_projets/Coste/descriptions/html
3
class Description {
3
class Description {
4
 
4
 
5
	const DOSSIER_V0 = '../../../donnees/coste/0.00/';
5
	const DOSSIER_V0 = '../../../donnees/coste/0.00/';
6
	const DOSSIER_DSC_HTML = '../../../donnees/coste/descriptions/html/';
6
	const DOSSIER_DSC_HTML = '../../../donnees/coste/descriptions/html/';
7
	const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
7
	const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
8
	const DOSSIER_LOG = 'log/';
8
	const DOSSIER_LOG = 'log/';
9
 
9
 
10
	private $auteurs = array();
10
	private $auteurs = array();
11
	private $dossierBase = '';
11
	private $dossierBase = '';
12
	private $conteneur = null;
12
	private $conteneur = null;
13
	private $outils = null;
13
	private $outils = null;
14
	private $messages = null;
14
	private $messages = null;
15
	private $action = '';
15
	private $action = '';
16
	private $nomFichier = '';
16
	private $nomFichier = '';
17
	private $nomDossier = '';
17
	private $nomDossier = '';
18
	private $listeFichiers = array();
18
	private $listeFichiers = array();
19
	private $fichierNum = '';
19
	private $fichierNum = '';
20
	private $fichier = '';
20
	private $fichier = '';
21
	private $log = '';
21
	private $log = '';
22
	private $correspondance = array();
22
	private $correspondance = array();
23
	private $infosCorrespondanceBase = array(
23
	private $infosCorrespondanceBase = array(
24
		'nom_sci' => '',
24
		'nom_sci' => '',
25
		'auteur' => '',
25
		'auteur' => '',
26
		'nom_addendum' => '',
26
		'nom_addendum' => '',
27
		'annee' => '',
27
		'annee' => '',
28
		'biblio_origine' => '',
28
		'biblio_origine' => '',
29
		'rang' => 290,
29
		'rang' => 290,
30
		'nom_francais' => '',
30
		'nom_francais' => '',
31
		'nom_coste' => '',
31
		'nom_coste' => '',
32
		'auteur_coste' => '',
32
		'auteur_coste' => '',
33
		'biblio_coste' => '',
33
		'biblio_coste' => '',
34
		'num_nom_coste' => '',
34
		'num_nom_coste' => '',
35
		'num_nom_retenu_coste' => '',
35
		'num_nom_retenu_coste' => '',
36
		'num_tax_sup_coste' => '',
36
		'num_tax_sup_coste' => '',
37
		'tome' => '',
37
		'tome' => '',
38
		'page' => '',
38
		'page' => '',
39
		'synonymie_coste' => '',
39
		'synonymie_coste' => '',
40
		'bdnff_nn' => '',
40
		'flore_bdtfx_nn' => '',
41
		'bdnff_nt' => '');
41
		'flore_bdtfx_nt' => '');
42
 
42
 
43
	public function __construct(Conteneur $conteneur) {
43
	public function __construct(Conteneur $conteneur) {
44
		mb_internal_encoding('UTF-8');
44
		mb_internal_encoding('UTF-8');
45
		setlocale(LC_ALL, 'fr_FR.UTF-8');
45
		setlocale(LC_ALL, 'fr_FR.UTF-8');
46
		$this->conteneur = $conteneur;
46
		$this->conteneur = $conteneur;
47
		$this->outils = $conteneur->getOutils();
47
		$this->outils = $conteneur->getOutils();
48
		$this->messages = $conteneur->getMessages();
48
		$this->messages = $conteneur->getMessages();
49
		$this->dossierBase = dirname(__FILE__).'/';
49
		$this->dossierBase = dirname(__FILE__).'/';
50
	}
50
	}
51
 
51
 
52
	public function genererDescriptionTxt() {
52
	public function genererDescriptionTxt() {
53
		$this->chargerFichiers();
53
		$this->chargerFichiers();
54
 
54
 
55
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
55
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
56
			$this->messages->afficherAvancement("Création des descriptions au format txt");
56
			$this->messages->afficherAvancement("Création des descriptions au format txt");
57
			$this->genererFichier();
57
			$this->genererFichier();
58
		}
58
		}
59
		echo "\n";
59
		echo "\n";
60
	}
60
	}
61
 
61
 
62
	public function verifierDescriptionTxt() {
62
	public function verifierDescriptionTxt() {
63
		$this->chargerFichiers();
63
		$this->chargerFichiers();
64
 
64
 
65
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
65
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
66
			$this->messages->afficherAvancement("Analyse des descriptions");
66
			$this->messages->afficherAvancement("Analyse des descriptions");
67
			$this->verifierFichier();
67
			$this->verifierFichier();
68
		}
68
		}
69
		echo "\n";
69
		echo "\n";
70
		$this->ecrireLogs();
70
		$this->ecrireLogs();
71
	}
71
	}
72
 
72
 
73
	public function genererCorrespondance() {
73
	public function genererCorrespondance() {
74
		$this->chargerFichiers();
74
		$this->chargerFichiers();
75
 
75
 
76
		$this->ajouterLogSyno(implode("\t", array_keys($this->infosCorrespondanceBase)));
76
		$this->ajouterLogSyno(implode("\t", array_keys($this->infosCorrespondanceBase)));
77
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
77
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
78
			$this->messages->afficherAvancement("Création du fichier de correspondance");
78
			$this->messages->afficherAvancement("Création du fichier de correspondance");
79
			$this->extraireInfosCorrespondance();
79
			$this->extraireInfosCorrespondance();
80
		}
80
		}
81
		echo "\n";
81
		echo "\n";
82
 
82
 
83
		$fichierTxt = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv';
83
		$fichierTxt = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv';
84
		$txtCorrespondance = $this->creerFichierCsvCorrespondance();
84
		$txtCorrespondance = $this->creerFichierCsvCorrespondance();
85
		file_put_contents($fichierTxt, $txtCorrespondance);
85
		file_put_contents($fichierTxt, $txtCorrespondance);
86
 
86
 
87
		ksort($this->auteurs);
87
		ksort($this->auteurs);
88
		foreach ($this->auteurs as $auteur => $nbre) {
88
		foreach ($this->auteurs as $auteur => $nbre) {
89
			$this->ajouterLogAuteur("$auteur\t$nbre");
89
			$this->ajouterLogAuteur("$auteur\t$nbre");
90
		}
90
		}
91
 
91
 
92
		$this->ecrireLogs();
92
		$this->ecrireLogs();
93
	}
93
	}
94
 
94
 
95
 
95
 
96
	private function chargerFichiers() {
96
	private function chargerFichiers() {
97
		$this->nomDossier = $this->dossierBase.self::DOSSIER_DSC_HTML;
97
		$this->nomDossier = $this->dossierBase.self::DOSSIER_DSC_HTML;
98
		if (file_exists($this->nomDossier) === true) {
98
		if (file_exists($this->nomDossier) === true) {
99
			if (is_dir($this->nomDossier)) {
99
			if (is_dir($this->nomDossier)) {
100
				if ($dossierOuvert = opendir($this->nomDossier)) {
100
				if ($dossierOuvert = opendir($this->nomDossier)) {
101
					while (($this->nomFichier = readdir($dossierOuvert)) !== false) {
101
					while (($this->nomFichier = readdir($dossierOuvert)) !== false) {
102
						if (! is_dir($this->nomFichier) && preg_match('/e([0-9]{4})\.htm/', $this->nomFichier, $match)) {
102
						if (! is_dir($this->nomFichier) && preg_match('/e([0-9]{4})\.htm/', $this->nomFichier, $match)) {
103
							$this->listeFichiers[$match[1]] = $this->nomDossier.'/'.$this->nomFichier;
103
							$this->listeFichiers[$match[1]] = $this->nomDossier.'/'.$this->nomFichier;
104
						}
104
						}
105
					}
105
					}
106
					closedir($dossierOuvert);
106
					closedir($dossierOuvert);
107
				} else {
107
				} else {
108
					$this->messages->traiterErreur("Le dossier {$this->nomDossier} n'a pas pu être ouvert.");
108
					$this->messages->traiterErreur("Le dossier {$this->nomDossier} n'a pas pu être ouvert.");
109
				}
109
				}
110
			} else {
110
			} else {
111
				$this->messages->traiterErreur("{$this->nomDossier} n'est pas un dossier.");
111
				$this->messages->traiterErreur("{$this->nomDossier} n'est pas un dossier.");
112
			}
112
			}
113
		} else {
113
		} else {
114
			$this->messages->traiterErreur("Le dossier {$this->nomDossier} est introuvable.");
114
			$this->messages->traiterErreur("Le dossier {$this->nomDossier} est introuvable.");
115
		}
115
		}
116
 
116
 
117
		asort($this->listeFichiers);
117
		asort($this->listeFichiers);
118
	}
118
	}
119
 
119
 
120
	private function verifierFichier() {
120
	private function verifierFichier() {
121
		$donnees = $this->analyserFichier();
121
		$donnees = $this->analyserFichier();
122
		$txt = $donnees['texte'];
122
		$txt = $donnees['texte'];
123
		$this->verifierOuvertureFermetureBalise($txt);
123
		$this->verifierOuvertureFermetureBalise($txt);
124
		$this->verifierAbscenceEgale($txt);
124
		$this->verifierAbscenceEgale($txt);
125
		$this->verifierNumero($txt);
125
		$this->verifierNumero($txt);
126
		// TODO : vérifier les noms vernauclaire qui sont abrégés
126
		// TODO : vérifier les noms vernauclaire qui sont abrégés
127
	}
127
	}
128
 
128
 
129
	private function verifierOuvertureFermetureBalise($txt) {
129
	private function verifierOuvertureFermetureBalise($txt) {
130
		$b_ouvert = substr_count($txt, '<B>');
130
		$b_ouvert = substr_count($txt, '<B>');
131
		$b_ferme = substr_count($txt, '</B>');
131
		$b_ferme = substr_count($txt, '</B>');
132
		if ($b_ouvert != $b_ferme) {
132
		if ($b_ouvert != $b_ferme) {
133
			$message = "{$this->fichierNum} contient $b_ouvert balises B ouvertes et $b_ferme fermées";
133
			$message = "{$this->fichierNum} contient $b_ouvert balises B ouvertes et $b_ferme fermées";
134
			$this->ajouterLogAnalyse($message);
134
			$this->ajouterLogAnalyse($message);
135
		}
135
		}
136
		$i_ouvert = substr_count($txt, '<I>');
136
		$i_ouvert = substr_count($txt, '<I>');
137
		$i_ferme = substr_count($txt, '</I>');
137
		$i_ferme = substr_count($txt, '</I>');
138
		if ($i_ouvert != $i_ferme) {
138
		if ($i_ouvert != $i_ferme) {
139
			$message = "{$this->fichierNum} contient $i_ouvert balises I ouvertes et $i_ferme fermées";
139
			$message = "{$this->fichierNum} contient $i_ouvert balises I ouvertes et $i_ferme fermées";
140
			$this->ajouterLogAnalyse($message);
140
			$this->ajouterLogAnalyse($message);
141
		}
141
		}
142
	}
142
	}
143
 
143
 
144
	private function verifierAbscenceEgale($txt) {
144
	private function verifierAbscenceEgale($txt) {
145
		if (strripos($txt, '=') === false) {
145
		if (strripos($txt, '=') === false) {
146
			$message = "{$this->fichierNum} ne contient pas le séparateur de phénologie (=)";
146
			$message = "{$this->fichierNum} ne contient pas le séparateur de phénologie (=)";
147
			$this->ajouterLogAnalyse($message);
147
			$this->ajouterLogAnalyse($message);
148
		}
148
		}
149
	}
149
	}
150
 
150
 
151
	private function verifierNumero($txt) {
151
	private function verifierNumero($txt) {
152
		if (preg_match('/^<B>[0-9]{1,4}. – /', $txt) == 0) {
152
		if (preg_match('/^<B>[0-9]{1,4}. – /', $txt) == 0) {
153
			$message = "{$this->fichierNum} ne contient pas un numéro bien formaté";
153
			$message = "{$this->fichierNum} ne contient pas un numéro bien formaté";
154
			$this->ajouterLogAnalyse($message);
154
			$this->ajouterLogAnalyse($message);
155
		}
155
		}
156
	}
156
	}
157
 
157
 
158
	private function extraireInfosCorrespondance() {
158
	private function extraireInfosCorrespondance() {
159
		$donnees = $this->analyserFichier();
159
		$donnees = $this->analyserFichier();
160
		$infos = $this->infosCorrespondanceBase;
160
		$infos = $this->infosCorrespondanceBase;
161
 
161
 
162
		$titre = $donnees['titre'];
162
		$titre = $donnees['titre'];
163
		if (preg_match('/^Coste ([0-9]+) - ((?:(?! - ).)+) - F[0-9]+, (?:(?! - ).)+ - (G[0-9]+), T([123])[.]p([0-9]+)$/', $titre, $match)) {
163
		if (preg_match('/^Coste ([0-9]+) - ((?:(?! - ).)+) - F[0-9]+, (?:(?! - ).)+ - (G[0-9]+), T([123])[.]p([0-9]+)$/', $titre, $match)) {
164
			$infos['num_nom_coste'] = $match[1];
164
			$infos['num_nom_coste'] = $match[1];
165
			$infos['num_nom_retenu_coste'] = $match[1];
165
			$infos['num_nom_retenu_coste'] = $match[1];
166
			$infos['nom_sci'] = $match[2];
166
			$infos['nom_sci'] = $match[2];
167
			$infos['num_tax_sup_coste'] = $match[3];
167
			$infos['num_tax_sup_coste'] = $match[3];
168
			$infos['tome'] = $match[4];
168
			$infos['tome'] = $match[4];
169
			$infos['page'] = $match[5];
169
			$infos['page'] = $match[5];
170
		} else {
170
		} else {
171
			$this->messages->traiterErreur("Le titre du fichier {$this->fichierNum} est mal formaté.");
171
			$this->messages->traiterErreur("Le titre du fichier {$this->fichierNum} est mal formaté.");
172
		}
172
		}
173
 
173
 
174
		$corres = $donnees['correspondance'];
174
		$corres = $donnees['correspondance'];
175
		if (preg_match('/^Bdnff ([0-9]+) - (?:(?! - ).)+ - (?:(?! - ).)+ - Tax=([0-9]+)$/', $corres, $match)) {
175
		if (preg_match('/^Bdnff ([0-9]+) - (?:(?! - ).)+ - (?:(?! - ).)+ - Tax=([0-9]+)$/', $corres, $match)) {
176
			$infos['bdnff_nn'] = $match[1];
176
			$infos['flore_bdtfx_nn'] = $match[1];
177
			$infos['bdnff_nt'] = $match[2];
177
			$infos['flore_bdtfx_nt'] = $match[2];
178
		} else {
178
		} else {
179
			$this->messages->traiterErreur("La correspondance du fichier {$this->fichierNum} est mal formatée.");
179
			$this->messages->traiterErreur("La correspondance du fichier {$this->fichierNum} est mal formatée.");
180
		}
180
		}
181
 
181
 
182
		$txt = $donnees['texte'];
182
		$txt = $donnees['texte'];
183
		$txt = $this->corrigerDescription($txt);
183
		$txt = $this->corrigerDescription($txt);
184
		if (preg_match('/^<B>[0-9]{1,4}[.] – ([^<]+)<\/B> ([^–]*)– (?:<I>([^<]+)<\/I>[.] – |<I>([^<]+)<\/I>( \([^)]+\))[.] – |[A-Z]|<I>(?:Sous-|Espèce|Turion|Souche|Plante|Feuille|Racine))/u', $txt, $match)) {
184
		if (preg_match('/^<B>[0-9]{1,4}[.] – ([^<]+)<\/B> ([^–]*)– (?:<I>([^<]+)<\/I>[.] – |<I>([^<]+)<\/I>( \([^)]+\))[.] – |[A-Z]|<I>(?:Sous-|Espèce|Turion|Souche|Plante|Feuille|Racine))/u', $txt, $match)) {
185
			$infos['nom_coste'] = trim($match[1]);
185
			$infos['nom_coste'] = trim($match[1]);
186
			$infos['rang'] = $this->obtenirRangNom($infos['nom_coste']);
186
			$infos['rang'] = $this->obtenirRangNom($infos['nom_coste']);
187
			$infos['auteur_coste'] = trim($match[2]);
187
			$infos['auteur_coste'] = trim($match[2]);
188
			$infos['nom_francais'] = isset($match[3]) ? $match[3] : '';
188
			$infos['nom_francais'] = isset($match[3]) ? $match[3] : '';
189
			$infos['nom_francais'] = isset($match[4]) && isset($match[5]) ? $match[4].$match[5] : $infos['nom_francais'];
189
			$infos['nom_francais'] = isset($match[4]) && isset($match[5]) ? $match[4].$match[5] : $infos['nom_francais'];
190
			if (strpos($infos['auteur_coste'], '(' ) !== false) {
190
			if (strpos($infos['auteur_coste'], '(' ) !== false) {
191
				if (preg_match('/^([^(]*)\(([^)]+)\)(?:[.]?| ; ((?:(?! – ).)+))$/', $infos['auteur_coste'], $match)) {
191
				if (preg_match('/^([^(]*)\(([^)]+)\)(?:[.]?| ; ((?:(?! – ).)+))$/', $infos['auteur_coste'], $match)) {
192
					$infos['auteur_coste'] = $this->traiterAuteur(trim($match[1]));
192
					$infos['auteur_coste'] = $this->traiterAuteur(trim($match[1]));
193
					$infos['auteur'] = $this->normaliserAuteur($infos['auteur_coste']);
193
					$infos['auteur'] = $this->normaliserAuteur($infos['auteur_coste']);
194
					$parentheseContenu = trim($match[2]);
194
					$parentheseContenu = trim($match[2]);
195
					if (preg_match('/^[0-9]+$/', $parentheseContenu)) {
195
					if (preg_match('/^[0-9]+$/', $parentheseContenu)) {
196
						$infos['annee'] = $parentheseContenu;
196
						$infos['annee'] = $parentheseContenu;
197
					} else {
197
					} else {
198
						$infos['synonymie_coste'] = $parentheseContenu;
198
						$infos['synonymie_coste'] = $parentheseContenu;
199
						$infos['biblio_coste'] = isset($match[3]) ? trim($match[3]) : '';
199
						$infos['biblio_coste'] = isset($match[3]) ? trim($match[3]) : '';
200
					}
200
					}
201
				} else {
201
				} else {
202
					$this->messages->traiterErreur("L'auteur du nom sciencitifique du fichier {$this->fichierNum} est mal formaté.");
202
					$this->messages->traiterErreur("L'auteur du nom sciencitifique du fichier {$this->fichierNum} est mal formaté.");
203
				}
203
				}
204
			}
204
			}
205
		} else {
205
		} else {
206
			$this->messages->traiterErreur("La texte du fichier {$this->fichierNum} est mal formaté.");
206
			$this->messages->traiterErreur("La texte du fichier {$this->fichierNum} est mal formaté.");
207
		}
207
		}
208
 
208
 
209
		$this->correspondance[] = $infos;
209
		$this->correspondance[] = $infos;
210
 
210
 
211
		if ($infos['synonymie_coste'] != '') {
211
		if ($infos['synonymie_coste'] != '') {
212
			$this->traiterSynonymie($infos);
212
			$this->traiterSynonymie($infos);
213
		}
213
		}
214
	}
214
	}
215
 
215
 
216
	private function normaliserAuteur($auteurCoste) {
216
	private function normaliserAuteur($auteurCoste) {
217
		$auteur = '';
217
		$auteur = '';
218
		if ($auteurCoste != '') {
218
		if ($auteurCoste != '') {
219
			$auteur = str_replace(' et ', ' & ', $auteurCoste);
219
			$auteur = str_replace(' et ', ' & ', $auteurCoste);
220
		}
220
		}
221
		return $auteur;
221
		return $auteur;
222
	}
222
	}
223
 
223
 
224
	private function traiterSynonymie($infos) {
224
	private function traiterSynonymie($infos) {
225
		$synoCoste = $infos['synonymie_coste'];
225
		$synoCoste = $infos['synonymie_coste'];
-
 
226
		$synoCoste = preg_replace('/, etc[.]$/', '', $synoCoste);
226
		$synoCoste = preg_replace('/^et /', '', $synoCoste);
227
		$synoCoste = preg_replace('/^et /', '', $synoCoste);
227
		$synoCoste = preg_replace('/^(([A-Z][.]|[A-Z]{3,}) [A-Z]{3,}(?:(?! et ).+)) et ([A-Z]{3,}) ((?![A-Z]{3,}).+)$/', '$1 ; $2 $3 $4', $synoCoste);
228
		$synoCoste = preg_replace('/^(([A-Z][.]|[A-Z]{3,}) [A-Z]{3,}(?:(?! et ).+)) et ([A-Z]{3,}) ((?![A-Z]{3,}).+)$/', '$1 ; $2 $3 $4', $synoCoste);
228
		$synoCoste = preg_replace('/ et ((?:[A-Z][.]|[A-Z]{3,}) [A-Z]{3,})/', ' ; $1', $synoCoste);
229
		$synoCoste = preg_replace('/ et ((?:[A-Z][.]|[A-Z]{3,}) [A-Z]{3,})/', ' ; $1', $synoCoste);
229
		$synoCoste = preg_replace('/, ((?:(?!non |part[.]|an |G[.] G[.]|part[.]|centr[.])[^,]+))/', ' ;$1', $synoCoste);
230
		$synoCoste = preg_replace('/, ((?:(?!non |part[.]|an |G[.] G[.]|part[.]|centr[.])[^,]+))/', ' ;$1', $synoCoste);
230
 
231
 
231
		$synonymes = explode(';', $synoCoste);
232
		$synonymes = explode(';', $synoCoste);
232
 
233
 
233
		foreach ($synonymes as $num => $syno) {
234
		foreach ($synonymes as $num => $syno) {
234
			$synoTraite = $this->traiterNomSyno($syno);
235
			$synoTraite = $this->traiterNomSyno($syno);
235
			$nomSci = $this->obtenirNomSci($synoTraite, $infos, $synonymes, $num);
236
			$nomSci = $this->obtenirNomSci($synoTraite, $infos, $synonymes, $num);
236
			$rang = $this->obtenirRangNom($nomSci);
237
			$rang = $this->obtenirRangNom($nomSci);
237
			$complementNom = $this->obtenirComplementNom($synoTraite);
238
			$complementNom = $this->obtenirComplementNom($synoTraite);
238
			$auteurCoste = $this->obtenirAuteur($complementNom);
239
			$auteurCoste = $this->obtenirAuteur($complementNom);
239
			$auteur = $this->normaliserAuteur($auteurCoste);
240
			$auteur = $this->normaliserAuteur($auteurCoste);
240
			$this->ajouterAuteur($auteur);
241
			$this->ajouterAuteur($auteur);
241
			$biblioCoste = $this->obtenirBiblio($complementNom);
242
			$biblioCoste = $this->obtenirBiblio($complementNom);
242
			$annee = $this->extraireAnnee($complementNom);
243
			$annee = $this->extraireAnnee($complementNom);
243
 
244
 
244
			$infosSyno = $this->infosCorrespondanceBase;
245
			$infosSyno = $this->infosCorrespondanceBase;
245
			$infosSyno['nom_sci'] = $nomSci;
246
			$infosSyno['nom_sci'] = $nomSci;
246
			$infosSyno['auteur'] = $auteur;
247
			$infosSyno['auteur'] = $auteur;
247
			$infosSyno['biblio_origine'] = $biblioCoste;
248
			$infosSyno['biblio_origine'] = $biblioCoste;
248
			$infosSyno['annee'] = $annee;
249
			$infosSyno['annee'] = $annee;
249
			$infosSyno['nom_addendum'] =  $this->obtenirNomAddendum($syno);
250
			$infosSyno['nom_addendum'] =  $this->obtenirNomAddendum($syno);
250
 
251
 
251
			$infosSyno['rang'] = $rang;
252
			$infosSyno['rang'] = $rang;
252
			$infosSyno['nom_coste'] = $synoTraite;
253
			$infosSyno['nom_coste'] = $synoTraite;
253
			$infosSyno['auteur_coste'] = $auteurCoste;
254
			$infosSyno['auteur_coste'] = $auteurCoste;
254
			$infosSyno['biblio_coste'] =  $biblioCoste;
255
			$infosSyno['biblio_coste'] =  $biblioCoste;
255
			$infosSyno['num_nom_coste'] = $infos['num_nom_coste'].'.'.($num + 1);
256
			$infosSyno['num_nom_coste'] = $infos['num_nom_coste'].'.'.($num + 1);
256
			$infosSyno['num_nom_retenu_coste'] = $infos['num_nom_coste'];
257
			$infosSyno['num_nom_retenu_coste'] = $infos['num_nom_coste'];
257
			$this->ajouterLogSyno(implode("\t", $infosSyno));
258
			$this->ajouterLogSyno(implode("\t", $infosSyno));
258
			$this->correspondance[] = $infosSyno;
259
			$this->correspondance[] = $infosSyno;
259
		}
260
		}
260
	}
261
	}
261
 
262
 
262
	private function traiterNomSyno($syno) {
263
	private function traiterNomSyno($syno) {
263
		$syno = $this->nettoyerEspacesNomSyno($syno);
264
		$syno = $this->nettoyerEspacesNomSyno($syno);
264
		$syno = preg_replace('/^(?:avec|(?:compr|incl)[.]) /', '', $syno);
265
		$syno = preg_replace('/^(?:avec|(?:compr|incl)[.]) /', '', $syno);
265
		return $syno;
266
		return $syno;
266
	}
267
	}
267
 
268
 
268
	private function nettoyerEspacesNomSyno($syno) {
269
	private function nettoyerEspacesNomSyno($syno) {
269
		$syno = trim($syno);
270
		$syno = trim($syno);
270
		$syno = trim($syno, ' ');
271
		$syno = trim($syno, ' ');
271
		return $syno;
272
		return $syno;
272
	}
273
	}
273
 
274
 
274
	private function obtenirComplementNom($syno) {
275
	private function obtenirComplementNom($syno) {
275
		$complementNom = '';
276
		$complementNom = '';
276
		if (preg_match('/^(?:[^ ]+ [^ ]+ (?:(?:var|V)[.] [^ ]+|STELATUM|MINUS)|[^ ]+ [^ ]+) (.+)$/', $syno, $match)) {
277
		if (preg_match('/^(?:[^ ]+ [^ ]+ (?:(?:var|V)[.] [^ ]+|STELATUM|MINUS)|[^ ]+ [^ ]+) (.+)$/', $syno, $match)) {
277
			$complementNom = $match[1];
278
			$complementNom = $match[1];
278
		}
279
		}
279
		return $complementNom;
280
		return $complementNom;
280
	}
281
	}
281
 
282
 
282
	private function obtenirBiblio($complementNom) {
283
	private function obtenirBiblio($complementNom) {
283
		$biblioCoste = '';
284
		$biblioCoste = '';
284
		if (preg_match("/ (p[.] [0-9]{1,}|in .+||Fl[.] fr[.]|(?: Sp[.])? ed[.] [1-2])$/", $complementNom, $match)) {
285
		if (preg_match("/ (p[.] [0-9]{1,}|in .+||Fl[.] fr[.]|(?: Sp[.])? ed[.] [1-2])$/", $complementNom, $match)) {
285
			$biblioCoste = $match[1];
286
			$biblioCoste = $match[1];
286
		}
287
		}
287
		return $biblioCoste;
288
		return $biblioCoste;
288
	}
289
	}
289
 
290
 
290
	private function extraireAnnee($complementNom) {
291
	private function extraireAnnee($complementNom) {
291
		$annee = '';
292
		$annee = '';
292
		if (preg_match('/(?:^| )([0-9]+)$/', $complementNom, $match)) {
293
		if (preg_match('/(?:^| )([0-9]+)$/', $complementNom, $match)) {
293
			$annee = $match[1];
294
			$annee = $match[1];
294
		}
295
		}
295
		return $annee;
296
		return $annee;
296
	}
297
	}
297
 
298
 
298
	private function obtenirAuteur($complementNom) {
299
	private function obtenirAuteur($complementNom) {
299
		$auteurCoste = '';
300
		$auteurCoste = '';
300
		if ($complementNom != '') {
301
		if ($complementNom != '') {
301
			if (preg_match("/^((?!(?:auct.+|(?:, )?(?:non|an) .+|p[.] p[.])$).+)$/", $complementNom, $match)) {
302
			if (preg_match("/^((?!(?:auct.+|(?:, )?(?:non|an) .+|p[.] p[.])$).+)$/", $complementNom, $match)) {
302
				$auteurCoste = $this->traiterAuteur($match[1]);
303
				$auteurCoste = $this->traiterAuteur($match[1]);
303
			} else {
304
			} else {
304
				$message = "Impossible de récupérer l'auteur pour le complément de nom ($complementNom).";
305
				$message = "Impossible de récupérer l'auteur pour le complément de nom ($complementNom).";
305
				$this->ajouterLogProbleme($message);
306
				$this->ajouterLogProbleme($message);
306
			}
307
			}
307
		}
308
		}
308
		return $auteurCoste;
309
		return $auteurCoste;
309
	}
310
	}
310
 
311
 
311
	private function traiterAuteur($auteurCoste) {
312
	private function traiterAuteur($auteurCoste) {
312
		$auteur = '';
313
		$auteur = '';
313
		if ($auteurCoste != '') {
314
		if ($auteurCoste != '') {
314
			$remplacementTxt = array(' p. p.', ' saltem part.', 'Fl. fr.');
315
			$remplacementTxt = array(' p. p.', ' saltem part.', 'Fl. fr.');
315
			$auteurCoste = str_replace($remplacementTxt, '', $auteurCoste);
316
			$auteurCoste = str_replace($remplacementTxt, '', $auteurCoste);
316
			$remplacementsRegExp = array(
317
			$remplacementsRegExp = array(
317
				' [0-9]{4}',
318
				' [0-9]{4}',
318
				'[^ ]+ et auct[.], .+',
319
				'[^ ]+ et auct[.], .+',
319
				' auct.+',
320
				' auct.+',
320
				',? part[.]',
321
				',? part[.]',
321
				' p[.] [0-9]{1,}',
322
				' p[.] [0-9]{1,}',
322
				' in .+|,? (?:non|an) .+',
323
				' in .+|,? (?:non|an) .+',
323
				'(?: Sp[.])? ed[.] [1-2]');
324
				'(?: Sp[.])? ed[.] [1-2]');
324
			$auteur = preg_replace('/(?:'.implode('|', $remplacementsRegExp).')$/', '', $auteurCoste);
325
			$auteur = preg_replace('/(?:'.implode('|', $remplacementsRegExp).')$/', '', $auteurCoste);
325
		}
326
		}
326
		return $auteur;
327
		return $auteur;
327
	}
328
	}
328
 
329
 
329
	private function ajouterAuteur($auteur) {
330
	private function ajouterAuteur($auteur) {
330
		if (!isset($this->auteurs[$auteur])) {
331
		if (!isset($this->auteurs[$auteur])) {
331
			$this->auteurs[$auteur] = 1;
332
			$this->auteurs[$auteur] = 1;
332
		} else {
333
		} else {
333
			$this->auteurs[$auteur]++;
334
			$this->auteurs[$auteur]++;
334
		}
335
		}
335
	}
336
	}
336
 
337
 
337
	private function obtenirNomAddendum($syno) {
338
	private function obtenirNomAddendum($syno) {
338
		$syno = $this->nettoyerEspacesNomSyno($syno);
339
		$syno = $this->nettoyerEspacesNomSyno($syno);
339
		$nomAddendum = array();
340
		$nomAddendum = array();
340
		if (preg_match('/^((?:compr|incl)[.]) /', $syno, $match)) {
341
		if (preg_match('/^((?:compr|incl)[.]) /', $syno, $match)) {
341
			$nomAddendum[] = '['.$match[1].']';
342
			$nomAddendum[] = '['.$match[1].']';
342
		}
343
		}
343
		if (preg_match('/ ([^ ]+ et auct[.], .+)$/', $syno, $match)) {
344
		if (preg_match('/ ([^ ]+ et auct[.], .+)$/', $syno, $match)) {
344
			$nomAddendum[] = '['.$match[1].']';
345
			$nomAddendum[] = '['.$match[1].']';
345
		} elseif (preg_match('/ (auct[.],? .+)$/', $syno, $match)) {
346
		} elseif (preg_match('/ (auct[.],? .+)$/', $syno, $match)) {
346
			$nomAddendum[] = '['.$match[1].']';
347
			$nomAddendum[] = '['.$match[1].']';
347
		} else if (preg_match('/,? ((?:non|an) .+)$/', $syno, $match)) {
348
		} else if (preg_match('/,? ((?:non|an) .+)$/', $syno, $match)) {
348
			$nomAddendum[] = '['.$match[1].']';
349
			$nomAddendum[] = '['.$match[1].']';
349
		} else if (preg_match('/ (p[.] p[.])$/', $syno, $match)) {
350
		} else if (preg_match('/ (p[.] p[.])$/', $syno, $match)) {
350
			$nomAddendum[] = '['.$match[1].']';
351
			$nomAddendum[] = '['.$match[1].']';
351
		} else if (preg_match('/ (saltem part[.])$/', $syno, $match)) {
352
		} else if (preg_match('/ (saltem part[.])$/', $syno, $match)) {
352
			$nomAddendum[] = '['.$match[1].']';
353
			$nomAddendum[] = '['.$match[1].']';
353
		} else if (preg_match('/,? (part[.])$/', $syno, $match)) {
354
		} else if (preg_match('/,? (part[.])$/', $syno, $match)) {
354
			$nomAddendum[] = '['.$match[1].']';
355
			$nomAddendum[] = '['.$match[1].']';
355
		}
356
		}
356
 
357
 
357
		$nomAddendum = implode(' ; ', $nomAddendum);
358
		$nomAddendum = implode(' ; ', $nomAddendum);
358
		return $nomAddendum;
359
		return $nomAddendum;
359
	}
360
	}
360
 
361
 
361
	private function remplacerAbreviationGenre($syno, $infos, $synonymes, $num) {
362
	private function remplacerAbreviationGenre($syno, $infos, $synonymes, $num) {
362
		$nomSci = $syno;
363
		$nomSci = $syno;
363
 
364
 
364
		if (preg_match('/^(([A-Zƌ])[.]) /', $syno, $matchSyno)) {
365
		if (preg_match('/^(([A-Zƌ])[.]) /', $syno, $matchSyno)) {
365
			if ($matchSyno[2] == substr($infos['nom_coste'], 0, 1)) {
366
			if ($matchSyno[2] == substr($infos['nom_coste'], 0, 1)) {
366
				if (preg_match('/^([^ ]+) /', $infos['nom_coste'], $matchNomRetenu)) {
367
				if (preg_match('/^([^ ]+) /', $infos['nom_coste'], $matchNomRetenu)) {
367
					$nomSci = str_replace($matchSyno[1], $matchNomRetenu[1], $syno);
368
					$nomSci = str_replace($matchSyno[1], $matchNomRetenu[1], $syno);
368
				}
369
				}
369
			} else {
370
			} else {
370
				$synoPrecedent = $this->obtenirSynoAvecGenreComplet($synonymes, $num);
371
				$synoPrecedent = $this->obtenirSynoAvecGenreComplet($synonymes, $num);
371
 
372
 
372
				if ($matchSyno[2] == substr($synoPrecedent, 0, 1)) {
373
				if ($matchSyno[2] == substr($synoPrecedent, 0, 1)) {
373
					if (preg_match('/^([^ ]+) /', $synoPrecedent, $matchSynoPrec)) {
374
					if (preg_match('/^([^ ]+) /', $synoPrecedent, $matchSynoPrec)) {
374
						$nomSci = str_replace($matchSyno[1], $matchSynoPrec[1], $syno);
375
						$nomSci = str_replace($matchSyno[1], $matchSynoPrec[1], $syno);
375
					}
376
					}
376
				} else {
377
				} else {
377
					$message = "L'initiale du synonyme ($syno) ne correspondant pas au nom retenu {$infos['num_nom_coste']} ({$infos['nom_coste']}) ".
378
					$message = "L'initiale du synonyme ($syno) ne correspondant pas au nom retenu {$infos['num_nom_coste']} ({$infos['nom_coste']}) ".
378
							"ni au synonyme précédent ($synoPrecedent).";
379
							"ni au synonyme précédent ($synoPrecedent).";
379
					$this->ajouterLogProbleme($message);
380
					$this->ajouterLogProbleme($message);
380
				}
381
				}
381
			}
382
			}
382
		}
383
		}
383
		return $nomSci;
384
		return $nomSci;
384
	}
385
	}
385
 
386
 
386
	private function obtenirSynoAvecGenreComplet($synonymes, $num) {
387
	private function obtenirSynoAvecGenreComplet($synonymes, $num) {
387
		$synoPrecedent = '';
388
		$synoPrecedent = '';
388
		$synoOk = false;
389
		$synoOk = false;
389
		while ($synoOk == false) {
390
		while ($synoOk == false) {
390
			if ($num < 0) {
391
			if ($num < 0) {
391
				$synoOk = true;
392
				$synoOk = true;
392
			}
393
			}
393
			$synoPrecedent = $this->obtenirSynoPrecedent($synonymes, $num);
394
			$synoPrecedent = $this->obtenirSynoPrecedent($synonymes, $num);
394
			if (preg_match('/^[A-Zƌ][.] /', $synoPrecedent)) {
395
			if (preg_match('/^[A-Zƌ][.] /', $synoPrecedent)) {
395
				$num = $num - 1;
396
				$num = $num - 1;
396
			} else {
397
			} else {
397
				$synoOk = true;
398
				$synoOk = true;
398
			}
399
			}
399
		}
400
		}
400
		return $synoPrecedent;
401
		return $synoPrecedent;
401
	}
402
	}
402
 
403
 
403
	private function obtenirSynoPrecedent($synonymes, $num) {
404
	private function obtenirSynoPrecedent($synonymes, $num) {
404
		$synoPrecedent = '';
405
		$synoPrecedent = '';
405
		if (isset($synonymes[($num - 1 )])) {
406
		if (isset($synonymes[($num - 1 )])) {
406
			$synoPrecedent = $this->traiterNomSyno($synonymes[($num - 1 )]);
407
			$synoPrecedent = $this->traiterNomSyno($synonymes[($num - 1 )]);
407
		}
408
		}
408
		return $synoPrecedent;
409
		return $synoPrecedent;
409
	}
410
	}
410
 
411
 
411
 
412
 
412
	private function obtenirNomSci($syno, $infos, $synonymes, $num) {
413
	private function obtenirNomSci($syno, $infos, $synonymes, $num) {
413
		$nomSci = $this->remplacerAbreviationGenre($syno, $infos, $synonymes, $num);
414
		$nomSci = $this->remplacerAbreviationGenre($syno, $infos, $synonymes, $num);
414
 
415
 
415
		if (preg_match('/^([^ ]+) ([^ ]+) (?:(?:var|V)[.] ([^ ]+)|(STELATUM||MINUS) )/', $nomSci, $match)) {
416
		if (preg_match('/^([^ ]+) ([^ ]+) (?:(?:var|V)[.] ([^ ]+)|(STELATUM||MINUS) )/', $nomSci, $match)) {
416
			$genre = $this->normaliserGenre($match[1]);
417
			$genre = $this->normaliserGenre($match[1]);
417
			$sp = $this->normaliserEpithete($match[2]);
418
			$sp = $this->normaliserEpithete($match[2]);
418
			$infrasp = isset($match[4]) ? $match[4] : $match[3];
419
			$infrasp = isset($match[4]) ? $match[4] : $match[3];
419
			$infrasp = $this->normaliserEpithete($infrasp);
420
			$infrasp = $this->normaliserEpithete($infrasp);
420
			$nomSci = "$genre $sp var. $infrasp";
421
			$nomSci = "$genre $sp var. $infrasp";
421
		} else if (preg_match('/^([^ ]+) ([^ ]+)(?: |$)/', $nomSci, $match)) {
422
		} else if (preg_match('/^([^ ]+) ([^ ]+)(?: |$)/', $nomSci, $match)) {
422
			$genre = $this->normaliserGenre($match[1]);
423
			$genre = $this->normaliserGenre($match[1]);
423
			$sp = $this->normaliserEpithete($match[2]);
424
			$sp = $this->normaliserEpithete($match[2]);
424
			$nomSci = "$genre $sp";
425
			$nomSci = "$genre $sp";
425
		} else {
426
		} else {
426
			$message = "Le synonyme ($nomSci) du nom {$infos['num_nom_coste']} a une structure étrange.";
427
			$message = "Le synonyme ($nomSci) du nom {$infos['num_nom_coste']} a une structure étrange.";
427
			$this->ajouterLogProbleme($message);
428
			$this->ajouterLogProbleme($message);
428
		}
429
		}
429
		return $nomSci;
430
		return $nomSci;
430
	}
431
	}
431
 
432
 
432
	private function normaliserGenre($genre) {
433
	private function normaliserGenre($genre) {
433
		$genre = mb_convert_case(mb_strtolower($genre), MB_CASE_TITLE);
434
		$genre = mb_convert_case(mb_strtolower($genre), MB_CASE_TITLE);
434
		$genre = str_replace('Æ', 'æ', $genre);
435
		$genre = str_replace('Æ', 'æ', $genre);
435
		return $genre;
436
		return $genre;
436
	}
437
	}
437
 
438
 
438
	private function normaliserEpithete($sp) {
439
	private function normaliserEpithete($sp) {
439
		$sp = mb_strtolower($sp);
440
		$sp = mb_strtolower($sp);
440
		$sp = str_replace('Æ', 'æ', $sp);
441
		$sp = str_replace('Æ', 'æ', $sp);
441
		return $sp;
442
		return $sp;
442
	}
443
	}
443
 
444
 
444
	private function obtenirRangNom($syno) {
445
	private function obtenirRangNom($syno) {
445
		$rang = 290;
446
		$rang = 290;
446
		if (strpos($syno, ' var. ')) {
447
		if (strpos($syno, ' var. ')) {
447
			$rang = 340;
448
			$rang = 340;
448
		}
449
		}
449
		return $rang;
450
		return $rang;
450
	}
451
	}
451
 
452
 
452
	private function creerFichierCsvCorrespondance() {
453
	private function creerFichierCsvCorrespondance() {
453
		$lignes[] = implode("\t", array_keys($this->infosCorrespondanceBase));
454
		$lignes[] = implode("\t", array_keys($this->infosCorrespondanceBase));
454
		foreach ($this->correspondance as $infos) {
455
		foreach ($this->correspondance as $infos) {
455
			$lignes[] = implode("\t", $infos);
456
			$lignes[] = implode("\t", $infos);
456
		}
457
		}
457
 
458
 
458
		$txt = '';
459
		$txt = '';
459
		$txt = implode("\n", $lignes);
460
		$txt = implode("\n", $lignes);
460
		return $txt;
461
		return $txt;
461
	}
462
	}
462
 
463
 
463
	private function genererFichier() {
464
	private function genererFichier() {
464
		$donnees = $this->analyserFichier();
465
		$donnees = $this->analyserFichier();
465
 
466
 
466
		$txt = $this->nettoyerDescription($donnees['texte']);
467
		$txt = $this->nettoyerDescription($donnees['texte']);
467
		$txt = $this->corrigerDescription($txt);
468
		$txt = $this->corrigerDescription($txt);
468
		$txt = $this->remplacerHtmlParSyntaxeWiki($txt);
469
		$txt = $this->remplacerHtmlParSyntaxeWiki($txt);
469
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.txt';
470
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.txt';
470
		file_put_contents($fichierTxt, $txt);
471
		file_put_contents($fichierTxt, $txt);
471
 
472
 
472
		unset($donnees['texte']);
473
		unset($donnees['texte']);
473
		$txt = implode("\n", $donnees);
474
		$txt = implode("\n", $donnees);
474
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.json';
475
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.json';
475
		file_put_contents($fichierTxt, $txt);
476
		file_put_contents($fichierTxt, $txt);
476
	}
477
	}
477
 
478
 
478
	private function analyserFichier() {
479
	private function analyserFichier() {
479
		$donnees = array('titre' => '', 'texte' => '', 'correspondance' => '');
480
		$donnees = array('titre' => '', 'texte' => '', 'correspondance' => '');
480
		if ($fichierOuvert = fopen($this->fichier, 'r')) {
481
		if ($fichierOuvert = fopen($this->fichier, 'r')) {
481
			$i = 1;
482
			$i = 1;
482
			while ($ligne = fgets($fichierOuvert)) {
483
			while ($ligne = fgets($fichierOuvert)) {
483
				if ($i == 24) {
484
				if ($i == 24) {
484
					$donnees['titre'] = $this->supprimerHtml($ligne);
485
					$donnees['titre'] = $this->supprimerHtml($ligne);
485
				} elseif ($i >= 45 && $i <= 60) {
486
				} elseif ($i >= 45 && $i <= 60) {
486
					$donnees['texte'] .= $this->traiterLigneDescription($ligne);
487
					$donnees['texte'] .= $this->traiterLigneDescription($ligne);
487
				} elseif ($i >= 61 && preg_match('/Bdnff /ui', $ligne)) {
488
				} elseif ($i >= 61 && preg_match('/Bdnff /ui', $ligne)) {
488
					$donnees['correspondance'] = $this->supprimerHtml($ligne);
489
					$donnees['correspondance'] = $this->supprimerHtml($ligne);
489
				}
490
				}
490
				$i++;
491
				$i++;
491
			}
492
			}
492
			fclose($fichierOuvert);
493
			fclose($fichierOuvert);
493
		} else {
494
		} else {
494
			$this->messages->traiterErreur("Le fichier {$this->fichier} n'a pas pu être ouvert.");
495
			$this->messages->traiterErreur("Le fichier {$this->fichier} n'a pas pu être ouvert.");
495
		}
496
		}
496
		return $donnees;
497
		return $donnees;
497
	}
498
	}
498
 
499
 
499
	private function supprimerHtml($txt) {
500
	private function supprimerHtml($txt) {
500
		$txt = strip_tags($txt,'<b>,<i>');
501
		$txt = strip_tags($txt,'<b>,<i>');
501
		$txt = str_replace('&#173;', '', $txt);
502
		$txt = str_replace('&#173;', '', $txt);
502
		$txt = str_ireplace('&nbsp;', ' ', $txt);
503
		$txt = str_ireplace('&nbsp;', ' ', $txt);
503
		$txt = trim($txt);
504
		$txt = trim($txt);
504
		$txt = preg_replace('/^<\/I>/', '', $txt);
505
		$txt = preg_replace('/^<\/I>/', '', $txt);
505
		$txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
506
		$txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
506
		return $txt;
507
		return $txt;
507
	}
508
	}
508
 
509
 
509
	private function traiterLigneDescription($txt) {
510
	private function traiterLigneDescription($txt) {
510
		$txt = $this->supprimerHtml($txt);
511
		$txt = $this->supprimerHtml($txt);
511
		$txt = $txt."\n";
512
		$txt = $txt."\n";
512
		return $txt;
513
		return $txt;
513
	}
514
	}
514
 
515
 
515
	private function nettoyerDescription($txt) {
516
	private function nettoyerDescription($txt) {
516
		$txt = preg_replace("/\n{2,}+/", "\n", $txt);
517
		$txt = preg_replace("/\n{2,}+/", "\n", $txt);
517
		$txt = trim($txt);
518
		$txt = trim($txt);
518
		return $txt;
519
		return $txt;
519
	}
520
	}
520
 
521
 
521
	private function corrigerDescription($txt) {
522
	private function corrigerDescription($txt) {
522
		$txt = preg_replace("/– <I>([^.]+?)[.] – <\/I>/", "– <I>$1</I>. – ", $txt);
523
		$txt = preg_replace("/– <I>([^.]+?)[.] – <\/I>/", "– <I>$1</I>. – ", $txt);
523
		$txt = preg_replace("/– <I>([^.]+?)[.] – ([A-Z])<\/I>/", "– <I>$1</I>. – $2", $txt);
524
		$txt = preg_replace("/– <I>([^.]+?)[.] – ([A-Z])<\/I>/", "– <I>$1</I>. – $2", $txt);
524
		$txt = preg_replace("/– <I>([^.]+?) – <\/I>/", "– <I>$1</I>. – ", $txt);
525
		$txt = preg_replace("/– <I>([^.]+?) – <\/I>/", "– <I>$1</I>. – ", $txt);
525
		return $txt;
526
		return $txt;
526
	}
527
	}
527
 
528
 
528
	private function remplacerHtmlParSyntaxeWiki($txt) {
529
	private function remplacerHtmlParSyntaxeWiki($txt) {
529
		$txt = str_replace(array('<B>', '</B>'), '**', $txt);
530
		$txt = str_replace(array('<B>', '</B>'), '**', $txt);
530
		$txt = str_replace(array('<I>', '</I>'), '//', $txt);
531
		$txt = str_replace(array('<I>', '</I>'), '//', $txt);
531
		return $txt;
532
		return $txt;
532
	}
533
	}
533
 
534
 
534
	private function ajouterLogAnalyse($txt) {
535
	private function ajouterLogAnalyse($txt) {
535
		if (isset($this->log['analyse']) == false) {
536
		if (isset($this->log['analyse']) == false) {
536
			$this->log['analyse'] = '';
537
			$this->log['analyse'] = '';
537
		}
538
		}
538
		$this->log['analyse'] .= "$txt\n";
539
		$this->log['analyse'] .= "$txt\n";
539
	}
540
	}
540
 
541
 
541
	private function ajouterLogSyno($txt) {
542
	private function ajouterLogSyno($txt) {
542
		if (isset($this->log['synonymes']) == false) {
543
		if (isset($this->log['synonymes']) == false) {
543
			$this->log['synonymes'] = '';
544
			$this->log['synonymes'] = '';
544
		}
545
		}
545
		$this->log['synonymes'] .= "$txt\n";
546
		$this->log['synonymes'] .= "$txt\n";
546
	}
547
	}
547
 
548
 
548
	private function ajouterLogAuteur($txt) {
549
	private function ajouterLogAuteur($txt) {
549
		if (isset($this->log['auteurs']) == false) {
550
		if (isset($this->log['auteurs']) == false) {
550
			$this->log['auteurs'] = '';
551
			$this->log['auteurs'] = '';
551
		}
552
		}
552
		$this->log['auteurs'] .= "$txt\n";
553
		$this->log['auteurs'] .= "$txt\n";
553
	}
554
	}
554
 
555
 
555
	private function ajouterLogProbleme($txt) {
556
	private function ajouterLogProbleme($txt) {
556
		if (isset($this->log['problemes']) == false) {
557
		if (isset($this->log['problemes']) == false) {
557
			$this->log['problemes'] = '';
558
			$this->log['problemes'] = '';
558
		}
559
		}
559
		$this->log['problemes'] .= "$txt\n";
560
		$this->log['problemes'] .= "$txt\n";
560
	}
561
	}
561
 
562
 
562
	private function ecrireLogs() {
563
	private function ecrireLogs() {
563
		foreach ($this->log as $nom => $log) {
564
		foreach ($this->log as $nom => $log) {
564
			$fichier = $this->dossierBase.self::DOSSIER_LOG.$nom.'.log';
565
			$fichier = $this->dossierBase.self::DOSSIER_LOG.$nom.'.log';
565
			file_put_contents($fichier, $log);
566
			file_put_contents($fichier, $log);
566
		}
567
		}
567
	}
568
	}
568
}
569
}
569
?>
570
?>