Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 469 | Rev 476 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 469 Rev 471
Line 11... Line 11...
11
	private $dossierBase = '';
11
	private $dossierBase = '';
12
	private $spIndex = array();
12
	private $spIndex = array();
13
	private $supraSpIndex = array();
13
	private $supraSpIndex = array();
14
	private $indexFinal = array();
14
	private $indexFinal = array();
15
	private $tableauParDefaut = array();
15
	private $tableauParDefaut = array();
-
 
16
	private $nbreTaxonInf = array();
16
	private $enteteFinal = array(
17
	private $enteteFinal = array(
17
		'num_nom',
18
		'num_nom',
18
		'num_nom_retenu',
19
		'num_nom_retenu',
19
		'num_tax_sup',
20
		'num_tax_sup',
20
		'rang',
21
		'rang',
Line 31... Line 32...
31
		'num_nom_retenu_coste',
32
		'num_nom_retenu_coste',
32
		'num_tax_sup_coste',
33
		'num_tax_sup_coste',
33
		'synonymie_coste',
34
		'synonymie_coste',
34
		'tome',
35
		'tome',
35
		'page',
36
		'page',
-
 
37
		'nbre_taxons',
36
		'bdnff_nn',
38
		'bdnff_nn',
37
		'bdnff_nt');
39
		'bdnff_nt',
-
 
40
		'image',
-
 
41
		'page_wiki_dsc',
-
 
42
		'page_wiki_cle');
Line 38... Line 43...
38
 
43
 
39
	public function __construct(Conteneur $conteneur) {
44
	public function __construct(Conteneur $conteneur) {
40
		mb_internal_encoding('UTF-8');
45
		mb_internal_encoding('UTF-8');
41
		setlocale(LC_ALL, 'fr_FR.UTF-8');
46
		setlocale(LC_ALL, 'fr_FR.UTF-8');
Line 124... Line 129...
124
		}
129
		}
125
	}
130
	}
Line 126... Line 131...
126
 
131
 
127
	private function ajouterDansIndexFinal($infos) {
132
	private function ajouterDansIndexFinal($infos) {
128
		$infos = array_merge($this->tableauParDefaut, $infos);
133
		$infos = array_merge($this->tableauParDefaut, $infos);
129
		$infos['num_nom'] = count($this->indexFinal);
134
		$infos['num_nom'] = (count($this->indexFinal) + 1);
130
		$this->indexFinal[$infos['num_nom_coste']] = $infos;
135
		$this->indexFinal[$infos['num_nom_coste']] = $infos;
Line 131... Line 136...
131
	}
136
	}
-
 
137
 
132
 
138
	private function ajouterChampsDansIndexFinal() {
133
	private function ajouterChampsDansIndexFinal() {
139
		$this->genererNbreTaxons();
134
		foreach ($this->indexFinal as $nnc => $infos) {
140
		foreach ($this->indexFinal as $nnc => $infos) {
135
			if ($infos['num_nom_coste'] == $infos['num_nom_retenu_coste']) {
141
			if ($infos['num_nom_coste'] == $infos['num_nom_retenu_coste']) {
136
				$infos['num_nom_retenu'] = $infos['num_nom'];
142
				$infos['num_nom_retenu'] = $infos['num_nom'];
137
				if ($nnc != 'R') {
143
				if ($nnc != 'R') {
138
					$nomSuperieur = $this->indexFinal[$infos['num_tax_sup_coste']];
144
					$nomSuperieur = $this->indexFinal[$infos['num_tax_sup_coste']];
-
 
145
					$infos['num_tax_sup'] = $nomSuperieur['num_nom'];
139
					$infos['num_tax_sup'] = $nomSuperieur['num_nom'];
146
				}
140
				}
147
				$nomRetenu = $infos;
141
			} else {
148
			} else {
142
				$nomRetenu = $this->indexFinal[$infos['num_nom_retenu_coste']];
149
				$nomRetenu = $this->indexFinal[$infos['num_nom_retenu_coste']];
-
 
150
				$infos['num_nom_retenu'] = $nomRetenu['num_nom'];
-
 
151
			}
-
 
152
			$infos['image'] = $this->obtenirNomFichierImg($nomRetenu);
-
 
153
			$infos['nbre_taxons'] = $this->obtenirNbreTaxon($infos);
-
 
154
			$infos['nbre_taxons'] = $infos['nbre_taxons'];
-
 
155
			$infos['page_wiki_dsc'] = $this->genererPageWikiDsc($nomRetenu);
143
				$infos['num_nom_retenu'] = $nomRetenu['num_nom'];
156
			$infos['page_wiki_cle'] = $this->genererPageWikiCle($nomRetenu);
144
			}
157
 
145
			$this->indexFinal[$nnc] = $infos;
158
			$this->indexFinal[$nnc] = $infos;
Line -... Line 159...
-
 
159
		}
-
 
160
	}
-
 
161
 
-
 
162
	private function genererNbreTaxons() {
-
 
163
		foreach ($this->indexFinal as $infos) {
-
 
164
			if ($infos['num_tax_sup_coste'] != '') {
-
 
165
				if (isset($this->nbreTaxonInf[$infos['num_tax_sup_coste']])) {
-
 
166
					$this->nbreTaxonInf[$infos['num_tax_sup_coste']] += 1;
-
 
167
				} else {
-
 
168
					$this->nbreTaxonInf[$infos['num_tax_sup_coste']] = 1;
-
 
169
				}
-
 
170
			}
-
 
171
		}
-
 
172
	}
-
 
173
 
-
 
174
	private function genererPageWikiDsc($infos) {
-
 
175
		$prefixe = $this->genererPrefixePage($infos);
-
 
176
		$nomSci = str_replace(' ', '', ucwords(strtolower($infos['nom_sci'])));
-
 
177
		$pageWiki = $prefixe.$nomSci;
-
 
178
		return $pageWiki;
-
 
179
	}
-
 
180
 
-
 
181
	private function genererPageWikiCle($infos) {
-
 
182
		$pageWiki = '';
-
 
183
		if ($infos['nbre_taxons'] > 1) {
-
 
184
			$prefixe = $this->genererPrefixePage($infos);
-
 
185
			if ($infos['rang'] == '180') {
-
 
186
				$pageWiki = $prefixe.'TabGen';
-
 
187
			} else if ($infos['rang'] == '220') {
-
 
188
				$pageWiki = $prefixe.'TabSp';
-
 
189
			}
-
 
190
		}
-
 
191
		return $pageWiki;
-
 
192
	}
-
 
193
 
-
 
194
	private function genererPrefixePage($infos) {
-
 
195
		$prefixe = '';
-
 
196
		$num = preg_replace('/^[a-z]*([0-9.]+)$/i', '$1', $infos['num_nom_coste']);
-
 
197
		if (preg_match('/^([0-9]+)[.][0-9]+$/i', $infos['num_nom_coste'], $match)) {
-
 
198
			$num = sprintf('%04s', $match[1]);
-
 
199
		} else if ($infos['rang'] < 80 ) {
-
 
200
			$num = sprintf('%02s', $num);
-
 
201
		} else if ($infos['rang'] < 290 ) {
-
 
202
			$num = sprintf('%03s', $num);
-
 
203
		} else {
-
 
204
			$num = sprintf('%04s', $num);
-
 
205
		}
-
 
206
		$rangsTxt = array('20' => 'Reg', '40' => 'Emb', '80' => 'Cla', '180' => 'Fam', '220' => 'Gen', '290' => 'Esp', '340' => 'Var');
-
 
207
		$rang = $rangsTxt[$infos['rang']];
-
 
208
 
-
 
209
		$prefixe = $rang.$num;
-
 
210
		return $prefixe;
-
 
211
	}
-
 
212
 
-
 
213
	private function obtenirNbreTaxon($infos) {
-
 
214
		$nbre = '';
-
 
215
		if ($infos['rang'] == 180 || $infos['rang'] == 220) {
-
 
216
			if (isset($this->nbreTaxonInf[$infos['num_nom_coste']])) {
-
 
217
				$nbre = $this->nbreTaxonInf[$infos['num_nom_coste']];
-
 
218
			}
-
 
219
		}
-
 
220
		return $nbre;
-
 
221
	}
-
 
222
 
-
 
223
	private function obtenirNomFichierImg($infos) {
-
 
224
		$img = '';
-
 
225
		if ($infos['rang'] == '290' && ($infos['num_nom'] == $infos['num_nom_retenu'])) {
-
 
226
			$img = $infos['num_nom_coste'].'.png';
-
 
227
		}
146
		}
228
		return $img;
147
	}
229
	}
148
 
230
 
149
	private function creerFichierCsvIndexFinal() {
231
	private function creerFichierCsvIndexFinal() {
150
		$lignes = array();
232
		$lignes = array();