Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 208 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
206 jpm 1
<?php
2
class NomDetailsGenerique implements NomDetails {
3
 
4
	private $parametres = null;
5
	private $ressources = null;
6
	private $bdd = null;
7
	private $projet = null;
8
	private $versions = null;
9
	private $detailsHrefTpl = null;
10
	private $ontologieHrefTpl = null;
11
 
12
	private $nom = array();
13
	private $champsProjet = array();
14
 
15
	public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd) {
16
		$this->ressources = $ressources;
17
		$this->parametres = $parametres;
18
		$this->bdd = $bdd;
19
	}
20
 
21
	public function setProjet($projet) {
22
		$this->projet = $projet;
23
	}
24
 
25
	public function setVersions($versions) {
26
		$this->versions = $versions;
27
	}
28
 
29
	public function setChampsProjet($champsProjet) {
30
		$this->champsProjet = $champsProjet;
31
	}
32
 
33
	public function setDetailsHrefTpl($tpl) {
34
		$this->detailsHrefTpl = $tpl;
35
	}
36
 
37
	public function setOntologieHrefTpl($tpl) {
38
		$this->ontologieHrefTpl = $tpl;
39
	}
40
 
41
	public function consulter() {
42
		$infos = $this->rechercherInfosNom();
43
		$retour = $this->formaterDetails($infos);
44
		return $retour;
45
	}
46
 
47
	private function getTable() {
48
		$versions = $this->versions->getVersions();
49
		return $this->projet.'_v'.end($versions);
50
	}
51
 
52
	private function rechercherInfosNom() {
53
		$table = $this->getTable();
54
		$detailsId = $this->ressources->getDetailsId();
55
		$detailsId = $this->bdd->proteger($detailsId);
56
		$requete =
57
			'SELECT ns.*,  '.
58
			'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
59
			"FROM $table AS ns ".
60
			"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
61
			"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
62
			"WHERE ns.num_nom = $detailsId ";
63
		$resultats = $this->bdd->recuperer($requete);
64
		return $resultats;
65
	}
66
 
67
	private function formaterDetails($infos) {
68
		$nomAFormater = new NomDO($infos);
69
		$formateur = new NomFormateur($nomAFormater);
70
		$formateur->setBdd($this->bdd);
71
		$formateur->setChampsProjet($this->champsProjet);
72
		$formateur->setDetailsHrefTpl($this->detailsHrefTpl);
73
		$formateur->setOntologieHrefTpl($this->ontologieHrefTpl);
74
		$formateur->setChampsRetour($this->parametres->getListe('retour.champs'));
75
		$details = $formateur->formaterDetails();
76
		return $details;
77
	}
78
}
79
?>