Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 109 Rev 132
1
<?php
1
<?php
2
/**
2
/**
3
* Description :
3
* Description :
4
* Classe NomsVernaculaires.php fournit une liste de noms vernaculaires et leur liaison à la bdtfx
4
* Classe NomsVernaculaires.php fournit une liste de noms vernaculaires et leur liaison à la bdtfx
5
* Le but étant de fournir un ensemble minimal d'information comprenant :
5
* Le but étant de fournir un ensemble minimal d'information comprenant :
6
* un identifiant (numérique ou alphanumérique sous forme de ChatMot si possible), un nom, une langue et
6
* un identifiant (numérique ou alphanumérique sous forme de ChatMot si possible), un nom, une langue et
7
* une relation avec un taxon de la bdtfx.
7
* une relation avec un taxon de la bdtfx.
8
* Si l'url finit par /noms-vernaculaires on retourne une liste de noms (seulement les 100 premières par défaut).
8
* Si l'url finit par /noms-vernaculaires on retourne une liste de noms (seulement les 100 premières par défaut).
9
* L'url peut contenir des paramètres optionnels passés après le ? : /observations?param1=val1&param2=val2&...
9
* L'url peut contenir des paramètres optionnels passés après le ? : /observations?param1=val1&param2=val2&...
10
*
10
*
11
* Les paramètres de requête disponibles sont : masque, masque.code, masque.nom, masque.region , recherche,
11
* Les paramètres de requête disponibles sont : masque, masque.code, masque.nom, masque.region , recherche,
12
* distinct, retour.format, navigation.depart et navigation.limite.
12
* distinct, retour.format, navigation.depart et navigation.limite.
13
*
13
*
14
* Encodage en entrée : utf8
14
* Encodage en entrée : utf8
15
* Encodage en sortie : utf8
15
* Encodage en sortie : utf8
16
* @package framework-v3
16
* @package framework-v3
17
* @author Delphine Cauquil <delphine@tela-botanica.org>
17
* @author Delphine Cauquil <delphine@tela-botanica.org>
18
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
18
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
19
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
19
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
20
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
20
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
21
* @version 1.0
21
* @version 1.0
22
* @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
22
* @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
23
*/
23
*/
24
class NomsVernaculaires extends Commun {
24
class NomsVernaculaires extends Commun {
25
	protected $champ_infos = array(
25
	protected $champ_infos = array(
26
			'taxon' => array('service' => 'taxons', 'ressource' => 'nt:', 'projet' => 'bdtfx', 'nom' => 'nom_sci'),
26
			'taxon' => array('service' => 'taxons', 'ressource' => 'nt:', 'projet' => 'bdtfx', 'nom' => 'nom_sci'),
27
			'conseil_emploi' => array('service' => 'ontologies', 'ressource' => 'numStatut:', 'projet' => 'nvjfl', 'nom' => 'nom'),
27
			'conseil_emploi' => array('service' => 'ontologies', 'ressource' => 'numStatut:', 'projet' => 'nvjfl', 'nom' => 'nom'),
28
			'genre' => array('service' => 'ontologies', 'ressource' => 'genreNombre:', 'projet' => 'nvjfl', 'nom' => 'nom'));
28
			'genre' => array('service' => 'ontologies', 'ressource' => 'genreNombre:', 'projet' => 'nvjfl', 'nom' => 'nom'));
29
 
29
 
30
	protected $service = 'noms-vernaculaires';
30
	protected $service = 'noms-vernaculaires';
31
 
31
 
32
	/**
32
	/**
33
	 * Permet de stocker la requete formulée : /noms-vernaculaires | /noms-vernaculaires/#id |
33
	 * Permet de stocker la requete formulée : /noms-vernaculaires | /noms-vernaculaires/#id |
34
	 *  /noms-vernaculaires/#id/champ | /noms-vernaculaires/#id/relations
34
	 *  /noms-vernaculaires/#id/champ | /noms-vernaculaires/#id/relations
35
	 * Est remplit au cours de l'analyse des ressources (traiterRessources()), par défaut, a la valeur du service.
35
	 * Est remplit au cours de l'analyse des ressources (traiterRessources()), par défaut, a la valeur du service.
36
	 * Est utilisée principalement pr déterminer le format du tableau à retourner.	 */
36
	 * Est utilisée principalement pr déterminer le format du tableau à retourner.	 */
37
	protected $format_reponse = 'noms-vernaculaires';
37
	protected $format_reponse = 'noms-vernaculaires';
38
 
38
 
39
	/** Variables constituant les parametres de la requete SQL (champ, condition, limit) remplie
39
	/** Variables constituant les parametres de la requete SQL (champ, condition, limit) remplie
40
	 * selon ressources et paramètres */
40
	 * selon ressources et paramètres */
41
	protected $requete_champ = array(' * ');
41
	protected $requete_champ = array(' * ');
42
	protected $requete_condition = '';
42
	protected $requete_condition = '';
43
	protected $limite_requete = array(
43
	protected $limite_requete = array(
44
		'depart' => 0,
44
		'depart' => 0,
45
		'limite' => 100
45
		'limite' => 100
46
	);
46
	);
47
 
47
 
48
	/**
48
	/**
49
	 * Precise la contenance plus ou moins précise du tableau à retourner :
49
	 * Precise la contenance plus ou moins précise du tableau à retourner :
50
	 *  - min = les données présentes dans la table
50
	 *  - min = les données présentes dans la table
51
	 *  - max = les données de la table + les informations complémentaires (pour les identifiants et les codes)
51
	 *  - max = les données de la table + les informations complémentaires (pour les identifiants et les codes)
52
	 *  - oss = la liste des nom_sci (uniquement pour noms et taxons) */
52
	 *  - oss = la liste des nom_sci (uniquement pour noms et taxons) */
53
	protected $retour_format = 'max';
53
	protected $retour_format = 'max';
54
	/** Valeur du paramètre de requete recherche :
54
	/** Valeur du paramètre de requete recherche :
55
	 *  - stricte : le masque est passé tel quel à l'opérateur LIKE.
55
	 *  - stricte : le masque est passé tel quel à l'opérateur LIKE.
56
	 *  - etendue : ajout automatique du signe % à la place des espaces et en fin de masque avec utilisation de LIKE.
56
	 *  - etendue : ajout automatique du signe % à la place des espaces et en fin de masque avec utilisation de LIKE.
57
	 *  - floue : recherche tolérante vis-à-vis d'approximations ou d'erreurs (fautes d'orthographe par exemple) */
57
	 *  - floue : recherche tolérante vis-à-vis d'approximations ou d'erreurs (fautes d'orthographe par exemple) */
58
	protected $recherche;
58
	protected $recherche;
59
 
59
 
60
	/** Permet de stocker le tableau de résultat (non encodé en json) */
60
	/** Permet de stocker le tableau de résultat (non encodé en json) */
61
	protected $table_retour = array();
61
	protected $table_retour = array();
62
	/** Stocke le nombre total de résultats de la requete principale. Est calculée lors de l'assemblage de la requete */
62
	/** Stocke le nombre total de résultats de la requete principale. Est calculée lors de l'assemblage de la requete */
63
	protected $total_resultat;
63
	protected $total_resultat;
64
 
64
 
65
	//+------------------------------------------------------------------------------------------------------+
65
	//+------------------------------------------------------------------------------------------------------+
66
	// créer une condition en fonction du paramétre
66
	// créer une condition en fonction du paramétre
67
	public function traiterParametres() {
67
	public function traiterParametres() {
68
		if (isset($this->parametres) && !empty($this->parametres)) {
68
		if (isset($this->parametres) && !empty($this->parametres)) {
69
 
69
 
70
			if (isset($this->parametres['recherche']) && $this->parametres['recherche'] != '') {
70
			if (isset($this->parametres['recherche']) && $this->parametres['recherche'] != '') {
71
				$this->recherche = $this->parametres['recherche'];
71
				$this->recherche = $this->parametres['recherche'];
72
			}
72
			}
73
			foreach ($this->parametres as $param => $valeur) {
73
			foreach ($this->parametres as $param => $valeur) {
74
				switch ($param) {
74
				switch ($param) {
75
					case 'masque' :
75
					case 'masque' :
76
						$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
76
						$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
77
						break;
77
						break;
78
					case 'masque.nt' :
78
					case 'masque.nt' :
79
						$this->ajouterLeFiltreMasque('num_taxon', $valeur);
79
						$this->ajouterLeFiltreMasque('num_taxon', $valeur);
80
						break;
80
						break;
81
					case 'masque.nv' :
81
					case 'masque.nv' :
82
						$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
82
						$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
83
						break;
83
						break;
84
					case 'masque.lg' :
84
					case 'masque.lg' :
85
						$this->ajouterLeFiltreMasque('code_langue', $valeur);
85
						$this->ajouterLeFiltreMasque('code_langue', $valeur);
86
						break;
86
						break;
87
					case 'masque.cce' :
87
					case 'masque.cce' :
88
						$this->ajouterLeFiltreMasque('num_statut', $valeur);
88
						$this->ajouterLeFiltreMasque('num_statut', $valeur);
89
						break;
89
						break;
90
					case 'retour.format' :
90
					case 'retour.format' :
91
						$this->retour_format = $valeur;
91
						$this->retour_format = $valeur;
92
						break;
92
						break;
93
					case 'navigation.depart' :
93
					case 'navigation.depart' :
94
						$this->limite_requete['depart'] = $valeur;
94
						$this->limite_requete['depart'] = $valeur;
95
						break;
95
						break;
96
					case 'navigation.limite' :
96
					case 'navigation.limite' :
97
						$this->limite_requete['limite'] = $valeur;
97
						$this->limite_requete['limite'] = $valeur;
98
						break;
98
						break;
99
					case 'recherche' :
99
					case 'recherche' :
100
						break;
100
						break;
101
					default :
101
					default :
102
						$p = 'Erreur dans les paramètres de recherche de votre requête : '.
102
						$p = 'Erreur dans les paramètres de recherche de votre requête : '.
103
							'</br> Le paramètre " '.$param.' " n\'existe pas.';
103
							'</br> Le paramètre " '.$param.' " n\'existe pas.';
104
							$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $p);
104
							$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $p);
105
				}
105
				}
106
			}
106
			}
107
		}
107
		}
108
	}
108
	}
109
 
109
 
110
	public function ajouterLeFiltreMasque($nom_champ, $valeur) {
110
	public function ajouterLeFiltreMasque($nom_champ, $valeur) {
111
		if ($nom_champ == 'num_taxon') { // si il s'agit d'un chiffre
111
		if ($nom_champ == 'num_taxon') { // si il s'agit d'un chiffre
112
			$this->requete_condition[] = $nom_champ.' = '.$this->getBdd()->proteger($valeur);
112
			$this->requete_condition[] = $nom_champ.' = '.$this->getBdd()->proteger($valeur);
113
		} else {
113
		} else {
114
			if ($this->recherche == 'floue') {
114
			if ($this->recherche == 'floue') {
115
				$this->requete_condition[] = '(SOUNDEX('.$nom_champ.') = SOUNDEX(\''.$valeur.'\')'
115
				$this->requete_condition[] = '(SOUNDEX('.$nom_champ.') = SOUNDEX(\''.$valeur.'\')'
116
					.' OR SOUNDEX(REVERSE('.$nom_champ.')) = SOUNDEX(REVERSE(\''.$valeur.'\'))) ';
116
					.' OR SOUNDEX(REVERSE('.$nom_champ.')) = SOUNDEX(REVERSE(\''.$valeur.'\'))) ';
117
			} else {
117
			} else {
118
				if ($this->recherche == 'etendue') {
118
				if ($this->recherche == 'etendue') {
119
					$valeur = str_replace(' ','%', $valeur);
119
					$valeur = str_replace(' ','%', $valeur);
120
					$valeur .= '%';
120
					$valeur .= '%';
121
				}
121
				}
122
				$this->requete_condition[] = $nom_champ.' LIKE '.$this->getBdd()->proteger($valeur);
122
				$this->requete_condition[] = $nom_champ.' LIKE '.$this->getBdd()->proteger($valeur);
123
			}
123
			}
124
		}
124
		}
125
	}
125
	}
126
 
126
 
127
	//+------------------------------------------------------------------------------------------------------+
127
	//+------------------------------------------------------------------------------------------------------+
128
	// en fonction de la présence des ressources modifie requete_champ et requete_condition
128
	// en fonction de la présence des ressources modifie requete_champ et requete_condition
129
	public function traiterRessources() {
129
	public function traiterRessources() {
130
		if (isset($this->ressources) && !empty($this->ressources)) {
130
		if (isset($this->ressources) && !empty($this->ressources)) {
131
			if (isset($this->ressources[0]) && !empty($this->ressources[0])) {
131
			if (isset($this->ressources[0]) && !empty($this->ressources[0])) {
132
				$this->traiterRessourceId(); // ajoute condition id=#valeur
132
				$this->traiterRessourceId(); // ajoute condition id=#valeur
133
				if (isset($this->ressources[1]) && !empty($this->ressources[1])) {
133
				if (isset($this->ressources[1]) && !empty($this->ressources[1])) {
134
					$this->traiterRessourceChampOuRelations(); //modifie requete_champ ou requete_condition
134
					$this->traiterRessourceChampOuRelations(); //modifie requete_champ ou requete_condition
135
				}
135
				}
136
			}
136
			}
137
		} else { //rajoute distinct pour ne pas avoir plusieurs fois le même nom
137
		} else { //rajoute distinct pour ne pas avoir plusieurs fois le même nom
138
			$this->requete_champ = array('distinct(id)', 'nom_vernaculaire ');
138
			$this->requete_champ = array('distinct(id)', 'nom_vernaculaire ');
139
		}
139
		}
140
	}
140
	}
141
 
141
 
142
	//requete : /noms-vernaculaires/#id (ex : /noms-vernaculaires/7)
142
	//requete : /noms-vernaculaires/#id (ex : /noms-vernaculaires/7)
143
	public function traiterRessourceId() {
143
	public function traiterRessourceId() {
144
		if (is_numeric($this->ressources[0])) {
144
		if (is_numeric($this->ressources[0])) {
145
			$this->requete_condition[] = ' id = '.$this->getBdd()->proteger($this->ressources[0]);
145
			$this->requete_condition[] = ' id = '.$this->getBdd()->proteger($this->ressources[0]);
146
			$this->format_reponse .= '/id';
146
			$this->format_reponse .= '/id';
147
		} else {
147
		} else {
148
			$r = 'Erreur dans les ressources de votre requête : </br> La ressource " '.$this->ressources[0].
148
			$r = 'Erreur dans les ressources de votre requête : </br> La ressource " '.$this->ressources[0].
149
				' " n\'existe pas.';
149
				' " n\'existe pas.';
150
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $r);
150
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $r);
151
		}
151
		}
152
	}
152
	}
153
 
153
 
154
 
154
 
155
	public function traiterRessourceChampOuRelations() {
155
	public function traiterRessourceChampOuRelations() {
156
		//requete = /noms-vernaculaires/#id/relations :
156
		//requete = /noms-vernaculaires/#id/relations :
157
		if ($this->ressources[1] == 'relations') {
157
		if ($this->ressources[1] == 'relations') {
158
			$this->format_reponse .= '/relations';
158
			$this->format_reponse .= '/relations';
159
			$this->requete_condition[] = 'num_taxon = (SELECT region FROM '.$this->table.' WHERE '
159
			$this->requete_condition[] = 'num_taxon = (SELECT region FROM '.$this->table.' WHERE '
160
										.implode(' AND ', $this->requete_condition).')';
160
										.implode(' AND ', $this->requete_condition).')';
161
		//requete = /noms-vernaculaires/#id/#champ :
161
		//requete = /noms-vernaculaires/#id/#champ :
162
		} else {
162
		} else {
163
			$this->format_reponse .= '/champ';
163
			$this->format_reponse .= '/champ';
164
			$this->analyserChamp();
164
			$this->analyserChamp();
165
		}
165
		}
166
	}
166
	}
167
 
167
 
168
	public function analyserChamp() {
168
	public function analyserChamp() {
169
		$this->requete_champ = array();
169
		$this->requete_champ = array();
170
		$this->recupererTableConfig('champs_possibles');// s'il y a plusieurs champs correspondant au champ demandé ils sont séparé par des |
170
		$this->recupererTableConfig('champs_possibles');// s'il y a plusieurs champs correspondant au champ demandé ils sont séparé par des |
171
		$champs = explode(' ', $this->ressources[1]);
171
		$champs = explode(' ', $this->ressources[1]);
172
		foreach ($champs as $champ) {
172
		foreach ($champs as $champ) {
173
			preg_match('/^([^.]+)(\.([^.]+))?$/', $champ, $match);
173
			preg_match('/^([^.]+)(\.([^.]+))?$/', $champ, $match);
174
			if (isset($this->champs_possibles[$match[1]])) {
174
			if (isset($this->champs_possibles[$match[1]])) {
175
				$this->requete_champ[] = str_replace('|', ', ', $this->champs_possibles[$match[1]]);
175
				$this->requete_champ[] = str_replace('|', ', ', $this->champs_possibles[$match[1]]);
176
			} elseif (isset($this->champs_possibles[$match[0]])) {
176
			} elseif (isset($this->champs_possibles[$match[0]])) {
177
				$this->requete_champ[] = str_replace('|', ', ', $this->champs_possibles[$match[0]]);
177
				$this->requete_champ[] = str_replace('|', ', ', $this->champs_possibles[$match[0]]);
178
			} else {
178
			} else {
179
				$champs_possibles = implode('</li><li>', array_keys($this->champs_possibles));
179
				$champs_possibles = implode('</li><li>', array_keys($this->champs_possibles));
180
				$c = 'Erreur dans votre requête : </br> Le champ "'.$champ_possibles.'" n\'existe pas. '.
180
				$c = 'Erreur dans votre requête : </br> Le champ "'.$champ_possibles.'" n\'existe pas. '.
181
					'Les champs disponibles sont : <li>'.$champs_possibles.'</li> et leurs déclinaisons (ex. ".code").';
181
					'Les champs disponibles sont : <li>'.$champs_possibles.'</li> et leurs déclinaisons (ex. ".code").';
182
				$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $c);
182
				$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $c);
183
			}
183
			}
184
		}
184
		}
185
	}
185
	}
186
 
186
 
187
	//+------------------------------------------------------------------------------------------------------+
187
	//+------------------------------------------------------------------------------------------------------+
188
	public function assemblerLaRequete() {
188
	public function assemblerLaRequete() {
189
		$requete = ' SELECT '.$this->formerRequeteChamp().
189
		$requete = ' SELECT '.$this->formerRequeteChamp().
190
					' FROM '.$this->table
190
					' FROM '.$this->table
191
					.$this->formerRequeteCondition()
191
					.$this->formerRequeteCondition()
192
					.$this->formerRequeteLimite();
192
					.$this->formerRequeteLimite();
193
		return $requete;
193
		return $requete;
194
	}
194
	}
195
 
195
 
196
	public  function formerRequeteChamp() {
196
	public  function formerRequeteChamp() {
197
		if (in_array('*', $this->requete_champ)) {
197
		if (in_array('*', $this->requete_champ)) {
198
			$champ = ' * ';
198
			$champ = ' * ';
199
		} else {
199
		} else {
200
			$champ = implode(', ', $this->requete_champ);
200
			$champ = implode(', ', $this->requete_champ);
201
		}
201
		}
202
		return $champ;
202
		return $champ;
203
	}
203
	}
204
 
204
 
205
	public  function formerRequeteCondition() {
205
	public  function formerRequeteCondition() {
206
		$condition = '';
206
		$condition = '';
207
		if ($this->requete_condition != null) {
207
		if ($this->requete_condition != null) {
208
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
208
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
209
		}
209
		}
210
		return $condition;
210
		return $condition;
211
	}
211
	}
212
 
212
 
213
	//ajout d'une limite seulement pour les listes (pas plus de 100 resultats retournés pr les requetes
213
	//ajout d'une limite seulement pour les listes (pas plus de 100 resultats retournés pr les requetes
214
	// suivantes : /noms-vernaculaires et /noms-vernaculaires/#id/relations)
214
	// suivantes : /noms-vernaculaires et /noms-vernaculaires/#id/relations)
215
	public function formerRequeteLimite() {
215
	public function formerRequeteLimite() {
216
		if (in_array($this->format_reponse , array($this->service.'/id', $this->service.'/id/champs'))) {
216
		if (in_array($this->format_reponse , array($this->service.'/id', $this->service.'/id/champs'))) {
217
			$this->requete_limite = '';
217
			$this->requete_limite = '';
218
		} elseif (($depart = $this->limite_requete['depart']) > ($this->total_resultat = $this->recupererTotalResultat())) {
218
		} elseif (($depart = $this->limite_requete['depart']) > ($this->total_resultat = $this->recupererTotalResultat())) {
219
			$this->limite_requete['depart'] =
219
			$this->limite_requete['depart'] =
220
				(($this->total_resultat - $this->limite_requete['limite']) < 0) ? 0 : ($this->total_resultat - $this->limite_requete['limite']);
220
				(($this->total_resultat - $this->limite_requete['limite']) < 0) ? 0 : ($this->total_resultat - $this->limite_requete['limite']);
221
			$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
221
			$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
222
		} else {
222
		} else {
223
			$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
223
			$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
224
		}
224
		}
225
		return $this->requete_limite;
225
		return $this->requete_limite;
226
	}
226
	}
227
 
227
 
228
	//on récupère le nombre total de résultats de la requete (ex : le nombre d'id contenu dans la liste /noms-vernaculaires)
228
	//on récupère le nombre total de résultats de la requete (ex : le nombre d'id contenu dans la liste /noms-vernaculaires)
229
	public function recupererTotalResultat() {
229
	public function recupererTotalResultat() {
230
		$requete = 'SELECT count(distinct(id)) as nombre FROM '
230
		$requete = 'SELECT count(distinct(id)) as nombre FROM '
231
			.$this->table
231
			.$this->table
232
			.$this->formerRequeteCondition();
232
			.$this->formerRequeteCondition();
233
		$res = $this->getBdd()->recuperer($requete);
233
		$res = $this->getBdd()->recuperer($requete);
234
 
234
 
235
		if ($res) {
235
		if ($res) {
236
			$total = $res['nombre'];
236
			$total = $res['nombre'];
237
		} else {
237
		} else {
238
			$t = 'Fonction recupererTotalResultat() : <br/>Données introuvables dans la base';
238
			$t = 'Fonction recupererTotalResultat() : <br/>Données introuvables dans la base';
239
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $t);
239
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $t);
240
		}
240
		}
241
		return $total;
241
		return $total;
242
	}
242
	}
243
 
243
 
244
	//+------------------------------------------------------------------------------------------------------+
244
	//+------------------------------------------------------------------------------------------------------+
245
	// determine en fct du service appelé (/noms-vernaculaires | /noms-vernaculaires/#id | /noms-vernaculaires/#id/champ |
245
	// determine en fct du service appelé (/noms-vernaculaires | /noms-vernaculaires/#id | /noms-vernaculaires/#id/champ |
246
	// /noms-vernaculaires/#id/relations) le format du tableau à retourner.
246
	// /noms-vernaculaires/#id/relations) le format du tableau à retourner.
247
	public function retournerResultatFormate($resultat) {
247
	public function retournerResultatFormate($resultat) {
248
		$this->recupererTableConfig('correspondance_champs');
248
		$this->recupererTableConfig('correspondance_champs');
249
		switch ($this->format_reponse) {
249
		switch ($this->format_reponse) {
-
 
250
			case 'noms-vernaculaires'				: 
250
			case 'noms-vernaculaires'				: $reponse = $this->formaterNomsVernaculaires($resultat);			break;
251
				$reponse = ($this->retour_format == 'oss') ? $this->formaterEnOss($resultat) : $this->formaterNomsVernaculaires($resultat);			break;
251
			case 'noms-vernaculaires/id'			: $reponse = $this->formaterNomsVernaculairesId($resultat);			break;
252
			case 'noms-vernaculaires/id'			: $reponse = $this->formaterNomsVernaculairesId($resultat);			break;
252
			case 'noms-vernaculaires/id/champ'		: $reponse = $this->formaterNomsVernaculairesIdChamp($resultat);	break;
253
			case 'noms-vernaculaires/id/champ'		: $reponse = $this->formaterNomsVernaculairesIdChamp($resultat);	break;
253
			default									:																	break;
254
			default									:																	break;
254
		}
255
		}
255
		return $reponse;
256
		return $reponse;
256
	}
257
	}
257
 
258
 
258
	public function formaterNomsVernaculaires($resultat) {
259
	public function formaterNomsVernaculaires($resultat) {
259
		//on remplit la table $table_retour_json['entete']
260
		//on remplit la table $table_retour_json['entete']
260
		$table_retour_json['entete']['depart'] = $this->limite_requete['depart'];
261
		$table_retour_json['entete']['depart'] = $this->limite_requete['depart'];
261
		$table_retour_json['entete']['limite'] = $this->limite_requete['limite'];
262
		$table_retour_json['entete']['limite'] = $this->limite_requete['limite'];
262
		$table_retour_json['entete']['total']  = $this->total_resultat;
263
		$table_retour_json['entete']['total']  = $this->total_resultat;
263
		$url = $this->formulerUrl($this->total_resultat, '/noms-vernaculaires');
264
		$url = $this->formulerUrl($this->total_resultat, '/noms-vernaculaires');
264
		if (isset($url['precedent']) && $url['precedent'] != '') { $table_retour_json['entete']['href.precedent'] = $url['precedent']; }
265
		if (isset($url['precedent']) && $url['precedent'] != '') { $table_retour_json['entete']['href.precedent'] = $url['precedent']; }
265
		if (isset($url['suivant']) && $url['suivant']   != '') { $table_retour_json['entete']['href.suivant']   = $url['suivant']; }
266
		if (isset($url['suivant']) && $url['suivant']   != '') { $table_retour_json['entete']['href.suivant']   = $url['suivant']; }
266
 
267
 
267
		//on remplit la table $table_retour_json['resultat']
268
		//on remplit la table $table_retour_json['resultat']
268
		if (isset($this->parametres['masque_nv'])) {
269
		if (isset($this->parametres['masque_nv'])) {
269
			$resultat = $this->trierRechercheFloue($this->parametres['masque_nv'], $resultat, 'nom_vernaculaire');
270
			$resultat = $this->trierRechercheFloue($this->parametres['masque_nv'], $resultat, 'nom_vernaculaire');
270
		}
271
		}
271
		foreach ($resultat as $tab) {
272
		foreach ($resultat as $tab) {
272
			foreach ($tab as $key => $valeur) {
273
			foreach ($tab as $key => $valeur) {
273
				if ($valeur != '') {
274
				if ($valeur != '') {
274
					switch ($key) {
275
					switch ($key) {
275
						case 'id'				: $num = $valeur;								break;
276
						case 'id'				: $num = $valeur;								break;
276
						case 'nom_vernaculaire'	: $this->table_retour['nom'] = $valeur;			break;
277
						case 'nom_vernaculaire'	: $this->table_retour['nom'] = $valeur;			break;
277
						default					:												break;
278
						default					:												break;
278
					}
279
					}
279
				}
280
				}
280
			}
281
			}
281
			if ($this->retour_format == 'max') $this->table_retour['href'] = $this->ajouterHref('noms-vernaculaires', $num);
282
			if ($this->retour_format == 'max') $this->table_retour['href'] = $this->ajouterHref('noms-vernaculaires', $num);
282
			$resultat_json[$num] = $this->table_retour;
283
			$resultat_json[$num] = $this->table_retour;
283
			$this->table_retour = array();
284
			$this->table_retour = array();
284
		}
285
		}
285
 
286
 
286
		$table_retour_json['resultat'] = $resultat_json;
287
		$table_retour_json['resultat'] = $resultat_json;
287
		return $table_retour_json;
288
		return $table_retour_json;
288
	}
289
	}
-
 
290
	
-
 
291
	public function formaterEnOss($resultat) {
-
 
292
		$table_nom = array();
-
 
293
		$oss = '';
-
 
294
		foreach ($resultat as $tab) {
-
 
295
			if (isset($tab['nom_vernaculaire']) ) {
-
 
296
				if (!in_array($tab['nom_vernaculaire'], $table_nom)) {
-
 
297
					$table_nom[] = $tab['nom_vernaculaire'];
-
 
298
					$oss [] = $tab['nom_vernaculaire'];
-
 
299
				}
-
 
300
			}
-
 
301
		}
-
 
302
		if (isset($this->masque)) $masque = implode('&', $this->masque);
-
 
303
		else $masque = 'Pas de masque';
-
 
304
		$table_retour_oss = array($masque, $oss);
-
 
305
		return $table_retour_oss;
-
 
306
	}
289
 
307
 
290
	// formatage de la reponse /id ss la forme
308
	// formatage de la reponse /id ss la forme
291
	// id, nom_vernaculaire, attributions
309
	// id, nom_vernaculaire, attributions
292
	// langue
310
	// langue
293
	// num_nom (correspond à un taxon bdtfx)
311
	// num_nom (correspond à un taxon bdtfx)
294
	public function formaterNomsVernaculairesId($resultat) {
312
	public function formaterNomsVernaculairesId($resultat) {
295
		foreach ($resultat as $taxon) { // pour chaque attribution à un taxon bdtfx
313
		foreach ($resultat as $taxon) { // pour chaque attribution à un taxon bdtfx
296
			// on crée les variables qui serviront de clés et on les enléves du tableau
314
			// on crée les variables qui serviront de clés et on les enléves du tableau
297
			$num_nom = $taxon['num_nom_vernaculaire']; // unique pour un trinôme id, langue, taxon
315
			$num_nom = $taxon['num_nom_vernaculaire']; // unique pour un trinôme id, langue, taxon
298
			unset($taxon['num_nom_vernaculaire']);
316
			unset($taxon['num_nom_vernaculaire']);
299
			$langue = $taxon['code_langue'];
317
			$langue = $taxon['code_langue'];
300
			unset($taxon['code_langue']);
318
			unset($taxon['code_langue']);
301
 
319
 
302
			foreach ($this->correspondance_champs as $key => $correspondance) { // ordonne les infos pour affichage
320
			foreach ($this->correspondance_champs as $key => $correspondance) { // ordonne les infos pour affichage
303
				if (isset($taxon[$key]) && $taxon[$key] != "") {
321
				if (isset($taxon[$key]) && $taxon[$key] != "") {
304
					$this->afficherDonnees($correspondance, $taxon[$key], $langue, $num_nom);
322
					$this->afficherDonnees($correspondance, $taxon[$key], $langue, $num_nom);
305
				}
323
				}
306
			}
324
			}
307
			foreach ($taxon as $key => $valeur) { // rajoute les champs non prévus dans l'api
325
			foreach ($taxon as $key => $valeur) { // rajoute les champs non prévus dans l'api
308
				if (!isset($this->correspondance_champs[$key]) && $valeur != "") {
326
				if (!isset($this->correspondance_champs[$key]) && $valeur != "") {
309
					$this->afficherDonnees($key, $valeur, $langue, $num_nom);
327
					$this->afficherDonnees($key, $valeur, $langue, $num_nom);
310
				}
328
				}
311
			}
329
			}
312
			if ($this->retour_format == 'max') $this->chargerBiblio($num_nom, $langue);
330
			if ($this->retour_format == 'max') $this->chargerBiblio($num_nom, $langue);
313
		}
331
		}
314
		if ($this->retour_format == 'max') $this->afficherTaxons(); // va chercher les noms de tous les taxons
332
		if ($this->retour_format == 'max') $this->afficherTaxons(); // va chercher les noms de tous les taxons
315
		unset($this->table_retour['href']);
333
		unset($this->table_retour['href']);
316
		return $this->table_retour;
334
		return $this->table_retour;
317
	}
335
	}
318
 
336
 
319
	public function afficherDonnees($champ, $valeur, $langue = '', $num_nom = '') {
337
	public function afficherDonnees($champ, $valeur, $langue = '', $num_nom = '') {
320
		if ($champ == 'id' || $champ == 'nom_vernaculaire') {
338
		if ($champ == 'id' || $champ == 'nom_vernaculaire') {
321
			$this->table_retour[$champ] = $valeur;
339
			$this->table_retour[$champ] = $valeur;
322
		} elseif (preg_match('/^(.*)\.code$/', $champ, $match)) {
340
		} elseif (preg_match('/^(.*)\.code$/', $champ, $match)) {
323
				switch ($match[1]) {
341
				switch ($match[1]) {
324
					case 'taxon'	: if ($this->retour_format == 'max') {$this->taxons[$num_nom] = $valeur;}
342
					case 'taxon'	: if ($this->retour_format == 'max') {$this->taxons[$num_nom] = $valeur;}
325
						$this->afficherPointCode($match[1], $langue, $num_nom, $valeur);	break;
343
						$this->afficherPointCode($match[1], $langue, $num_nom, $valeur);	break;
326
					case 'langue'	: //$this->afficherPointCode($match[1], 'iso-639-3', 'langues', $valeur);
344
					case 'langue'	: //$this->afficherPointCode($match[1], 'iso-639-3', 'langues', $valeur);
327
						break;
345
						break;
328
					case 'genre'	: $this->afficherPointCode($match[1], $langue, $num_nom, $valeur);	break;
346
					case 'genre'	: $this->afficherPointCode($match[1], $langue, $num_nom, $valeur);	break;
329
					case 'conseil_emploi'	: $this->afficherPointCode($match[1], $langue, $num_nom, $valeur);	break;
347
					case 'conseil_emploi'	: $this->afficherPointCode($match[1], $langue, $num_nom, $valeur);	break;
330
					default : break;
348
					default : break;
331
				}
349
				}
332
 
350
 
333
		} elseif ($langue != '') {
351
		} elseif ($langue != '') {
334
			$this->table_retour['attributions'][$langue][$num_nom][$champ] = $valeur;
352
			$this->table_retour['attributions'][$langue][$num_nom][$champ] = $valeur;
335
		} else {
353
		} else {
336
			$this->table_retour[$champ] = $valeur;
354
			$this->table_retour[$champ] = $valeur;
337
		}
355
		}
338
	}
356
	}
339
 
357
 
340
	public function afficherPointCode($nomChamp, $langue, $num_nom, $valeur) {
358
	public function afficherPointCode($nomChamp, $langue, $num_nom, $valeur) {
341
		if (isset($this->champ_infos[$nomChamp])) {
359
		if (isset($this->champ_infos[$nomChamp])) {
342
			extract($this->champ_infos[$nomChamp]);
360
			extract($this->champ_infos[$nomChamp]);
343
		}
361
		}
344
 
362
 
345
		if ($this->retour_format == 'max') {
363
		if ($this->retour_format == 'max') {
346
			$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
364
			$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
347
			if ($service == 'taxons') {
365
			if ($service == 'taxons') {
348
				$code_valeur = '';
366
				$code_valeur = '';
349
			} else {
367
			} else {
350
				$code_valeur = $this->chercherSignificationCode($url, $nom);
368
				$code_valeur = $this->chercherSignificationCode($url, $nom);
351
			}
369
			}
352
			if ($projet != '') $projet .= '.';
370
			if ($projet != '') $projet .= '.';
353
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp] = $code_valeur;
371
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp] = $code_valeur;
354
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
372
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
355
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.href'] = $url;
373
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.href'] = $url;
356
		} else {
374
		} else {
357
			if ($projet != '') $projet .= '.';
375
			if ($projet != '') $projet .= '.';
358
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
376
			$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
359
		}
377
		}
360
	}
378
	}
361
 
379
 
362
	public function chercherSignificationCode($url, $nom) {
380
	public function chercherSignificationCode($url, $nom) {
363
		if (isset($this->signification_code[$url])) {
381
		if (isset($this->signification_code[$url])) {
364
			$valeur = $this->signification_code[$url];
382
			$valeur = $this->signification_code[$url];
365
		} else {
383
		} else {
366
			$res = $this->consulterHref($url);
384
			$res = $this->consulterHref($url);
367
			$valeur = $res->$nom;
385
			$valeur = $res->$nom;
368
			$this->signification_code[$url] = $valeur;
386
			$this->signification_code[$url] = $valeur;
369
		}
387
		}
370
		return $valeur;
388
		return $valeur;
371
	}
389
	}
372
 
390
 
373
	public function afficherTaxons() {
391
	public function afficherTaxons() {
374
		$url = Config::get('url_service_base').'bdtfx/taxons?navigation.limite=500&masque.nt='.$this->getBdd()->proteger(implode(',', $this->taxons));
392
		$url = Config::get('url_service_base').'bdtfx/taxons?navigation.limite=500&masque.nt='.$this->getBdd()->proteger(implode(',', $this->taxons));
375
		$res = $this->consulterHref($url);
393
		$res = $this->consulterHref($url);
376
		foreach ($res->resultat as $id=>$taxon) {
394
		foreach ($res->resultat as $id=>$taxon) {
377
			$resultat[$taxon->num_taxonomique] = $taxon->nom_sci;
395
			$resultat[$taxon->num_taxonomique] = $taxon->nom_sci;
378
		}
396
		}
379
		foreach ($this->table_retour['attributions'] as $code_langue=>$langue) {
397
		foreach ($this->table_retour['attributions'] as $code_langue=>$langue) {
380
			foreach ($langue as $num_nom=>$taxon) {
398
			foreach ($langue as $num_nom=>$taxon) {
381
				$num_tax = ltrim($taxon['taxon.code'], 'bdtfx.nt:');
399
				$num_tax = ltrim($taxon['taxon.code'], 'bdtfx.nt:');
382
				if (isset($resultat[$num_tax])) {
400
				if (isset($resultat[$num_tax])) {
383
					$this->table_retour['attributions'][$code_langue][$num_nom]['taxon'] = $resultat[$num_tax];
401
					$this->table_retour['attributions'][$code_langue][$num_nom]['taxon'] = $resultat[$num_tax];
384
				}
402
				}
385
			}
403
			}
386
		}
404
		}
387
	}
405
	}
388
 
406
 
389
	public function formaterNomsVernaculairesIdChamp($resultat) {
407
	public function formaterNomsVernaculairesIdChamp($resultat) {
390
		$this->table_retour['id'] = $this->ressources[0];
408
		$this->table_retour['id'] = $this->ressources[0];
391
		$champs = explode(' ', $this->ressources[1]);
409
		$champs = explode(' ', $this->ressources[1]);
392
		if (in_array('attributions', $champs) != false) {
410
		if (in_array('attributions', $champs) != false) {
393
			$this->formaterNomsVernaculairesId($resultat);
411
			$this->formaterNomsVernaculairesId($resultat);
394
			unset($this->table_retour['nom_vernaculaire']);
412
			unset($this->table_retour['nom_vernaculaire']);
395
		} else {//print_r($resultat);
413
		} else {//print_r($resultat);
396
			$champ_attributions = array('num_taxon', 'zone_usage', 'num_statut', 'num_genre', 'notes');
414
			$champ_attributions = array('num_taxon', 'zone_usage', 'num_statut', 'num_genre', 'notes');
397
			foreach ($resultat as $taxon) {
415
			foreach ($resultat as $taxon) {
398
				foreach ($taxon as $key=>$valeur) {
416
				foreach ($taxon as $key=>$valeur) {
399
					if ($key == 'code_langue' && in_array('langue', $champs) != false) {
417
					if ($key == 'code_langue' && in_array('langue', $champs) != false) {
400
						$this->table_retour['attributions']['langue'][] = $valeur;
418
						$this->table_retour['attributions']['langue'][] = $valeur;
401
					} elseif (in_array($key, $champ_attributions) != false) {
419
					} elseif (in_array($key, $champ_attributions) != false) {
402
						$this->afficherPoint($this->correspondance_champs[$key] , $valeur, $taxon['code_langue'], $taxon['num_nom_vernaculaire']);
420
						$this->afficherPoint($this->correspondance_champs[$key] , $valeur, $taxon['code_langue'], $taxon['num_nom_vernaculaire']);
403
					} elseif (in_array($key, $champs) != false) {
421
					} elseif (in_array($key, $champs) != false) {
404
						$this->table_retour[$key] = $valeur;
422
						$this->table_retour[$key] = $valeur;
405
					}
423
					}
406
				}
424
				}
407
				if (in_array('biblio', $champs) != false) $this->chargerBiblio($taxon['num_nom_vernaculaire'], $taxon['code_langue']);
425
				if (in_array('biblio', $champs) != false) $this->chargerBiblio($taxon['num_nom_vernaculaire'], $taxon['code_langue']);
408
			}
426
			}
409
			if (in_array('biblio', $champs) != false && array_search('biblio.num_ref', $this->table_retour) != false) $this->table_retour['biblio'] = null;
427
			if (in_array('biblio', $champs) != false && array_search('biblio.num_ref', $this->table_retour) != false) $this->table_retour['biblio'] = null;
410
		}
428
		}
411
		return $this->table_retour;
429
		return $this->table_retour;
412
	}
430
	}
413
 
431
 
414
	public function afficherPoint($champ, $valeur, $langue, $num_nom) {
432
	public function afficherPoint($champ, $valeur, $langue, $num_nom) {
415
		preg_match('/^(.*)\.code$/', $champ, $match);
433
		preg_match('/^(.*)\.code$/', $champ, $match);
416
		$champ = $match[1];
434
		$champ = $match[1];
417
		if (isset($this->champ_infos[$champ])) {
435
		if (isset($this->champ_infos[$champ])) {
418
			extract($this->champ_infos[$champ]);
436
			extract($this->champ_infos[$champ]);
419
			$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
437
			$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
420
			$projet .= '.';
438
			$projet .= '.';
421
		}
439
		}
422
 
440
 
423
		$champs = explode(' ', $this->ressources[1]);
441
		$champs = explode(' ', $this->ressources[1]);
424
		if (in_array($champ.'.*', $champs) !== false && isset($projet)) {
442
		if (in_array($champ.'.*', $champs) !== false && isset($projet)) {
425
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
443
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
426
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
444
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
427
		}
445
		}
428
		if (in_array($champ.'.code', $champs) !== false && isset($projet)) {
446
		if (in_array($champ.'.code', $champs) !== false && isset($projet)) {
429
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
447
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
430
		}
448
		}
431
		if (in_array($champ.'.href', $champs) !== false && isset($projet)) {
449
		if (in_array($champ.'.href', $champs) !== false && isset($projet)) {
432
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
450
			$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
433
		}
451
		}
434
		if (in_array($champ, $champs) !== false) {
452
		if (in_array($champ, $champs) !== false) {
435
			if (isset($url)) {
453
			if (isset($url)) {
436
				$this->table_retour['attributions'][$langue][$num_nom][$champ] = $this->chercherSignificationCode($url, $nom);
454
				$this->table_retour['attributions'][$langue][$num_nom][$champ] = $this->chercherSignificationCode($url, $nom);
437
			} else {
455
			} else {
438
				$this->table_retour['attributions'][$langue][$champ] = $valeur;
456
				$this->table_retour['attributions'][$langue][$champ] = $valeur;
439
			}
457
			}
440
		}
458
		}
441
	}
459
	}
442
 
460
 
443
	public function afficherLangue($nomChamp, $projet, $service, $valeur, $ressource = '', $nom = 'nom') {
461
	public function afficherLangue($nomChamp, $projet, $service, $valeur, $ressource = '', $nom = 'nom') {
444
		if ($this->retour_format == 'max') {
462
		if ($this->retour_format == 'max') {
445
				$this->table_retour['attributions'][$nomChamp] = $nom;
463
				$this->table_retour['attributions'][$nomChamp] = $nom;
446
				$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
464
				$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
447
				$this->table_retour['attributions'][$nomChamp.'.href'] = $url;
465
				$this->table_retour['attributions'][$nomChamp.'.href'] = $url;
448
		} else {
466
		} else {
449
			$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
467
			$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
450
		}
468
		}
451
	}
469
	}
452
 
470
 
453
	public function chargerBiblio($num_nom, $langue) {
471
	public function chargerBiblio($num_nom, $langue) {
454
		list($table, $version) = explode('_v',$this->table);
472
		list($table, $version) = explode('_v',$this->table);
455
		$requete = "SELECT b.*, lb.notes FROM nvjfl_lien_biblio_v$version lb, nvjfl_biblio_v$version b ".
473
		$requete = "SELECT b.*, lb.notes FROM nvjfl_lien_biblio_v$version lb, nvjfl_biblio_v$version b ".
456
					"WHERE b.num_ref = lb.num_ref AND lb.num_nom = '$num_nom' ;";
474
					"WHERE b.num_ref = lb.num_ref AND lb.num_nom = '$num_nom' ;";
457
		$resultat = $this->getBdd()->recupererTous($requete); //Debug::printr($resultat);
475
		$resultat = $this->getBdd()->recupererTous($requete); //Debug::printr($resultat);
458
 
476
 
459
		 if ($resultat == '') { //cas ou la requete comporte des erreurs
477
		 if ($resultat == '') { //cas ou la requete comporte des erreurs
460
		 	$r = 'La requête SQL formée comporte une erreur !!';
478
		 	$r = 'La requête SQL formée comporte une erreur !!';
461
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $r);
479
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $r);
462
			Debug::printr($requete);
480
			Debug::printr($requete);
463
		 } elseif ($resultat) {
481
		 } elseif ($resultat) {
464
			foreach ($resultat as $res) {
482
			foreach ($resultat as $res) {
465
			   	foreach ($res as $cle => $valeur) {
483
			   	foreach ($res as $cle => $valeur) {
466
			   		if ($valeur !== "") {
484
			   		if ($valeur !== "") {
467
			   			$this->table_retour['attributions'][$langue][$num_nom]['biblio.'.$cle] = $valeur;
485
			   			$this->table_retour['attributions'][$langue][$num_nom]['biblio.'.$cle] = $valeur;
468
			   		}
486
			   		}
469
			    }
487
			    }
470
			}
488
			}
471
		}
489
		}
472
	}
490
	}
473
 
491
 
474
}
492
}
475
?>
493
?>