Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 146 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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