Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev Author Line No. Line
161 jpm 1
<?php
2
class AlphabVernaFormateur implements Formateur {
3
 
4
	const TPL_VUE = 'liste_noms_verna';
5
 
6
	private $parametres = null;
7
	private $surligneur = null;
8
	private $trieur = null;
9
	private $urls = null;
10
	private $fusioneur = null;
11
	private $manipulateurDeChaine = null;
12
	private $imagesService = null;
13
 
14
	private $motsASurligner = array();
15
	private $noms = array();
16
	private $infosPourTpl = array();
17
 
18
	public function __construct(ParametresResultats $parametres, Array $resultats,
19
		Surligneur $surligneur = null, Trieur $trieur = null, AppUrls $urls = null,
20
		ChaineManipulateur $manipulateurDeChaine = null, Images $imagesService = null) {
21
 
22
		$this->parametres = $parametres;
23
		$this->noms = $resultats['resultat'];
24
		$this->surligneur = (is_null($surligneur)) ? new Surligneur() : $surligneur;
25
		$this->trieur = (is_null($trieur)) ? new Trieur() : $trieur;
26
		$this->urls = (is_null($urls)) ? new AppUrls() : $urls;
27
		$this->manipulateurDeChaine = is_null($manipulateurDeChaine) ? new ChaineManipulateur() : $manipulateurDeChaine;
28
		$this->imagesService = is_null($imagesService) ? new Images($this->parametres->projetImg) : $imagesService;
29
	}
30
 
31
	public function getTplInfos() {
32
		return $this->infosPourTpl;
33
	}
34
 
35
	public function getTplNom() {
36
		return self::TPL_VUE;
37
	}
791 mathilde 38
 
39
	private function supprimerCodeReftaxAvecNn($nn) {
40
		$codeReftax = $this->parametres->reftaxCourant.'.nn:';
41
		return str_replace($codeReftax, '', $nn);
42
	}
161 jpm 43
 
44
	public function formater() {
791 mathilde 45
	foreach ($this->noms as $id => $nom) {
46
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
47
			$infosDuNom = array();
48
			$infosDuNom['nomSci'] = $nom['taxon'];
49
			$infosDuNom['nomVerna'] = $nom['nom_vernaculaire'];
50
			$infosDuNom['langue'] = $nom['code_langue'];
51
			$infosDuNom['geo'] = $nom['zone_usage'];
52
			$infosDuNom['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom,  $this->parametres->masqueRecherche);
53
			$this->infosPourTpl['noms'][$nn] = $infosDuNom;
54
		}
161 jpm 55
	}
56
 
57
	public function trier() {
791 mathilde 58
		$this->trieur->setTableau($this->infosPourTpl['noms']);
59
		$this->trieur->setChampsEtOrdres(array('nomVerna'=> SORT_NATURAL));
60
		$this->infosPourTpl['noms'] = $this->trieur->trier();
161 jpm 61
	}
62
 
63
	public function surligner() {
64
 
65
	}
66
}
67
?>