Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 146 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 146 Rev 149
Line 1... Line 1...
1
<?php
1
<?php
2
class DecompoFormateur implements Formateur {
2
class DecompoFormateur implements Formateur {
Line 3... Line 3...
3
 
3
 
Line -... Line 4...
-
 
4
	const TPL_VUE = 'decomposition';
-
 
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();
4
	private $resultats = null;
12
	private $infosPourTpl = array();
-
 
13
 
5
 
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
 
6
	public function __construct(ParametresResultats $resultats) {
26
	public function getTplNom() {
Line 7... Line 27...
7
		$this->resultats = $resultats;
27
		return self::TPL_VUE;
-
 
28
	}
8
	}
29
 
9
 
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'] == '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
		}
-
 
44
	}
-
 
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
 
10
	public function formater() {
63
	private function surlignerMotsMasqueRecherche($nom) {
11
		$donnees = array();
64
		$this->surligneur->setTexte($nom);
12
		$donnees['vue'] = 'decomposition';
65
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);
13
		return $donnees;
66
		return $nom;
14
	}
67
	}