/trunk/modules/resultat/formateurs/nom_vernaculaire/DeterminationVernaFormateur.php |
---|
125,29 → 125,39 |
$chaine = str_replace($codeReftax, '', $chaine); |
return $chaine; |
} |
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')); |
} |
private function extraireInfosNomsPourTplDetermination() { |
$taxons = array(); |
foreach ($this->noms as $idNomCourant => $nom) { |
$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']); |
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) { |
$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 )) { |
//au moins un debute par la requête |
if (isset($taxons) && 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) { |
if (isset($taxons) && array_key_exists($nn, $taxons[1]) == false) { |
$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn); |
} |
$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom); |
} |
} |
ksort($taxons); |
$this->infosPourTpl['noms'] = isset($taxons) ? $taxons : false; |
} |
186,11 → 196,7 |
return $this->trieur->trier(); |
} |
public function diviserResultats() { |
foreach ($this->infosPourTpl['noms'] as $nt => $valeurs) { |
} |
} |
public function surligner() { |
$this->definirMotsASurligner(); |
204,39 → 210,13 |
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); |
/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; |
} |
} |
?> |