7,9 → 7,11 |
private $conteneur = null; |
private $outils = null; |
private $messages = null; |
private $generateur = null; |
private $dossierBase = ''; |
private $spIndex = array(); |
private $supraSpIndex = array(); |
private $imgIndex = array(); |
private $indexFinal = array(); |
private $tableauParDefaut = array(); |
private $nbreTaxonInf = array(); |
19,10 → 21,20 |
'num_tax_sup', |
'rang', |
'nom_sci', |
'nom_supra_generique', |
'genre', |
'epithete_infra_generique', |
'epithete_sp', |
'type_epithete', |
'epithete_infra_sp', |
'cultivar_groupe', |
'cultivar', |
'nom_commercial', |
'auteur', |
'nom_addendum', |
'annee', |
'biblio_origine', |
'notes', |
'nom_addendum', |
'nom_francais', |
'nom_coste', |
'auteur_coste', |
34,11 → 46,13 |
'tome', |
'page', |
'nbre_taxons', |
'bdnff_nn', |
'bdnff_nt', |
'flore_bdtfx_nn', |
'flore_bdtfx_nt', |
'image', |
'image_auteur', |
'page_wiki_dsc', |
'page_wiki_cle'); |
'page_wiki_cle', |
'nom_sci_html'); |
|
public function __construct(Conteneur $conteneur) { |
mb_internal_encoding('UTF-8'); |
46,6 → 60,7 |
$this->conteneur = $conteneur; |
$this->outils = $conteneur->getOutils(); |
$this->messages = $conteneur->getMessages(); |
$this->generateur = $conteneur->getGenerateurNomSciHtml(); |
$this->dossierBase = dirname(__FILE__).'/'; |
} |
|
55,6 → 70,9 |
$this->initialiserTableauLigneIndexFinal(); |
$this->creerIndexFinal(); |
$this->ajouterChampsDansIndexFinal(); |
$this->ajouteurAuteurImage(); |
$this->decomposerNomSci(); |
$this->ajouteurNomSciHtml(); |
$this->creerFichierCsvIndexFinal(); |
} |
|
152,7 → 170,11 |
|
private function genererPageWikiDsc($infos) { |
$prefixe = $this->genererPrefixePage($infos); |
if ($infos['rang'] == '180') { |
$nomSci = str_replace(' ', '', ucwords(strtolower($infos['nom_coste']))); |
} else { |
$nomSci = str_replace(' ', '', ucwords(strtolower($infos['nom_sci']))); |
} |
$pageWiki = $prefixe.$nomSci; |
return $pageWiki; |
} |
161,7 → 183,13 |
$pageWiki = ''; |
if ($infos['nbre_taxons'] > 1) { |
$prefixe = $this->genererPrefixePage($infos); |
if ($infos['rang'] == '180') { |
if ($infos['rang'] == '20') { |
$pageWiki = $prefixe.'TabClaEtEmb'; |
} elseif ($infos['rang'] == '40' && ($infos['num_nom_coste'] == 'E2' || $infos['num_nom_coste'] == 'E3')) { |
$pageWiki = $prefixe.'TabFam'; |
} else if ($infos['rang'] == '80') { |
$pageWiki = $prefixe.'TabFam'; |
} else if ($infos['rang'] == '180') { |
$pageWiki = $prefixe.'TabGen'; |
} else if ($infos['rang'] == '220') { |
$pageWiki = $prefixe.'TabSp'; |
175,6 → 203,8 |
$num = preg_replace('/^[a-z]*([0-9.]+)$/i', '$1', $infos['num_nom_coste']); |
if (preg_match('/^([0-9]+)[.][0-9]+$/i', $infos['num_nom_coste'], $match)) { |
$num = sprintf('%04s', $match[1]); |
} else if ($infos['rang'] == 20 ) { |
$num = ''; |
} else if ($infos['rang'] < 80 ) { |
$num = sprintf('%02s', $num); |
} else if ($infos['rang'] < 290 ) { |
191,11 → 221,9 |
|
private function obtenirNbreTaxon($infos) { |
$nbre = ''; |
if ($infos['rang'] == 180 || $infos['rang'] == 220) { |
if (isset($this->nbreTaxonInf[$infos['num_nom_coste']])) { |
$nbre = $this->nbreTaxonInf[$infos['num_nom_coste']]; |
} |
} |
return $nbre; |
} |
|
207,6 → 235,66 |
return $img; |
} |
|
private function ajouteurAuteurImage() { |
$this->chargerAuteurImg(); |
foreach ($this->indexFinal as $nnc => $infos) { |
$infos['image_auteur'] = $this->imgIndex[$infos['image']]; |
$this->indexFinal[$nnc] = $infos; |
} |
} |
|
private function chargerAuteurImg() { |
$imgIndexFichier = $this->dossierBase.self::DOSSIER_V0.'coste_images_auteur_correspondance_bdnff.tsv'; |
$index = $this->outils->transformerTxtTsvEnTableau($imgIndexFichier); |
foreach ($index as $infos) { |
$id = $infos['id_image']; |
$this->imgIndex[$id] = $infos['auteur']; |
} |
} |
|
private function decomposerNomSci() { |
$majuscule = "[ÆŒA-Z]"; |
$epithete = "[æœïa-z-]+"; |
foreach ($this->indexFinal as $nnc => $infos) { |
$id = $infos['num_nom_coste']; |
$nomSci = $infos['nom_sci']; |
$rang = $infos['rang']; |
if ($rang < 220) { |
$infos['nom_supra_generique'] = $nomSci; |
} else if ($rang == 220) { |
$infos['genre'] = $nomSci; |
} else if ($rang == 290) { |
if (preg_match("/^($majuscule$epithete) ($epithete)$/", $nomSci, $match)) { |
$infos['genre'] = $match[1]; |
$infos['epithete_sp'] = $match[2]; |
} else { |
$this->messages->traiterErreur("Le nom $nomSci ($id) de rang $rang n'est pas standard."); |
} |
} else if ($rang == 340) { |
if (preg_match("/^($majuscule$epithete) ($epithete) (var[.]) ($epithete)$/", $nomSci, $match)) { |
$infos['genre'] = $match[1]; |
$infos['epithete_sp'] = $match[2]; |
$infos['type_epithete'] = $match[3]; |
$infos['epithete_infra_sp'] = $match[4]; |
} else { |
$this->messages->traiterErreur("Le nom $nomSci ($id) de rang $rang n'est pas standard."); |
} |
} |
|
$this->indexFinal[$nnc] = $infos; |
$this->messages->afficherAvancement("Décomposition des noms scientifiques en cours"); |
} |
echo "\n"; |
} |
|
private function ajouteurNomSciHtml() { |
foreach ($this->indexFinal as $nnc => $infos) { |
$this->indexFinal[$nnc]['nom_sci_html'] = $this->generateur->genererNomSciHtml($infos); |
$this->messages->afficherAvancement("Création des noms scientifiques HTML en cours"); |
} |
echo "\n"; |
} |
|
private function creerFichierCsvIndexFinal() { |
$lignes = array(); |
array_unshift($this->indexFinal, $this->enteteFinal); |