Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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();
33
			$infosDuNom['nomSci'] = $nom['nom_sci'];
34
			$infosDuNom['retenu'] = $nom['retenu'];
35
			$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($id);
36
 
37
			$this->infosPourTpl['noms'][$id] = $infosDuNom;
38
		}
39
	}
40
 
41
	public function trier() {
42
		$this->trieur->setTableau($this->infosPourTpl['noms']);
43
		$this->trieur->setChampsEtOrdres(array('nomSci' => SORT_ASC));
44
		$this->infosPourTpl['noms'] = $this->trieur->trier();
45
	}
46
 
47
	public function surligner() {
48
		$this->definirMotsASurligner();
49
		foreach ($this->infosPourTpl['noms'] as $id => $nom) {
50
			$this->infosPourTpl['noms'][$id]['nomSci'] = $this->surlignerMotsMasqueRecherche($nom['nomSci']);
51
		}
52
	}
53
 
54
	private function definirMotsASurligner() {
55
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
56
	}
57
 
58
	private function surlignerMotsMasqueRecherche($nom) {
59
		$this->surligneur->setTexte($nom);
60
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);
61
		return $nom;
62
	}
63
}
64
?>