Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 428 Rev 430
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 $dossierBase = '';
10
	private $dossierBase = '';
11
	private $conteneur = null;
11
	private $conteneur = null;
12
	private $outils = null;
12
	private $outils = null;
13
	private $messages = null;
13
	private $messages = null;
14
	private $action = '';
14
	private $action = '';
15
	private $nomFichier = '';
15
	private $nomFichier = '';
16
	private $nomDossier = '';
16
	private $nomDossier = '';
17
	private $listeFichiers = array();
17
	private $listeFichiers = array();
18
	private $fichierNum = '';
18
	private $fichierNum = '';
19
	private $fichier = '';
19
	private $fichier = '';
20
	private $log = '';
20
	private $log = '';
21
	private $correspondance = array();
21
	private $correspondance = array();
22
	private $infosCorrespondanceBase = array(
22
	private $infosCorrespondanceBase = array(
23
		'nom_sci' => '',
23
		'nom_sci' => '',
24
		'rang' => 290,
24
		'rang' => 290,
25
		'auteur' => '',
25
		'auteur' => '',
-
 
26
		'annee' => '',
-
 
27
		'biblio_coste' => '',
26
		'nom_francais' => '',
28
		'nom_francais' => '',
27
		'nom_coste' => '',
29
		'nom_coste' => '',
-
 
30
		'auteur_coste' => '',
28
		'num_nom_coste' => '',
31
		'num_nom_coste' => '',
-
 
32
		'num_nom_retenu_coste' => '',
29
		'num_tax_sup_coste' => '',
33
		'num_tax_sup_coste' => '',
30
		'tome' => '',
34
		'tome' => '',
31
		'page' => '',
35
		'page' => '',
-
 
36
		'synonymie_coste' => '',
32
		'bdnff_nn' => '',
37
		'bdnff_nn' => '',
33
		'bdnff_nt' => '');
38
		'bdnff_nt' => '');
34
 
39
 
35
	public function __construct(Conteneur $conteneur) {
40
	public function __construct(Conteneur $conteneur) {
36
		$this->conteneur = $conteneur;
41
		$this->conteneur = $conteneur;
37
		$this->outils = $conteneur->getOutils();
42
		$this->outils = $conteneur->getOutils();
38
		$this->messages = $conteneur->getMessages();
43
		$this->messages = $conteneur->getMessages();
39
		$this->dossierBase = dirname(__FILE__).'/';
44
		$this->dossierBase = dirname(__FILE__).'/';
40
	}
45
	}
41
 
46
 
42
	public function genererDescriptionTxt() {
47
	public function genererDescriptionTxt() {
43
		$this->chargerFichiers();
48
		$this->chargerFichiers();
44
 
49
 
45
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
50
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
46
			$this->messages->afficherAvancement("Création des descriptions au format txt");
51
			$this->messages->afficherAvancement("Création des descriptions au format txt");
47
			$this->genererFichier();
52
			$this->genererFichier();
48
		}
53
		}
49
		echo "\n";
54
		echo "\n";
50
	}
55
	}
51
 
56
 
52
	public function verifierDescriptionTxt() {
57
	public function verifierDescriptionTxt() {
53
		$this->chargerFichiers();
58
		$this->chargerFichiers();
54
 
59
 
55
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
60
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
56
			$this->messages->afficherAvancement("Analyse des descriptions");
61
			$this->messages->afficherAvancement("Analyse des descriptions");
57
			$this->verifierFichier();
62
			$this->verifierFichier();
58
		}
63
		}
59
		echo "\n";
64
		echo "\n";
60
 
65
 
61
		$fichierTxt = $this->dossierBase.self::DOSSIER_LOG.'analyse.log';
66
		$fichierTxt = $this->dossierBase.self::DOSSIER_LOG.'analyse.log';
62
		file_put_contents($fichierTxt, $this->log);
67
		file_put_contents($fichierTxt, $this->log);
63
	}
68
	}
64
 
69
 
65
	public function genererCorrespondance() {
70
	public function genererCorrespondance() {
66
		$this->chargerFichiers();
71
		$this->chargerFichiers();
67
 
72
 
68
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
73
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
69
			$this->messages->afficherAvancement("Création du fichier de correspondance");
74
			$this->messages->afficherAvancement("Création du fichier de correspondance");
70
			$this->extraireInfosCorrespondance();
75
			$this->extraireInfosCorrespondance();
71
		}
76
		}
72
		echo "\n";
77
		echo "\n";
73
 
78
 
74
		$fichierTxt = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv';
79
		$fichierTxt = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv';
75
		$txtCorrespondance = $this->creerFichierCsvCorrespondance();
80
		$txtCorrespondance = $this->creerFichierCsvCorrespondance();
76
		file_put_contents($fichierTxt, $txtCorrespondance);
81
		file_put_contents($fichierTxt, $txtCorrespondance);
-
 
82
 
-
 
83
		$fichierLog = $this->dossierBase.self::DOSSIER_LOG.'synonymes.log';
-
 
84
		file_put_contents($fichierLog, $this->log);
77
	}
85
	}
78
 
86
 
79
	private function chargerFichiers() {
87
	private function chargerFichiers() {
80
		$this->nomDossier = $this->dossierBase.self::DOSSIER_DSC_HTML;
88
		$this->nomDossier = $this->dossierBase.self::DOSSIER_DSC_HTML;
81
		if (file_exists($this->nomDossier) === true) {
89
		if (file_exists($this->nomDossier) === true) {
82
			if (is_dir($this->nomDossier)) {
90
			if (is_dir($this->nomDossier)) {
83
				if ($dossierOuvert = opendir($this->nomDossier)) {
91
				if ($dossierOuvert = opendir($this->nomDossier)) {
84
					while (($this->nomFichier = readdir($dossierOuvert)) !== false) {
92
					while (($this->nomFichier = readdir($dossierOuvert)) !== false) {
85
						if (! is_dir($this->nomFichier) && preg_match('/e([0-9]{4})\.htm/', $this->nomFichier, $match)) {
93
						if (! is_dir($this->nomFichier) && preg_match('/e([0-9]{4})\.htm/', $this->nomFichier, $match)) {
86
							$this->listeFichiers[$match[1]] = $this->nomDossier.'/'.$this->nomFichier;
94
							$this->listeFichiers[$match[1]] = $this->nomDossier.'/'.$this->nomFichier;
87
						}
95
						}
88
					}
96
					}
89
					closedir($dossierOuvert);
97
					closedir($dossierOuvert);
90
				} else {
98
				} else {
91
					$this->messages->traiterErreur("Le dossier {$this->nomDossier} n'a pas pu être ouvert.");
99
					$this->messages->traiterErreur("Le dossier {$this->nomDossier} n'a pas pu être ouvert.");
92
				}
100
				}
93
			} else {
101
			} else {
94
				$this->messages->traiterErreur("{$this->nomDossier} n'est pas un dossier.");
102
				$this->messages->traiterErreur("{$this->nomDossier} n'est pas un dossier.");
95
			}
103
			}
96
		} else {
104
		} else {
97
			$this->messages->traiterErreur("Le dossier {$this->nomDossier} est introuvable.");
105
			$this->messages->traiterErreur("Le dossier {$this->nomDossier} est introuvable.");
98
		}
106
		}
99
 
107
 
100
		asort($this->listeFichiers);
108
		arsort($this->listeFichiers);
101
	}
109
	}
102
 
110
 
103
	private function verifierFichier() {
111
	private function verifierFichier() {
104
		$donnees = $this->analyserFichier();
112
		$donnees = $this->analyserFichier();
105
		$txt = $donnees['texte'];
113
		$txt = $donnees['texte'];
106
		$this->verifierOuvertureFermetureBalise($txt);
114
		$this->verifierOuvertureFermetureBalise($txt);
107
		$this->verifierAbscenceEgale($txt);
115
		$this->verifierAbscenceEgale($txt);
108
		$this->verifierNumero($txt);
116
		$this->verifierNumero($txt);
-
 
117
		// TODO : vérifier les noms vernauclaire qui sont abrégés
109
	}
118
	}
110
 
119
 
111
	private function verifierOuvertureFermetureBalise($txt) {
120
	private function verifierOuvertureFermetureBalise($txt) {
112
		$b_ouvert = substr_count($txt, '<B>');
121
		$b_ouvert = substr_count($txt, '<B>');
113
		$b_ferme = substr_count($txt, '</B>');
122
		$b_ferme = substr_count($txt, '</B>');
114
		if ($b_ouvert != $b_ferme) {
123
		if ($b_ouvert != $b_ferme) {
115
			$this->log .= "{$this->fichierNum} contient $b_ouvert balises B ouvertes et $b_ferme fermées\n";
124
			$this->log .= "{$this->fichierNum} contient $b_ouvert balises B ouvertes et $b_ferme fermées\n";
116
		}
125
		}
117
		$i_ouvert = substr_count($txt, '<I>');
126
		$i_ouvert = substr_count($txt, '<I>');
118
		$i_ferme = substr_count($txt, '</I>');
127
		$i_ferme = substr_count($txt, '</I>');
119
		if ($i_ouvert != $i_ferme) {
128
		if ($i_ouvert != $i_ferme) {
120
			$this->log .= "{$this->fichierNum} contient $i_ouvert balises I ouvertes et $i_ferme fermées\n";
129
			$this->log .= "{$this->fichierNum} contient $i_ouvert balises I ouvertes et $i_ferme fermées\n";
121
		}
130
		}
122
	}
131
	}
123
 
132
 
124
	private function verifierAbscenceEgale($txt) {
133
	private function verifierAbscenceEgale($txt) {
125
		if (strripos($txt, '=') === false) {
134
		if (strripos($txt, '=') === false) {
126
			$this->log .= "{$this->fichierNum} ne contient pas le séparateur de phénologie (=)\n";
135
			$this->log .= "{$this->fichierNum} ne contient pas le séparateur de phénologie (=)\n";
127
		}
136
		}
128
	}
137
	}
129
 
138
 
130
	private function verifierNumero($txt) {
139
	private function verifierNumero($txt) {
131
		if (preg_match('/^<B>[0-9]{1,4}. – /', $txt) == 0) {
140
		if (preg_match('/^<B>[0-9]{1,4}. – /', $txt) == 0) {
132
			$this->log .= "{$this->fichierNum} ne contient pas un numéro bien formaté\n";
141
			$this->log .= "{$this->fichierNum} ne contient pas un numéro bien formaté\n";
133
		}
142
		}
134
	}
143
	}
135
 
144
 
136
	private function extraireInfosCorrespondance() {
145
	private function extraireInfosCorrespondance() {
137
		$donnees = $this->analyserFichier();
146
		$donnees = $this->analyserFichier();
138
		$infos = $this->infosCorrespondanceBase;
147
		$infos = $this->infosCorrespondanceBase;
139
 
148
 
140
		$titre = $donnees['titre'];
149
		$titre = $donnees['titre'];
141
		if (preg_match('/^Coste ([0-9]+) - ([^ ]+ [^ ]+) - F[0-9]+, [^ ]+ - (G[0-9]+), T([123])[.]p([0-9]+)$/', $titre, $match)) {
150
		if (preg_match('/^Coste ([0-9]+) - ((?:(?! - ).)+) - F[0-9]+, (?:(?! - ).)+ - (G[0-9]+), T([123])[.]p([0-9]+)$/', $titre, $match)) {
142
			$infos['num_nom_coste'] = $match[1];
151
			$infos['num_nom_coste'] = $match[1];
143
			$infos['nom_sci'] = $match[2];
152
			$infos['nom_sci'] = $match[2];
144
			$infos['num_tax_sup_coste'] = $match[3];
153
			$infos['num_tax_sup_coste'] = $match[3];
145
			$infos['tome'] = $match[4];
154
			$infos['tome'] = $match[4];
146
			$infos['page'] = $match[5];
155
			$infos['page'] = $match[5];
147
		} else {
156
		} else {
148
			$this->messages->traiterErreur("Le titre du fichier {$this->fichierNum} est mal formaté.");
157
			$this->messages->traiterErreur("Le titre du fichier {$this->fichierNum} est mal formaté.");
149
		}
158
		}
150
 
159
 
151
		$corres = $donnees['correspondance'];
160
		$corres = $donnees['correspondance'];
152
		if (preg_match('/^Bdnff ([0-9]+) -[^-]+-[^-]+- Tax=([0-9]+)$/', $corres, $match)) {
161
		if (preg_match('/^Bdnff ([0-9]+) - (?:(?! - ).)+ - (?:(?! - ).)+ - Tax=([0-9]+)$/', $corres, $match)) {
153
			$infos['bdnff_nn'] = $match[1];
162
			$infos['bdnff_nn'] = $match[1];
154
			$infos['bdnff_nt'] = $match[2];
163
			$infos['bdnff_nt'] = $match[2];
155
 
-
 
156
		} else {
164
		} else {
157
			$this->messages->traiterErreur("La correspondance du fichier {$this->fichierNum} est mal formatée.");
165
			$this->messages->traiterErreur("La correspondance du fichier {$this->fichierNum} est mal formatée.");
158
		}
166
		}
159
 
167
 
160
		$txt = $donnees['texte'];
168
		$txt = $donnees['texte'];
161
		$txt = $this->corrigerDescription($txt);
169
		$txt = $this->corrigerDescription($txt);
162
		if (preg_match('/^<B>[0-9]{1,4}[.] – ([^<]+)<\/B> ([^–]+)– (?:<I>([^<]+)<\/I>|[A-Z])/u', $txt, $match)) {
170
		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)) {
163
			$infos['nom_coste'] = $match[1];
171
			$infos['nom_coste'] = trim($match[1]);
164
			$infos['auteur'] = $match[2];
172
			$infos['auteur_coste'] = trim($match[2]);
165
			$infos['nom_francais'] = isset($match[3]) ? $match[3] : '';
173
			$infos['nom_francais'] = isset($match[3]) ? $match[3] : '';
-
 
174
			$infos['nom_francais'] = isset($match[4]) && isset($match[5]) ? $match[4].$match[5] : $infos['nom_francais'];
-
 
175
			if (strpos($infos['auteur_coste'], '(' ) !== false) {
-
 
176
				if (preg_match('/^([^(]*)\(([^)]+)\)(?:[.]?| ; ((?:(?! – ).)+))$/', $infos['auteur_coste'], $match)) {
-
 
177
					$infos['auteur_coste'] = trim($match[1]);
-
 
178
					$infos['auteur'] = $this->traiterAuteur($infos['auteur_coste']);
-
 
179
					$parentheseContenu = trim($match[2]);
-
 
180
					if (preg_match('/^[0-9]+$/', $parentheseContenu)) {
-
 
181
						$infos['annee'] = $parentheseContenu;
-
 
182
					} else {
-
 
183
						$infos['synonymie_coste'] = $parentheseContenu;
-
 
184
						$infos['biblio_coste'] = isset($match[3]) ? trim($match[3]) : '';
-
 
185
					}
-
 
186
				} else {
-
 
187
					$this->messages->traiterErreur("L'auteur du nom sciencitifique du fichier {$this->fichierNum} est mal formaté.");
-
 
188
				}
-
 
189
			}
166
		} else {
190
		} else {
167
			$this->messages->traiterErreur("La texte du fichier {$this->fichierNum} est mal formaté.");
191
			$this->messages->traiterErreur("La texte du fichier {$this->fichierNum} est mal formaté.");
168
		}
192
		}
169
 
193
 
170
		$this->correspondance[] = $infos;
194
		$this->correspondance[] = $infos;
-
 
195
 
-
 
196
		if ($infos['synonymie_coste'] != '') {
-
 
197
			$this->traiterSynonymie($infos);
-
 
198
		}
-
 
199
	}
-
 
200
 
-
 
201
	private function traiterAuteur($auteurCoste) {
-
 
202
		$auteur = '';
-
 
203
		if ($auteurCoste != '') {
-
 
204
			$auteur = str_replace('et', '&', $auteurCoste);
-
 
205
		}
-
 
206
		return $auteur;
-
 
207
	}
-
 
208
 
-
 
209
	private function traiterSynonymie($infos) {
-
 
210
		$synoCoste = $infos['synonymie_coste'];
-
 
211
		$synoCoste = preg_replace('/^et /', '', $synoCoste);
-
 
212
		$synoCoste = preg_replace('/ et ([A-Z]{2,}|[A-Z][.] [A-Z]{2,})/', ' ; $1', $synoCoste);
-
 
213
		$synoCoste = preg_replace('/, ((?:(?!non |part[.]|an |G[.] G[.])[^,]+))/', ' ;$1', $synoCoste);
-
 
214
 
-
 
215
		$synonymes = explode(';', $synoCoste);
-
 
216
 
-
 
217
		foreach ($synonymes as $syno) {
-
 
218
			$syno = trim($syno);
-
 
219
			$syno = trim($syno, ' ');
-
 
220
			$infosSyno = $this->infosCorrespondanceBase;
-
 
221
			$this->log .= $infos['num_nom_coste']."\t$syno\n";
-
 
222
			$this->correspondance[] = $infosSyno;
-
 
223
		}
171
	}
224
	}
172
 
225
 
173
	private function creerFichierCsvCorrespondance() {
226
	private function creerFichierCsvCorrespondance() {
174
		$lignes[] = implode("\t", array_keys($this->infosCorrespondanceBase));
227
		$lignes[] = implode("\t", array_keys($this->infosCorrespondanceBase));
175
		foreach ($this->correspondance as $infos) {
228
		foreach ($this->correspondance as $infos) {
176
			$lignes[] = implode("\t", $infos);
229
			$lignes[] = implode("\t", $infos);
177
		}
230
		}
178
 
231
 
179
		$txt = '';
232
		$txt = '';
180
		$txt = implode("\n", $lignes);
233
		$txt = implode("\n", $lignes);
181
		return $txt;
234
		return $txt;
182
	}
235
	}
183
 
236
 
184
	private function genererFichier() {
237
	private function genererFichier() {
185
		$donnees = $this->analyserFichier();
238
		$donnees = $this->analyserFichier();
186
 
239
 
187
		$txt = $this->nettoyerDescription($donnees['texte']);
240
		$txt = $this->nettoyerDescription($donnees['texte']);
188
		$txt = $this->corrigerDescription($txt);
241
		$txt = $this->corrigerDescription($txt);
189
		$txt = $this->remplacerHtmlParSyntaxeWiki($txt);
242
		$txt = $this->remplacerHtmlParSyntaxeWiki($txt);
190
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.txt';
243
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.txt';
191
		file_put_contents($fichierTxt, $txt);
244
		file_put_contents($fichierTxt, $txt);
192
 
245
 
193
		unset($donnees['texte']);
246
		unset($donnees['texte']);
194
		$txt = implode("\n", $donnees);
247
		$txt = implode("\n", $donnees);
195
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.json';
248
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.json';
196
		file_put_contents($fichierTxt, $txt);
249
		file_put_contents($fichierTxt, $txt);
197
	}
250
	}
198
 
251
 
199
	private function analyserFichier() {
252
	private function analyserFichier() {
200
		$donnees = array('titre' => '', 'texte' => '', 'correspondance' => '');
253
		$donnees = array('titre' => '', 'texte' => '', 'correspondance' => '');
201
		if ($fichierOuvert = fopen($this->fichier, 'r')) {
254
		if ($fichierOuvert = fopen($this->fichier, 'r')) {
202
			$i = 1;
255
			$i = 1;
203
			while ($ligne = fgets($fichierOuvert)) {
256
			while ($ligne = fgets($fichierOuvert)) {
204
				if ($i == 24) {
257
				if ($i == 24) {
205
					$donnees['titre'] = $this->supprimerHtml($ligne);
258
					$donnees['titre'] = $this->supprimerHtml($ligne);
206
				} elseif ($i >= 45 && $i <= 62) {
259
				} elseif ($i >= 45 && $i <= 60) {
207
					$donnees['texte'] .= $this->traiterLigneDescription($ligne);
260
					$donnees['texte'] .= $this->traiterLigneDescription($ligne);
208
				} elseif (($i == 63 || $i == 67) && preg_match('/Bdnff /ui', $ligne)) {
261
				} elseif ($i >= 61 && preg_match('/Bdnff /ui', $ligne)) {
209
					$donnees['correspondance'] = $this->supprimerHtml($ligne);
262
					$donnees['correspondance'] = $this->supprimerHtml($ligne);
210
				}
263
				}
211
				$i++;
264
				$i++;
212
			}
265
			}
213
			if ($i > 94) {
-
 
214
				$this->messages->traiterErreur("Le fichier {$this->fichier} contient plus de 94 lignes ($i).");
-
 
215
			}
-
 
216
			fclose($fichierOuvert);
266
			fclose($fichierOuvert);
217
		} else {
267
		} else {
218
			$this->messages->traiterErreur("Le fichier {$this->fichier} n'a pas pu être ouvert.");
268
			$this->messages->traiterErreur("Le fichier {$this->fichier} n'a pas pu être ouvert.");
219
		}
269
		}
220
		return $donnees;
270
		return $donnees;
221
	}
271
	}
222
 
272
 
223
	private function supprimerHtml($txt) {
273
	private function supprimerHtml($txt) {
224
		$txt = strip_tags($txt,'<b>,<i>');
274
		$txt = strip_tags($txt,'<b>,<i>');
225
		$txt = str_replace('&#173;', '', $txt);
275
		$txt = str_replace('&#173;', '', $txt);
226
		$txt = str_ireplace('&nbsp;', ' ', $txt);
276
		$txt = str_ireplace('&nbsp;', ' ', $txt);
227
		$txt = trim($txt);
277
		$txt = trim($txt);
228
		$txt = preg_replace('/^<\/I>/', '', $txt);
278
		$txt = preg_replace('/^<\/I>/', '', $txt);
229
		$txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
279
		$txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
230
		return $txt;
280
		return $txt;
231
	}
281
	}
232
 
282
 
233
	private function traiterLigneDescription($txt) {
283
	private function traiterLigneDescription($txt) {
234
		$txt = $this->supprimerHtml($txt);
284
		$txt = $this->supprimerHtml($txt);
235
		$txt = $txt."\n";
285
		$txt = $txt."\n";
236
		return $txt;
286
		return $txt;
237
	}
287
	}
238
 
288
 
239
	private function nettoyerDescription($txt) {
289
	private function nettoyerDescription($txt) {
240
		$txt = preg_replace("/\n{2,}+/", "\n", $txt);
290
		$txt = preg_replace("/\n{2,}+/", "\n", $txt);
241
		$txt = trim($txt);
291
		$txt = trim($txt);
242
		return $txt;
292
		return $txt;
243
	}
293
	}
244
 
294
 
245
	private function corrigerDescription($txt) {
295
	private function corrigerDescription($txt) {
246
		$txt = preg_replace("/– <I>([^.]+?)[.] – <\/I>/", "– <I>$1</I>. – ", $txt);
296
		$txt = preg_replace("/– <I>([^.]+?)[.] – <\/I>/", "– <I>$1</I>. – ", $txt);
247
		$txt = preg_replace("/– <I>([^.]+?)[.] – ([A-Z])<\/I>/", "– <I>$1</I>. – $2", $txt);
297
		$txt = preg_replace("/– <I>([^.]+?)[.] – ([A-Z])<\/I>/", "– <I>$1</I>. – $2", $txt);
248
		$txt = preg_replace("/– <I>([^.]+?) – <\/I>/", "– <I>$1</I>. – ", $txt);
298
		$txt = preg_replace("/– <I>([^.]+?) – <\/I>/", "– <I>$1</I>. – ", $txt);
249
		return $txt;
299
		return $txt;
250
	}
300
	}
251
 
301
 
252
	private function remplacerHtmlParSyntaxeWiki($txt) {
302
	private function remplacerHtmlParSyntaxeWiki($txt) {
253
		$txt = str_replace(array('<B>', '</B>'), '**', $txt);
303
		$txt = str_replace(array('<B>', '</B>'), '**', $txt);
254
		$txt = str_replace(array('<I>', '</I>'), '//', $txt);
304
		$txt = str_replace(array('<I>', '</I>'), '//', $txt);
255
		return $txt;
305
		return $txt;
256
	}
306
	}
257
}
307
}
258
?>
308
?>