Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 216 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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