Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 215 Rev 216
Line 8... Line 8...
8
		$this->parametres = $parametres;
8
		$this->parametres = $parametres;
9
		$this->bdd = $bdd;
9
		$this->bdd = $bdd;
10
		$this->versions = $versions;
10
		$this->versions = $versions;
11
	}
11
	}
Line 12... Line -...
12
 
-
 
13
	private function getTable() {
-
 
14
		$versions = $this->versions->getVersions();
-
 
15
		$derniereVersion = end($versions);
-
 
16
		$projetNom = strtolower($this->ressources->getProjetNom());
-
 
17
		return $projetNom.'_v'.$derniereVersion;
-
 
18
	}
-
 
19
 
12
 
20
	public function rechercherInfosNom() {
13
	public function rechercherInfosNom() {
21
		$table = $this->getTable();
14
		$table = $this->getTable();
22
		$detailsId = $this->ressources->getDetailsId();
15
		$detailsId = $this->ressources->getDetailsId();
23
		$detailsId = $this->bdd->proteger($detailsId);
16
		$detailsId = $this->bdd->proteger($detailsId);
Line 31... Line 24...
31
		$resultats = $this->bdd->recuperer($requete);
24
		$resultats = $this->bdd->recuperer($requete);
32
		$nom = new NomDO($resultats);
25
		$nom = new NomDO($resultats);
33
		return $nom;
26
		return $nom;
34
	}
27
	}
Line 35... Line 28...
35
 
28
 
36
	public function rechercherStricte() {
29
	public function rechercher() {
37
		$table = $this->getTable();
30
		$table = $this->getTable();
38
		$conditions = array();
31
		$conditions = $this->getConditions();
39
		if ($masque = $this->parametres->getMasquePourBdd()) {
-
 
40
			$conditions[] = "ns.nom_sci = $masque";
-
 
41
		}
-
 
42
		if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
-
 
43
			$conditions[] = "ns.nom_supra_generique = $masqueSg";
-
 
44
		}
-
 
45
		if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
-
 
46
			$conditions[] = "ns.genre = $masqueGen";
-
 
47
		}
-
 
48
		if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
-
 
49
			$conditions[] = "ns.epithete_sp = $masqueSp";
-
 
50
		}
32
		$where = $this->getWhere($conditions);
51
		$navigation = $this->getNavigation();
-
 
52
		$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*,  '.
-
 
53
			'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
-
 
54
			"FROM $table AS ns ".
-
 
55
			"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
-
 
56
			"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
-
 
57
			$this->getWhere($conditions).
-
 
58
			implode(' AND ', $conditions).
-
 
59
			'ORDER BY ns.nom_sci ASC '.
-
 
60
			"LIMIT $navigation ";
-
 
61
 
-
 
62
		$resultats = $this->bdd->recupererTous($requete);
-
 
63
 
-
 
64
		return $resultats;
-
 
Line 65... Line -...
65
	}
-
 
66
 
-
 
67
	public function rechercherEtendue() {
-
 
68
		$table = $this->getTable();
-
 
69
		$conditions = array();
-
 
70
		if ($masque = $this->parametres->getMasquePourBdd()) {
-
 
71
			$conditions[] = "ns.nom_sci LIKE $masque";
-
 
72
		}
-
 
73
		if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
-
 
74
			$conditions[] = "ns.nom_supra_generique LIKE $masqueSg";
-
 
75
		}
-
 
76
		if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
-
 
77
			$conditions[] = "ns.genre LIKE $masqueGen";
-
 
78
		}
-
 
79
		if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
-
 
80
			$conditions[] = "ns.epithete_sp LIKE $masqueSp";
-
 
81
		}
33
		$navigation = $this->getNavigation();
82
		$navigation = $this->getNavigation();
34
 
83
		$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*,  '.
35
		$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*,  '.
84
			'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
36
			'	nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
85
			"FROM $table AS ns ".
37
			"FROM $table AS ns ".
86
			"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
38
			"	LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
87
			"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
-
 
88
			$this->getWhere($conditions).
39
			"	LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
89
			implode(' AND ', $conditions).
40
			$where.$conditions.
Line 90... Line 41...
90
			'ORDER BY ns.nom_sci ASC '.
41
			'ORDER BY ns.nom_sci ASC '.
-
 
42
			"LIMIT $navigation ";
91
			"LIMIT $navigation ";
43
 
92
 
44
		$resultats = $this->bdd->recupererTous($requete);
Line 93... Line 45...
93
		$resultats = $this->bdd->recupererTous($requete);
45
 
94
		return $resultats;
46
		return $resultats;
Line 112... Line 64...
112
			"LIMIT $navigation ";
64
			"LIMIT $navigation ";
113
		$resultats = $this->bdd->recupererTous($requete);
65
		$resultats = $this->bdd->recupererTous($requete);
114
		return $resultats;
66
		return $resultats;
115
	}
67
	}
Line -... Line 68...
-
 
68
 
-
 
69
	private function getTable() {
-
 
70
		$versions = $this->versions->getVersions();
-
 
71
		$derniereVersion = end($versions);
-
 
72
		$projetNom = strtolower($this->ressources->getProjetNom());
-
 
73
		return $projetNom.'_v'.$derniereVersion;
-
 
74
	}
116
 
75
 
-
 
76
	private function getConditions() {
-
 
77
		$masquesStrictes = array('nn', 'rg');
-
 
78
		$paramsMasque = array(
-
 
79
			'' => 'nom_sci',
-
 
80
			'nn' => 'num_nom',
-
 
81
			'rg' => 'rang',
-
 
82
			'sg' => 'nom_supra_generique',
-
 
83
			'gen' => 'genre',
-
 
84
			'sp' => 'epithete_sp',
-
 
85
			'ssp' => 'epithete_infra_sp',
-
 
86
			'au' => 'auteur',
-
 
87
			'an' => 'annee');
-
 
88
 
-
 
89
		$operateurParDefaut = $this->getOperateurCondition();
-
 
90
		$conditionsSql = array();
-
 
91
		foreach ($paramsMasque as $typeMasque => $champ) {
117
	private function getNavigation() {
92
			$operateur = in_array($typeMasque, $masquesStrictes) ? '=' : $operateurParDefaut;
-
 
93
			if ($valeurMasque = $this->parametres->getMasquePourBdd($typeMasque)) {
-
 
94
				$conditionsSql[] = "ns.$champ $operateur $valeurMasque";
-
 
95
			}
-
 
96
		}
-
 
97
		return implode(' AND ', $conditionsSql);
-
 
98
	}
-
 
99
 
-
 
100
	private function getOperateurCondition() {
118
		$debut = (int) $this->parametres->get('navigation.depart');
101
		$operateur = '';
-
 
102
		$recherche = $this->parametres->get('recherche');
-
 
103
		if ($recherche == 'stricte') {
-
 
104
			$operateur = '=';
119
		$nbre = $this->parametres->get('navigation.limite');
105
		} else if ($recherche == 'etendue') {
-
 
106
			$operateur = 'LIKE';
120
		$navigation = "$debut,$nbre";
107
		}
121
		return $navigation;
108
		return $operateur;
Line 122... Line 109...
122
	}
109
	}
123
 
110
 
124
	private function getWhere($conditions = array()) {
111
	private function getWhere($conditions = '') {
125
		$where = '';
112
		$where = '';
126
		if ($this->ressources->getServiceNom() == 'taxons') {
113
		if ($this->ressources->getServiceNom() == 'taxons') {
127
			$where = 'WHERE ns.num_nom = ns.num_nom_retenu ';
114
			$where = 'WHERE ns.num_nom = ns.num_nom_retenu ';
128
		} else if (count($conditions) > 0) {
115
		} else if ($conditions != '') {
129
			$where = 'WHERE ';
116
			$where = 'WHERE ';
130
		}
117
		}
Line -... Line 118...
-
 
118
		return $where;
-
 
119
	}
-
 
120
 
-
 
121
	private function getNavigation() {
-
 
122
		$debut = (int) $this->parametres->get('navigation.depart');
-
 
123
		$nbre = $this->parametres->get('navigation.limite');
-
 
124
		$navigation = "$debut,$nbre";
131
		return $where;
125
		return $navigation;
132
	}
126
	}
133
 
127
 
134
	public function recupererNombreNomsTotal() {
128
	public function recupererNombreNomsTotal() {
135
		$requete = 'SELECT FOUND_ROWS() AS nbre';
129
		$requete = 'SELECT FOUND_ROWS() AS nbre';