146 |
jpm |
1 |
<?php
|
|
|
2 |
class DecompoFormateur implements Formateur {
|
|
|
3 |
|
149 |
jpm |
4 |
const TPL_VUE = 'decomposition';
|
146 |
jpm |
5 |
|
149 |
jpm |
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;
|
146 |
jpm |
20 |
}
|
|
|
21 |
|
149 |
jpm |
22 |
public function getTplInfos() {
|
|
|
23 |
return $this->infosPourTpl;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
public function getTplNom() {
|
|
|
27 |
return self::TPL_VUE;
|
|
|
28 |
}
|
|
|
29 |
|
146 |
jpm |
30 |
public function formater() {
|
188 |
jpm |
31 |
$this->infosPourTpl['masqueRecherche'] = rawurlencode($this->parametres->masqueRecherche);
|
|
|
32 |
$this->infosPourTpl['baseUrlIco'] = $this->urls->obtenirUrlBaseDossier();
|
149 |
jpm |
33 |
foreach ($this->noms as $id => $nom) {
|
|
|
34 |
$infosDuNom = array();
|
|
|
35 |
$infosDuNom['nomSci'] = $nom['nom_sci'];
|
|
|
36 |
$infosDuNom['retenu'] = $nom['retenu'] == 'true' ? true : false;
|
|
|
37 |
$infosDuNom['auteur'] = is_null($nom['auteur']) ? '' : $nom['auteur'];
|
|
|
38 |
$infosDuNom['annee'] = is_null($nom['annee']) ? '' : $nom['annee'];
|
|
|
39 |
$infosDuNom['biblio'] = is_null($nom['biblio_origine']) ? '' : $nom['biblio_origine'];
|
|
|
40 |
$infosDuNom['addendum'] = is_null($nom['nom_addendum']) ? '' : $nom['nom_addendum'];
|
|
|
41 |
$infosDuNom['nn'] = $id;
|
216 |
delphine |
42 |
$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($id, $this->parametres->typeNom, $this->parametres->masqueRecherche);
|
149 |
jpm |
43 |
|
|
|
44 |
$this->infosPourTpl['noms'][$id] = $infosDuNom;
|
|
|
45 |
}
|
146 |
jpm |
46 |
}
|
149 |
jpm |
47 |
|
|
|
48 |
public function trier() {
|
|
|
49 |
$this->trieur->setTableau($this->infosPourTpl['noms']);
|
|
|
50 |
$this->trieur->setChampsEtOrdres(array('nomSci' => SORT_ASC));
|
|
|
51 |
$this->infosPourTpl['noms'] = $this->trieur->trier();
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public function surligner() {
|
|
|
55 |
$this->definirMotsASurligner();
|
|
|
56 |
foreach ($this->infosPourTpl['noms'] as $id => $nom) {
|
|
|
57 |
$this->infosPourTpl['noms'][$id]['nomSci'] = $this->surlignerMotsMasqueRecherche($nom['nomSci']);
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
private function definirMotsASurligner() {
|
|
|
62 |
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
private function surlignerMotsMasqueRecherche($nom) {
|
|
|
66 |
$this->surligneur->setTexte($nom);
|
|
|
67 |
$nom = $this->surligneur->surlignerMots($this->motsASurligner);
|
|
|
68 |
return $nom;
|
|
|
69 |
}
|
146 |
jpm |
70 |
}
|
|
|
71 |
?>
|