Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 206 Rev 208
Line 1... Line 1...
1
<?php
1
<?php
2
class NomsListeGenerique implements NomsListe {
2
class NomsListeGenerique implements NomsListe {
Line 3... Line 3...
3
 
3
 
4
	private $parametres = null;
4
	private $parametres = null;
5
	private $ressources = null;
-
 
6
	private $bdd = null;
5
	private $ressources = null;
7
	private $projet = null;
-
 
8
	private $versions = null;
6
	private $nomDao = null;
9
	private $listeUrl = null;
-
 
10
	private $detailsHrefTpl = null;
-
 
11
	private $ontologieHrefTpl = null;
-
 
Line -... Line 7...
-
 
7
	private $nomFormateur = null;
12
	private $champsProjet = array();
8
 
13
 
9
	private $listeUrl = null;
Line 14... Line 10...
14
	private $nbreTotalNoms = 0;
10
	private $nbreTotalNoms = 0;
15
	private $noms = array();
11
	private $noms = array();
16
 
12
 
17
	public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd) {
-
 
18
		$this->ressources = $ressources;
-
 
19
		$this->parametres = $parametres;
-
 
20
		$this->bdd = $bdd;
-
 
21
	}
13
	public function __construct(Ressources $ressources, Parametres $parametres, NomDAO $nomDao, NomFormateur $nomFormateur) {
22
 
-
 
23
	public function setProjet($projet) {
-
 
24
		$this->projet = $projet;
-
 
25
	}
-
 
26
 
-
 
27
	public function setVersions($versions) {
-
 
28
		$this->versions = $versions;
-
 
29
	}
14
		$this->ressources = $ressources;
30
 
-
 
31
public function setChampsProjet($champsProjet) {
-
 
32
		$this->champsProjet = $champsProjet;
-
 
33
	}
-
 
34
 
-
 
35
	public function setDetailsHrefTpl($tpl) {
-
 
36
		$this->detailsHrefTpl = $tpl;
-
 
37
	}
-
 
38
 
15
		$this->parametres = $parametres;
Line 39... Line 16...
39
	public function setOntologieHrefTpl($tpl) {
16
		$this->nomDao = $nomDao;
40
		$this->ontologieHrefTpl = $tpl;
17
		$this->nomFormateur = $nomFormateur;
41
	}
18
	}
Line 42... Line 19...
42
 
19
 
43
	public function setListeUrl($url) {
20
	public function setListeUrl($url) {
44
		$this->listeUrl = $url;
21
		$this->listeUrl = $url;
45
	}
22
	}
46
 
23
 
47
	public function consulter() {
24
	public function consulter() {
48
		$this->noms = $this->rechercher();
25
		$this->noms = $this->rechercher();
Line 49... Line -...
49
		$this->nbreNomsTotal = $this->recupererNombreNomsTotal();
-
 
50
		$this->trierNoms();
-
 
51
		$retour = $this->construireTableauRetour();
-
 
52
		return $retour;
-
 
Line 53... Line 26...
53
	}
26
		$this->nbreNomsTotal = $this->nomDao->recupererNombreNomsTotal();
54
 
27
		$this->trierNoms();
55
	private function getTable() {
28
		$retour = $this->construireTableauRetour();
Line 56... Line 29...
56
		$versions = $this->versions->getVersions();
29
		return $retour;
57
		return $this->projet.'_v'.end($versions);
30
	}
58
	}
31
 
59
 
32
 
60
	private function rechercher() {
33
	private function rechercher() {
61
		$resultats = array();
34
		$resultats = array();
62
		$recherche = $this->parametres->get('recherche');
35
		$recherche = $this->parametres->get('recherche');
Line 63... Line 36...
63
 
36
 
64
		if ($recherche == 'stricte') {
37
		if ($recherche == 'stricte') {
Line 65... Line -...
65
			$resultats = $this->rechercherStricte();
-
 
66
		} else if ($recherche == 'etendue') {
-
 
67
			$resultats = $this->rechercherEtendue();
-
 
68
		} else if ($recherche == 'floue') {
-
 
69
			$resultats = $this->rechercherFloue();
-
 
70
		}
-
 
71
 
-
 
72
		return $resultats;
-
 
73
	}
-
 
74
 
-
 
75
	private function rechercherStricte() {
-
 
76
		$table = $this->getTable();
-
 
77
		$conditions = array();
-
 
78
		if ($masque = $this->parametres->getMasquePourBdd()) {
-
 
79
			$conditions[] = "ns.nom_sci = $masque";
-
 
80
		}
-
 
81
		if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
-
 
82
			$conditions[] = "ns.nom_supra_generique = $masqueSg";
-
 
83
		}
-
 
84
		if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
-
 
85
			$conditions[] = "ns.genre = $masqueGen";
-
 
86
		}
-
 
87
		if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
-
 
88
			$conditions[] = "ns.epithete_sp = $masqueSp";
-
 
89
		}
-
 
90
 
-
 
91
		$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*,  '.
-
 
92
					'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
-
 
93
					"FROM $table AS ns ".
-
 
94
					"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
-
 
95
					"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
-
 
96
					(count($conditions) > 0 ? 'WHERE ' : '').
-
 
97
					implode(' AND ', $conditions).
-
 
98
					'ORDER BY ns.nom_sci ASC '.
-
 
99
					'LIMIT 0,100';
-
 
100
		$resultats = $this->bdd->recupererTous($requete);
-
 
101
 
-
 
102
		return $resultats;
-
 
103
	}
-
 
104
 
-
 
105
	private function rechercherEtendue() {
-
 
106
		$table = $this->getTable();
-
 
107
		$conditions = array();
-
 
108
		if ($masque = $this->parametres->getMasquePourBdd()) {
-
 
109
			$conditions[] = "ns.nom_sci LIKE $masque";
-
 
110
		}
-
 
111
		if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
-
 
112
			$conditions[] = "ns.nom_supra_generique LIKE $masqueSg";
-
 
113
		}
-
 
114
		if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
-
 
115
			$conditions[] = "ns.genre LIKE $masqueGen";
-
 
116
		}
-
 
117
		if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
-
 
118
			$conditions[] = "ns.epithete_sp LIKE $masqueSp";
-
 
119
		}
-
 
120
		$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*,  '.
-
 
121
			'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
-
 
122
			"FROM $table AS ns ".
-
 
123
			"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
-
 
124
			"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
-
 
125
			(count($conditions) > 0 ? 'WHERE ' : '').
-
 
126
			implode(' AND ', $conditions).
-
 
127
			'ORDER BY ns.nom_sci ASC '.
-
 
128
			'LIMIT 0,100';
-
 
129
 
-
 
130
		$resultats = $this->bdd->recupererTous($requete);
-
 
131
		return $resultats;
-
 
132
	}
-
 
133
 
-
 
134
	private function rechercherFloue() {
-
 
135
		$table = $this->getTable();
-
 
136
		$masque = $this->parametres->getMasquePourBdd();
-
 
137
		$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*,  '.
-
 
138
			'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
-
 
139
			"FROM $table AS ns ".
-
 
140
			"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
-
 
141
			"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
-
 
142
			($masque ? 'WHERE '.
-
 
143
				"	(SOUNDEX(ns.nom_sci) = SOUNDEX($masque)) ".
-
 
144
				"	OR (SOUNDEX(REVERSE(ns.nom_sci)) = SOUNDEX(REVERSE($masque))) " : '').
-
 
145
			'ORDER BY ns.nom_sci ASC '.
-
 
146
			'LIMIT 0,100';
-
 
147
		$resultats = $this->bdd->recupererTous($requete);
38
			$resultats = $this->nomDao->rechercherStricte();
148
		return $resultats;
39
		} else if ($recherche == 'etendue') {
149
	}
40
			$resultats = $this->nomDao->rechercherEtendue();
150
 
41
		} else if ($recherche == 'floue') {
151
	private function recupererNombreNomsTotal() {
42
			$resultats = $this->nomDao->rechercherFloue();
Line 194... Line 85...
194
		return $nomsFormates;
85
		return $nomsFormates;
195
	}
86
	}
Line 196... Line 87...
196
 
87
 
197
	private function formaterNom($infos) {
88
	private function formaterNom($infos) {
198
		$nomAFormater = new NomDO($infos);
89
		$nomAFormater = new NomDO($infos);
199
		$formateur = new NomFormateur($nomAFormater);
-
 
200
		$formateur->setBdd($this->bdd);
-
 
201
		$formateur->setDetailsHrefTpl($this->detailsHrefTpl);
90
		$this->nomFormateur->setNomAFormater($nomAFormater);
202
		$formateur->setChampsRetour($this->parametres->getListe('retour.champs'));
91
		$this->nomFormateur->setChampsRetour($this->parametres->getListe('retour.champs'));
203
		$nom = $formateur->formaterListe();
92
		$nom = $this->nomFormateur->formaterListe();
204
		return $nom;
93
		return $nom;
Line 205... Line 94...
205
	}
94
	}
206
 
95