Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 930 → Rev 931

/trunk/modules/resultat/formateurs/nom_vernaculaire/DeterminationVernaFormateur.php
34,23 → 34,6
$this->apiCartes = $this->conteneur->getApiCartes();
}
 
private function chargerRepartition() {
$this->apiCartes->setProjet('chorodep');
$this->apiCartes->setLargeur('108x101');
$urls = array();
foreach ($this->noms as $nom) {
if (array_key_exists('nom_retenu.code', $nom)) {
$id = $nom['nom_retenu.code'];
$id = $this->supprimerCodeReftaxAvecNn($id);
$this->apiCartes->setId("nn:$id");
if (array_key_exists($id, $urls) == false) {
$urls[$id] = $this->apiCartes->getUrlPng();
}
}
}
$this->infosPourTpl['repartition']['urls'] = $urls;
}
 
public function getTplInfos() {
return $this->infosPourTpl;
}
60,23 → 43,25
}
 
public function formater() {
$this->obtenirUrlsDessins();
$this->obtenirUrlsPhotos();
$this->chargerRepartition();
$this->extraireInfosNomsPourTplDetermination();
$this->obtenirUrlsImagesCoste();
$this->chargerRepartition();
}
private function obtenirUrlsImagesCoste() {
$this->extraireInfosTaxons();
$this->imagesService->setProjet('coste');
$tax = implode(',', $this->infosPourTpl['taxons']);
$this->imagesService->setNnTaxon($tax);
$costeImg = $this->imagesService->getInfosImagesTaxons();
if (!empty($costeImg)) {
foreach ($costeImg as $infos) {
$num_taxon = $infos['num_taxonomique'];
$images[$num_taxon][] = $infos['binaire.href'];
$this->infosPourTpl['imagesCoste'] = $images;
private function obtenirUrlsDessins() {
if (Config::get(Registre::get('parametres.referentiel').'.baseDessins') != "") {
$this->extraireInfosTaxons();
$this->imagesService->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseDessins'));
$tax = implode(',', $this->infosPourTpl['taxons']);
$this->imagesService->setNnTaxon($tax);
$costeImg = $this->imagesService->getInfosImagesTaxons();
if (!empty($costeImg)) {
foreach ($costeImg as $infos) {
$num_taxon = $infos['num_taxonomique'];
$images[$num_taxon][] = $infos['binaire.href'];
$this->infosPourTpl['imagesCoste'] = $images;
}
}
}
}
93,7 → 78,7
private function obtenirUrlsPhotos() {
$nns = $this->extraireNnDesNoms();
$urls = $this->imagesService->getUrlsImagesParIdsNoms($nns);
$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReftaxDesUrls($urls);
$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReferentielDesUrls($urls);
}
 
private function extraireNnDesNoms() {
101,7 → 86,7
foreach ($this->noms as $id => $nom) {
if (array_key_exists('nom_retenu.code', $nom)) {
if (in_array($nom['nom_retenu.code'], $nns) == false) {
$idAAjouter = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
$idAAjouter = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
if (is_numeric($idAAjouter)) {
$nns[] = $idAAjouter;
}
111,21 → 96,40
return $nns;
}
 
private function supprimerCodeReftaxDesUrls($urls) {
private function supprimerCodeReferentielDesUrls($urls) {
$urlsNettoyees = array();
foreach ($urls as $id => $url) {
$id = $this->supprimerCodeReftax($id);
$id = $this->supprimerCodeReferentiel($id);
$urlsNettoyees[$id] = $url;
}
return $urlsNettoyees;
}
 
private function supprimerCodeReftax($chaine) {
$codeReftax = $this->parametres->reftaxCourant.'.';
$chaine = str_replace($codeReftax, '', $chaine);
private function supprimerCodeReferentiel($chaine) {
$codeReferentiel = $this->parametres->referentielCourant.'.';
$chaine = str_replace($codeReferentiel, '', $chaine);
return $chaine;
}
private function chargerRepartition() {
if (Config::get(Registre::get('parametres.referentiel').'.baseRepartition') != "") {
$this->apiCartes->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseRepartition'));
$this->apiCartes->setLargeur('108x101');
$urls = array();
foreach ($this->noms as $nom) {
if (array_key_exists('nom_retenu.code', $nom)) {
$id = $nom['nom_retenu.code'];
$id = $this->supprimerCodeReferentielAvecNn($id);
$this->apiCartes->setId("nn:$id");
if (array_key_exists($id, $urls) == false) {
$urls[$id] = $this->apiCartes->getUrlPng();
}
}
}
$this->infosPourTpl['repartition']['urls'] = $urls;
}
}
function supprimerAccents($chaine){
return strtr($chaine,array('à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a',
'ç' => 'c',
141,7 → 145,7
private function extraireInfosNomsPourTplDetermination() {
$taxons = array();
foreach ($this->noms as $idNomCourant => $nom) {
$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
$nn = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
$nom_min = strtolower($nom['nom_vernaculaire']);
$nom_ss_accent = $this->supprimerAccents($nom_min);
if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).' |^'.strtolower($this->parametres->masqueRecherche).'$/', $nom_ss_accent )) {
152,7 → 156,7
$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
} else {
//contient
if (isset($taxons) && array_key_exists($nn, $taxons[1]) == false) {
if (isset($taxons) && (!isset($taxons[1]) || array_key_exists($nn, $taxons[1]) == false)) {
$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
}
$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
176,9 → 180,9
return $taxon;
}
 
private function supprimerCodeReftaxAvecNn($nn) {
$codeReftax = $this->parametres->reftaxCourant.'.nn:';
return str_replace($codeReftax, '', $nn);
private function supprimerCodeReferentielAvecNn($nn) {
$codeReferentiel = $this->parametres->referentielCourant.'.nn:';
return str_replace($codeReferentiel, '', $nn);
}
 
//tri alphabétique des noms scientifiques par catégorie (débute par , contient )
192,7 → 196,7
private function classerAlphabetiquement($champs, $valeurs) {
$this->trieur->setTableau($valeurs);
$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
$this->trieur->setChampsEtOrdres(array($champs => 'nat'));
return $this->trieur->trier();
}