Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 797 → Rev 798

/trunk/modules/resultat/formateurs/nom_vernaculaire/AlphabVernaFormateur.php
40,28 → 40,74
$codeReftax = $this->parametres->reftaxCourant.'.nn:';
return str_replace($codeReftax, '', $nn);
}
private function renvoyerInfoVerna($nn, $valeurs) {
$infosDuNom = array();
$infosDuNom['nomSci'] = $valeurs['taxon'];
$infosDuNom['nomVerna'] = $valeurs['nom_vernaculaire'];
$infosDuNom['langue'] = $valeurs['code_langue'];
$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
return $infosDuNom ;
}
 
function supprimerAccents($chaine){
return strtr($chaine,array('à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a',
'ç' => 'c',
'è' => 'e','é' => 'e','ê' => 'e','ë' => 'e',
'ì' => 'i','í' => 'i','î' => 'i','ï' => 'i',
'ñ' => 'n',
'ò' => 'o', 'ó' => 'o' , 'ô' => 'o', 'õ' => 'o', 'ö' => 'o',
'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u',
'ý' => 'y', 'ÿ' => 'y'));
}
public function formater() {
$nomVerna = array();
foreach ($this->noms as $id => $nom) {
$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
$infosDuNom = array();
$infosDuNom['nomSci'] = $nom['taxon'];
$infosDuNom['nomVerna'] = $nom['nom_vernaculaire'];
$infosDuNom['langue'] = $nom['code_langue'];
$infosDuNom['geo'] = $nom['zone_usage'];
$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
$this->infosPourTpl['noms'][$nn] = $infosDuNom;
$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)) {
$nomVerna[0][$id] = $this->renvoyerInfoVerna($nn, $nom);
} else {
$nomVerna[1][$id] = $this->renvoyerInfoVerna($nn, $nom);
}
}
ksort($nomVerna);
$this->infosPourTpl['noms'] = isset($nomVerna) ? $nomVerna : false;
}
 
public function trier() {
$this->trieur->setTableau($this->infosPourTpl['noms']);
$this->trieur->setChampsEtOrdres(array('nomVerna'=> SORT_NATURAL));
$this->infosPourTpl['noms'] = $this->trieur->trier();
public function trier() {
$verna = array();
foreach ($this->infosPourTpl['noms'] as $categorie => $valeurs) {
$verna += $this->classerAlphabetiquement('nomVerna', $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 surligner() {
$this->definirMotsASurligner();
foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
$this->infosPourTpl['noms'][$idNom]['nomVerna'] = $this->surlignerMotsMasqueRecherche($nom['nomVerna']);
}
}
 
private function definirMotsASurligner() {
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
 
}
 
private function surlignerMotsMasqueRecherche($nom) {
$this->surligneur->setTexte($nom);
$nom = $this->surligneur->surlignerMots($this->motsASurligner);
return $nom;
}
}
?>