Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 871 → Rev 872

/trunk/modules/resultat/formateurs/nom_scientifique/DeterminationFormateur.php
42,16 → 42,9
$this->obtenirUrlsPhotos();
$this->chargerRepartition();
$this->extraireInfosNomsPourTplDetermination();
}
 
private function obtenirUrlsPhotos() {
$this->imagesService->setProjet('cel');
$ids = $this->extraireIdDesNoms();
$urls = $this->imagesService->getUrlsImagesParIdsNoms($ids);
$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReftaxDesIds($urls);
}
private function obtenirUrlsImagesCoste() {
$this->extraireInfosTaxons();
$this->imagesService->setProjet('coste');
66,7 → 59,6
}
}
}
 
private function extraireInfosTaxons() {
foreach ($this->noms as $id => $nom ) {
if (array_key_exists('num_taxonomique', $nom)) {
75,28 → 67,14
}
}
// TODO : utiliser le conteneur pour charger tous les objets de cette classe
private function chargerRepartition() {
$conteneur = new Conteneur();
$cartesWs = $conteneur->getApiCartes();
$cartesWs->setProjet('chorodep');
$cartesWs->setLargeur('108x101');
$urls = array();
foreach ($this->noms as $id => $nom) {
if (array_key_exists('nom_retenu.id', $nom)) {
$id = $nom['nom_retenu.id'];
$cartesWs->setId("nn:$id");
if (array_key_exists($id, $urls) == false) {
$urls[$id] = $cartesWs->getUrlPng();
}
}
}
$this->infosPourTpl['repartition']['urls'] = $urls;
private function obtenirUrlsPhotos() {
$this->imagesService->setProjet('cel');
$ids = $this->extraireIdDesNoms();
$urls = $this->imagesService->getUrlsImagesParIdsNoms($ids);
$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReftaxDesIds($urls);
}
 
 
 
private function extraireIdDesNoms() {
$ids = array();
foreach ($this->noms as $id => $nom) {
115,7 → 93,6
}
return $ids;
}
 
private function supprimerCodeReftaxDesIds($urls) {
$urlsNettoyees = array();
foreach ($urls as $id => $url) {
124,13 → 101,40
}
return $urlsNettoyees;
}
 
private function supprimerCodeReftax($chaine) {
$codeReftax = $this->parametres->reftaxCourant.'.';
$chaine = str_replace($codeReftax, '', $chaine);
return $chaine;
}
// TODO : utiliser le conteneur pour charger tous les objets de cette classe
private function chargerRepartition() {
$conteneur = new Conteneur();
$cartesWs = $conteneur->getApiCartes();
$cartesWs->setProjet('chorodep');
$cartesWs->setLargeur('108x101');
$urls = array();
foreach ($this->noms as $id => $nom) {
if (array_key_exists('nom_retenu.id', $nom)) {
$id = $nom['nom_retenu.id'];
$cartesWs->setId("nn:$id");
if (array_key_exists($id, $urls) == false) {
$urls[$id] = $cartesWs->getUrlPng();
}
}
}
$this->infosPourTpl['repartition']['urls'] = $urls;
}
 
 
private function extraireInfosNomsPourTplDetermination() {
$tri = $this->diviserResultats();
$this->infosPourTpl['nomsSansCorrespondance'] = isset($tri['sansCorres']) ? $tri['sansCorres'] : false;
$this->infosPourTpl['noms'] = isset($tri['retenus']) ? $tri['retenus'] : false;
$this->infosPourTpl['synonymes'] = isset($tri['synonymes'] ) ? $tri['synonymes'] : false;
}
/**
* division ordonnée par
* 1 - noms retenus qui commencent par la requete
175,7 → 179,6
$tri['sansCorres'] = $sansCorres;
return $tri;
}
private function retournerInfosNomRetenu($cle, $nom_sci, $rang) {
$infos = array();
$infos['nomSciRetenu'] = $nom_sci;
183,8 → 186,6
$infos['rang'] = $rang;
return $infos;
}
private function retournerInfosSynonyme($cle, $valeurs) {
$infos = array();
$infos['nn'] = $cle;
192,33 → 193,6
$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, $this->parametres->masqueRecherche, $valeurs['nom_retenu.libelle']);
return $infos;
}
private function classerAlphabetiquement($champs, $valeurs) {
$this->trieur->setTableau($valeurs);
$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
return $this->trieur->trier();
}
private function extraireInfosNomsPourTplDetermination() {
$tri = $this->diviserResultats();
$this->infosPourTpl['nomsSansCorrespondance'] = isset($tri['sansCorres']) ? $tri['sansCorres'] : false;
$this->infosPourTpl['noms'] = isset($tri['retenus']) ? $tri['retenus'] : false;
$this->infosPourTpl['synonymes'] = isset($tri['synonymes'] ) ? $tri['synonymes'] : false;
}
private function donnerNombreResultatRetenus() {
$nbre = 0;
foreach ($this->infosPourTpl['noms'] as $lignes) {
$nbre += count($lignes);
if ($nbre >= 3 ) {
break;
}
}
return $nbre;
}
 
public function trier() {
if ($this->donnerNombreResultatRetenus() <= 3) { // classement par score
$nomsRetenus = array();
241,6 → 215,16
$this->classerAlphabetiquement('nomSciRetenu', $this->infosPourTpl['nomsSansCorrespondance'] );
}
}
private function donnerNombreResultatRetenus() {
$nbre = 0;
foreach ($this->infosPourTpl['noms'] as $lignes) {
$nbre += count($lignes);
if ($nbre >= 3 ) {
break;
}
}
return $nbre;
}
private function ajouterAuxNomsScoreSimilariteAvec($masque) {
$nom_demande_ss = strtolower($this->manipulateurDeChaine->supprimerAccents($masque));
255,7 → 239,14
$this->infosPourTpl['noms'][$id] = $nom;
}
}
private function classerAlphabetiquement($champs, $valeurs) {
$this->trieur->setTableau($valeurs);
$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
return $this->trieur->trier();
}
 
public function surligner() {
$this->definirMotsASurligner();
foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
267,11 → 258,9
}
}
}
 
private function definirMotsASurligner() {
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
}
 
private function surlignerMotsMasqueRecherche($nom) {
$this->surligneur->setTexte($nom);
$nom = $this->surligneur->surlignerMots($this->motsASurligner);