146 |
jpm |
1 |
<?php
|
|
|
2 |
class AlphabFormateur implements Formateur {
|
|
|
3 |
|
159 |
jpm |
4 |
const TPL_VUE = 'liste_noms';
|
146 |
jpm |
5 |
|
|
|
6 |
private $parametres = null;
|
|
|
7 |
private $surligneur = null;
|
|
|
8 |
private $trieur = null;
|
|
|
9 |
private $urls = null;
|
|
|
10 |
private $motsASurligner = array();
|
|
|
11 |
private $noms = array();
|
|
|
12 |
private $infosPourTpl = array();
|
|
|
13 |
|
|
|
14 |
public function __construct(ParametresResultats $parametres, Array $resultats, Surligneur $surligneur = null, Trieur $trieur = null, AppUrls $urls = null) {
|
|
|
15 |
$this->parametres = $parametres;
|
|
|
16 |
$this->noms = $resultats['resultat'];
|
|
|
17 |
$this->surligneur = (is_null($surligneur)) ? new Surligneur() : $surligneur;
|
|
|
18 |
$this->trieur = (is_null($trieur)) ? new Trieur() : $trieur;
|
|
|
19 |
$this->urls = (is_null($urls)) ? new AppUrls() : $urls;
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
public function getTplInfos() {
|
|
|
23 |
return $this->infosPourTpl;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
public function getTplNom() {
|
|
|
27 |
return self::TPL_VUE;
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
public function formater() {
|
|
|
31 |
foreach ($this->noms as $id => $nom) {
|
|
|
32 |
$infosDuNom = array();
|
872 |
delphine |
33 |
$infosDuNom['nomSci'] = $nom['nom_sci_complet'];
|
146 |
jpm |
34 |
$infosDuNom['retenu'] = $nom['retenu'];
|
247 |
delphine |
35 |
$nom_retenu = $nom['retenu'] == 'true' ? $nom['nom_sci'] : '';
|
369 |
delphine |
36 |
$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($id, $this->parametres->typeNom, $this->parametres->masqueRecherche);
|
146 |
jpm |
37 |
|
|
|
38 |
$this->infosPourTpl['noms'][$id] = $infosDuNom;
|
|
|
39 |
}
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public function trier() {
|
|
|
43 |
$this->trieur->setTableau($this->infosPourTpl['noms']);
|
|
|
44 |
$this->trieur->setChampsEtOrdres(array('nomSci' => SORT_ASC));
|
|
|
45 |
$this->infosPourTpl['noms'] = $this->trieur->trier();
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public function surligner() {
|
|
|
49 |
$this->definirMotsASurligner();
|
|
|
50 |
foreach ($this->infosPourTpl['noms'] as $id => $nom) {
|
|
|
51 |
$this->infosPourTpl['noms'][$id]['nomSci'] = $this->surlignerMotsMasqueRecherche($nom['nomSci']);
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
private function definirMotsASurligner() {
|
|
|
56 |
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
private function surlignerMotsMasqueRecherche($nom) {
|
|
|
60 |
$this->surligneur->setTexte($nom);
|
|
|
61 |
$nom = $this->surligneur->surlignerMots($this->motsASurligner);
|
|
|
62 |
return $nom;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
?>
|