127,24 → 127,44 |
} |
|
|
|
private function extraireInfosNomsPourTplDetermination() { |
$taxons = array(); |
foreach ($this->noms as $idNomCourant => $nom) { |
$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']); |
if (array_key_exists($nn, $taxons) == false) { |
$taxon = array(); |
$taxon['nomSci'] = $nom['taxon']; |
$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche); |
$taxon['repartition_vignette'] = $this->chargerRepartition($nn); |
$taxons[$nn] = $taxon; |
if (preg_match('/^'. strtolower($this->parametres->masqueRecherche).' |^'. strtolower($this->parametres->masqueRecherche).'$/', strtolower($nom['nom_vernaculaire']))) { |
//debute par |
if (array_key_exists($nn, $taxons[0]) == false) { |
$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn); |
} |
$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom); |
} else { |
//contient |
if (array_key_exists($nn, $taxons[1]) == false) { |
$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn); |
} |
$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom); |
} |
$nom_verna = array(); |
$nom_verna['nn'] = $nom['id']; |
$nom_verna['nom_vernaculaire'] = $nom['nom_vernaculaire']; |
$taxons[$nn]['nomVerna'][] = $nom_verna; |
} |
$this->infosPourTpl['noms'] = (count($taxons) > 0) ? $taxons : false; |
ksort($taxons); |
|
$this->infosPourTpl['noms'] = isset($taxons) ? $taxons : false; |
} |
|
private function renvoyerInfosNomVerna($valeurs) { |
$nom_verna = array(); |
$nom_verna['nn'] = $valeurs['id']; |
$nom_verna['nom_vernaculaire'] = $valeurs['nom_vernaculaire']; |
return $nom_verna; |
} |
|
private function renvoyerInfosTaxon($nomSci, $nn) { |
$taxon = array(); |
$taxon['nomSci'] = $nomSci; |
$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche); |
$taxon['repartition_vignette'] = $this->chargerRepartition($nn); |
return $taxon; |
} |
|
private function supprimerCodeReftaxAvecNn($nn) { |
$codeReftax = $this->parametres->reftaxCourant.'.nn:'; |
151,10 → 171,26 |
return str_replace($codeReftax, '', $nn); |
} |
|
|
//tri alphabétique des noms scientifiques par catégorie (débute par , contient ) |
public function trier() { |
|
$verna = array(); |
foreach ($this->infosPourTpl['noms'] as $categorie => $valeurs) { |
$verna += $this->classerAlphabetiquement('nomSci', $valeurs); |
} |
$this->infosPourTpl['noms'] = $verna; |
} |
|
private function classerAlphabetiquement($champs, $valeurs) { |
$this->trieur->setTableau($valeurs); |
$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL)); |
return $this->trieur->trier(); |
} |
|
public function diviserResultats() { |
foreach ($this->infosPourTpl['noms'] as $nt => $valeurs) { |
|
} |
} |
|
public function surligner() { |
$this->definirMotsASurligner(); |
168,8 → 204,39 |
|
private function definirMotsASurligner() { |
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche); |
foreach ($this->motsASurligner as $mot) { |
if (preg_match_all('/[aeiou]+/', $mot, $retour)) { |
$retour = array_unique($retour); |
$this->motsASurligner = $this->ajouterAccents($mot,$retour); |
} |
} |
} |
|
|
|
//pour le surlignage si présence d'accents |
private function ajouterAccents($mot, $retour) { |
$mots = array($mot); |
$accents = array('a' => array('à', 'â', 'ä'), |
'e' => array('é', 'è', 'ë', 'ê'), |
'i' => array('î' , 'ï'), |
'o' => array('ô', 'ö'), |
'u' => array('û', 'ü') |
); |
foreach($accents as $voyelle => $accents) { |
$lettre = array_shift($retour[0]); |
if ($lettre == $voyelle ) { |
foreach ($accents as $ac) { |
$mots[] = str_replace($lettre, $ac, $mot); |
} |
} |
if (empty($retour[0])) { |
break; |
} |
} |
return $mots; |
} |
|
private function surlignerMotsMasqueRecherche($nom) { |
$this->surligneur->setTexte($nom); |
$nom = $this->surligneur->surlignerMots($this->motsASurligner); |