Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev Author Line No. Line
3 jpm 1
<?php
2
/**
3
* Description :
4
* Classe MetaDonnees.php fournit des informations sur le projet.
8 jpm 5
* Le but étant de fournir un ensemble minimal d'information comprenant :
3 jpm 6
* la version, la langue, le nom, le créateur et l'éditeur du projet.
7
* Si l'url finit par /meta-donnees on retourne une liste de termes (seulement les 100 premières par défaut).
8
* L'url peut contenir des paramètres optionnels passés après le ? : /meta-donnees?param1=val1&param2=val2&...
8 jpm 9
*
10
* Les paramètres de requête disponibles sont : masque, , recherche,
3 jpm 11
* distinct, retour.format, navigation.depart et navigation.limite.
8 jpm 12
*
3 jpm 13
* Encodage en entrée : utf8
14
* Encodage en sortie : utf8
15
* @package framework-v3
16
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
17
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
18
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
19
* @version 1.0
20
* @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
21
*/
22
 
23
class MetaDonnees extends Commun {
8 jpm 24
 
3 jpm 25
	protected $requete_champ = '*';
26
	protected $requete_condition = null;
27
	protected $retour_format = 'max';
28
	protected $table_retour = array();
29
	protected $format_reponse = 'metaDonnees';
30
	protected $table_ressources;
8 jpm 31
 
32
 
3 jpm 33
	public function consulter($ressources, $parametres) {
236 delphine 34
		$this->ressources = $ressources;
35
		$this->parametres = $parametres;
36
		$this->serviceNom = 'meta-donnees';
37
 
38
		$resultats = '';
3 jpm 39
		// on traite en premier la version dans le cas ou un langage est demandé pr une version
236 delphine 40
		$this->traiterVersionProjet();
3 jpm 41
		$this->traiterParametres($parametres);
42
		$this->traiterRessources($ressources);
43
		if ($this->corps_http == '' && $this->entete_http == '') {
8 jpm 44
			$requete_meta  = $this->assemblerLaRequete();
45
			$resultat_meta = $this->getBdd()->recupererTous($requete_meta);
236 delphine 46
			$resultats = $this->formerResultat($resultat_meta, $requete_meta);
3 jpm 47
		}
236 delphine 48
		return $resultats;
3 jpm 49
	}
8 jpm 50
 
236 delphine 51
	public function formerResultat($resultat_meta, $requete_meta) {
3 jpm 52
		if ($resultat_meta == '') {
53
			$e = 'La requête formée comporte une erreur!';
54
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$e);
55
			Debug::printr($requete);
56
		} elseif ($resultat_meta) {
236 delphine 57
			$resultat_formate = $this->retournerResultatFormate($resultat_meta);
3 jpm 58
		} else {
59
			$m = "Données introuvables dans la base $this->table";
60
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $m);
61
			Debug::printr($requete_meta);
62
		}
63
		return $resultat_formate;
64
	}
8 jpm 65
 
3 jpm 66
//--------------------FONCTIONS TRAITEMENT DES PARAMETRES---------------------------------------------------------------
8 jpm 67
 
3 jpm 68
	public function traiterParametres($parametres) {
69
		if (isset($parametres) && !empty($parametres)) {
70
			foreach ($parametres as $param => $val) {
8 jpm 71
				switch ($param) {
72
					case 'retour.langue' : $this->rechercherLangueDispo($val);	break;
73
					case 'retour.format' : $this->retour_format = $val;			break;
74
					default				 :
3 jpm 75
						$e = 'Erreur dans les paramètres de recherche de votre requête : </br> Le paramètre " '
76
							.$param.' " n\'existe pas.';
77
						$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
78
						break;
79
				}
80
			}
81
		}
82
	}
8 jpm 83
 
3 jpm 84
//----------------------FONCTIONS TRAITEMENT DES RESSOURCES-------------------------------------------------------------
8 jpm 85
 
3 jpm 86
	public function traiterRessources($ressources) {
87
		// /meta-donnees (liste des meta-données. Toutes les info de la table sont affichées) ou /meta-donnees/#champ
88
		if (isset($ressources) && !empty($ressources)) {
89
			$this->table_ressources = $ressources;
90
			if (isset($ressources) && !empty($ressources)) {
91
				$this->format_reponse = 'metaDonnees/champ';
8 jpm 92
			}
3 jpm 93
		}
94
	}
8 jpm 95
 
96
	/** Détermine quelles métadonnées doivent etre retournées :
3 jpm 97
	 *  - "*" : (/#projet/* /meta-donnees) Renvoi les meta-données de toutes les versions du projet
98
	 *  - "numero de la version" : (/#projet/2.00/meta-donnees) Renvoi les meta-données de la version 2.00 du projet
99
	 *  - non renseignée : (/#projet/meta-donnees) Renvoi les meta-données de la dernière version du projet
100
	 *  Cette info est stockée dans par la classe RestServeur dans la variable $ressources ($ressources[0])
8 jpm 101
	 */
236 delphine 102
	public function traiterVersionProjet() {
103
		if (isset($this->ressources[0]) && !empty($this->ressources[0])) {
104
			if (preg_match('/(?:[0-9]+(?:_|[.])[0-9]+|[*]| )/', $this->ressources[0])) {
105
				$this->version_projet = array_shift($this->ressources);
3 jpm 106
				if ($this->version_projet == ' ') $this->version_projet = '+';
107
			}
108
			switch ($this->version_projet) {
8 jpm 109
				case '+' :
110
					$this->requete_condition[] = 'version = (SELECT MAX(version) FROM '.Config::get('bdd_table_meta').')';
3 jpm 111
					break;
8 jpm 112
				case '*' :
3 jpm 113
					break;
8 jpm 114
				default :
3 jpm 115
					if (is_numeric($this->version_projet)) {
236 delphine 116
						$this->ajouterFiltreVersion();
3 jpm 117
					}
118
					break;
119
			}
120
		}
8 jpm 121
 
3 jpm 122
	}
8 jpm 123
 
124
 
3 jpm 125
	/**
8 jpm 126
	 * Vérifie que le numéro de la version passée en paramètre correspond à une version existante.
3 jpm 127
	 * Si oui remplit la condition de la requete SQL
128
	 */
236 delphine 129
	public function ajouterFiltreVersion() {
130
		$val = str_replace('_', '.', $this->version_projet);
3 jpm 131
		$req_version = 'SELECT version FROM '.Config::get('bdd_table_meta');
132
		$res_version = $this->getBdd()->recupererTous($req_version);
133
		foreach ($res_version as $version) {
134
			$versions_dispo[] = $version['version'];
135
		}
136
		if (in_array($val, $versions_dispo)) {
8 jpm 137
			$this->requete_condition[] = 'version = '.$this->getBdd()->proteger($val);
3 jpm 138
		} else {
139
			$e = 'La version demandée n\'existe pas actuellement. </br>Les versions disponibles sont : '
140
				.implode($versions_dispo);
141
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
142
		}
143
	}
8 jpm 144
 
145
 
3 jpm 146
	/** Vérifie que les meta-donnees existe dans la langue passée en paramètre, Si oui remplit la condition de la requete SQL */
147
	public function rechercherLangueDispo($val) {
148
		//on recherche les langues_meta disponibles pour la version demandée : (d'ou ajout de la condition)
149
		$req_langue = 'SELECT langue_meta FROM '
150
						.Config::get('bdd_table_meta')
151
						.' WHERE '.implode(' AND ', $this->requete_condition);
152
		$res_langue = $this->getBdd()->recupererTous($req_langue);
153
		foreach ($res_langue as $langue) {
154
			$langue_dispo[] = $langue['langue_meta'];
155
		}
156
		if (in_array($val, $langue_dispo)) {
8 jpm 157
			$this->requete_condition[] = 'langue_meta = '.$this->getBdd()->proteger($val);
3 jpm 158
		} else {
159
			$e = 'La langue demandée n\'existe pas actuellement. </br>Les langues disponibles sont : '
160
				.implode($langue_dispo);
161
			$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
162
		}
163
	}
8 jpm 164
 
3 jpm 165
//------------------------------Fonction d'assemblage de la requete------------------------------------------------------
8 jpm 166
 
3 jpm 167
	public function assemblerLaRequete() {
168
		$condition = '';
169
		if (isset($this->requete_condition)) {
170
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
8 jpm 171
		}
3 jpm 172
		$req = 'SELECT '.$this->requete_champ.' FROM '.Config::get('bdd_table_meta').$condition;
173
		return $req;
174
	}
8 jpm 175
 
3 jpm 176
//--------------------------------------Fonction de formatage des resultats ---------------------------------------------
8 jpm 177
 
236 delphine 178
	public function retournerResultatFormate($resultat) {
3 jpm 179
		switch ($this->format_reponse) {
180
			case 'metaDonnees/champ' : $reponse = $this->formaterMetaDonneesChamp($resultat);  	break;
181
			case 'metaDonnees'		 : $reponse = $this->formaterMetaDonnees($resultat); 		break;
182
			default					 : 															break;
183
		}
236 delphine 184
		return $reponse;
8 jpm 185
	}
186
 
3 jpm 187
//--------------------------------------Fonction de formatage des resultats de /metaDonnees/----------------------------
8 jpm 188
 
3 jpm 189
	public function formaterMetaDonnees($resultat) {
190
		foreach ($resultat as $version) {
191
			foreach ($version as $key => $val) {
192
				if ($val != '') {
193
					$this->afficherDonnees($key, $val);
8 jpm 194
				}
3 jpm 195
			}
196
			if ($this->retour_format == 'max' && $this->version_projet == '*') {
197
				$this->table_retour['href'] = Config::get('url_service_base').Config::get('nom_projet')
236 delphine 198
											 .'/'.$version['version'].'/'.$this->serviceNom;
8 jpm 199
			}
3 jpm 200
			$table[] = $this->table_retour;
201
			$this->table_retour = array();
202
		}
203
		return $table;
204
	}
8 jpm 205
 
206
 
3 jpm 207
	public function afficherDonnees($key, $valeur) {
208
		if ($valeur != '') {
209
			$tab = array();
210
			if ($this->retour_format == 'min') {
211
				if (in_array($key, array('editeur','createurs',	'contributeurs','couverture_spatiale','couverture_temporelle'))) {
8 jpm 212
					//Pour les données comprenant plusieurs infos (...=...,...=...;...)
3 jpm 213
					$tab = $this->recupererTableauResultat($valeur);
214
					$this->afficherConcatenationValeur($key, $tab);
215
				} else {
8 jpm 216
					$this->table_retour[$key] = trim($valeur);
3 jpm 217
				}
218
			} else {
8 jpm 219
				if (in_array($key, array('editeur','createurs',	'contributeurs','couverture_spatiale','couverture_temporelle','langue','langue_meta'))) {
220
					$tab = $this->recupererTableauResultat($valeur);
3 jpm 221
					$this->afficherConcatenationValeur($key, $tab);
222
					$this->afficherDonneesMax($key,$valeur,$tab);
223
				} else {
224
					$this->table_retour[$key] = trim($valeur);
8 jpm 225
				}
3 jpm 226
			}
227
		}
228
	}
8 jpm 229
 
3 jpm 230
	/**
231
	 * Recupère à partir de la valeur du champ les différentes informations séparées par ';' (stocke ds un tableau)
232
	 * pour éditeurs, créateurs, contributeurs,...
233
	 * (ex : nom=Tela Botanica,guid=urn:lsid:tela-botanica.org,courriel=accueil@tela-botanica.org,...
8 jpm 234
	 */
3 jpm 235
	public function recupererTableauResultat($val) {
8 jpm 236
		$tab = array();
3 jpm 237
		$num_entite = 0;
238
		// découpe chaque participant
8 jpm 239
		$tab_entites = explode(';', $val);
3 jpm 240
		foreach ($tab_entites as $entite) {
241
			$tab[$num_entite] = array();
242
			if ($entite != '') { // découpe les informations du participant
8 jpm 243
				$entite_detail = explode(',', $entite);
3 jpm 244
				foreach ($entite_detail as $detail) {
245
					if ($detail != '') {
246
						if (preg_match('/^([^=]+)=([^=]*)$/', $detail, $match)) {
247
							$tab[$num_entite][$match[1]] = $match[2];
248
						} else {
249
							$tab[$num_entite][] = $detail;
250
						}
251
					}
252
				}
253
			}
254
			$num_entite++;
255
		}
256
		return $tab;
257
	}
8 jpm 258
 
259
 
260
	/** Retourne :
261
	 *  - le nom de l'editeur
3 jpm 262
	 *  - les coordonnées de l'éditeur sous la forme [latitude]N,[longitude]S [datum]
263
	 *  - la couverture temporelle sous la forme xxxx à xxxx
264
	 *  - la concaténation des noms pour les contributeurs et les créateurs (machin chouette, truc bidule...)
265
	 *  - la liste des liste des couvertures spatiales (le nom et pas le code) (France, allemagne..) */
266
	public function afficherConcatenationValeur($champ, $tab) {
267
		if (strrpos($champ, '.coordonnees') !== false) {
268
			if (isset($tab[0]['latitude']) && isset($tab[0]['longitude']) && isset($tab[0]['datum'])) {
269
				$this->table_retour[$champ] = $tab[0]['latitude'].' N, '.$tab[0]['longitude'].' S ['.$tab[0]['datum'].']';
270
			}
271
		} else {
272
			$concat = '';
273
			foreach ($tab as $entite) {
274
				foreach ($entite as $key => $val) {
275
					if ($champ == 'couverture_spatiale') {
276
							$concat .= ', '.$this->ajouterSignification($champ, $val);
277
					} else {
278
						if (strrpos($key, '.prenom') !== false) {
8 jpm 279
							$concat .= ', '.$val;
3 jpm 280
						} elseif (strrpos($key, 'nom') !== false) {
8 jpm 281
 
282
							$concat .= ' '.$val;
3 jpm 283
							break;
284
						}
285
					}
286
				}
287
			}
288
			$res = trim($concat, ',');
289
			$res = trim($res);
290
			if ($champ == 'couverture_temporelle') $res = str_replace(' ', ' à ',$res);
291
			$this->table_retour[$champ] = $res;
292
		}
293
	}
294
 
8 jpm 295
 
3 jpm 296
	public function afficherDonneesMax($champ,$valeur,$tab) {
297
		switch ($champ) {
298
			case 'couverture_temporelle' : $this->afficherInfosPrecises($champ, 'start,end', $valeur, $tab); 		break;
299
			case 'langue' 				 : $this->afficherInfosPrecises($champ,'signification,code,href', $valeur); break;
300
			case 'langue_meta' 			 : $this->afficherInfosPrecises($champ,'signification,code,href', $valeur); break;
301
			case 'couverture_spatiale' 	 : $this->afficherInfosPrecises($champ, 'details', $valeur, $tab); 			break;
302
			case 'createurs' 			 : $this->afficherInfosPrecises($champ, 'details', $valeur, $tab);			break;
303
			case 'contributeurs' 		 : $this->afficherInfosPrecises($champ, 'details', $valeur, $tab); 			break;
304
			case 'editeur' 				 : $this->afficherEditeur($champ, $tab);									break;
305
			default 					 : $this->table_retour[$champ] = $valeur; 									break;
306
		}
307
	}
8 jpm 308
 
309
 
310
	public function afficherEditeur($key, $tab) {
311
		// infos générales sur l'éditeur
3 jpm 312
		foreach ($tab[0] as $k => $val) {
313
			if ((strrpos($k, 'contact.') === false) && (strrpos($k, '.wgs84') === false)) {
8 jpm 314
				$this->table_retour[$key.'.'.$k] = $val;
3 jpm 315
			}
8 jpm 316
		}
317
		//on récupère dans un premier temps les tableaux des coordonnées.
3 jpm 318
		$table_coordonnees = $this->recupererTableCoordonnees($tab);
8 jpm 319
		//on affiche les informations sur les coordonnees : concaténation + détails
3 jpm 320
		if ($table_coordonnees[0] != array()) {
321
			$this->afficherConcatenationValeur($key.'.coordonnees', $table_coordonnees);
322
			if (isset($table_coordonnees[0]['datum'])) {
8 jpm 323
				$this->afficherInfosPrecises($key.'.coordonnees.datum',
3 jpm 324
					'signification,code,href',$table_coordonnees[0]['datum'],
325
					$table_coordonnees);
326
			}
8 jpm 327
		}
328
		$table_contact = $this->recupererTableContact($tab);
3 jpm 329
		//on affiche le premier contact en dehors de la table de détail:
330
		if ($table_contact[0] != array()) {
8 jpm 331
			$this->table_retour[$key.'.contact'] = '';
3 jpm 332
			foreach ($table_contact as $info => $valeur) {
333
				$this->table_retour[$key.'.contact'] .= $valeur['contact.prenom']." ".$valeur['contact.nom'];
334
			}
8 jpm 335
			//on affiche les détails des autres contacts :
336
			$this->afficherTableDetails($key.'.contact', $table_contact);
337
		}
3 jpm 338
	}
8 jpm 339
 
340
 
341
 
3 jpm 342
	public function afficherInfosPrecises($champ, $pts, $val, $tab = null) {
343
		//permet d'afficher les informations précises telles que les .details, .start, .end...
344
		$pts = explode(',', $pts);
345
		foreach ($pts as $pt) {
346
			switch ($pt) {
347
				case 'start'   		 : 	$this->table_retour[$champ.'.start'] = $tab['start']; 					 break;
348
				case 'end' 			 : 	$this->table_retour[$champ.'.end'] = $tab[' end']; 						 break;
349
				case 'code' 		 : 	$this->table_retour[$champ.'.code'] = $val; 							 break;
8 jpm 350
				case 'href' 		 : 	$this->table_retour[$champ.'.href'] =
3 jpm 351
										$this->ajouterHrefAutreProjet($champ, '', $val);  				 	 break;
352
				case 'signification' :  $this->table_retour[$champ] = $this->ajouterSignification($champ, $val); break;
353
				case 'details' 		 :  if ($champ == 'couverture_spatiale') {
354
											$this->afficherCouvertureSpatiale($champ, $tab);
355
										} else {
356
											$this->afficherTableDetails($champ, $tab);
357
										}																		 break;
358
				default 			 :  $this->table_retour[$champ.'.'.$pt] = $tab[$pt]; 						 break;
359
			}
360
		}
361
	}
8 jpm 362
 
363
 
364
 
3 jpm 365
	public function afficherCouvertureSpatiale($key, $tab) {
366
		$res = $this->table_retour;
367
		$this->table_retour = array();
368
		foreach ($tab as $iso) {
369
			foreach ($iso as $val) {
8 jpm 370
				$this->afficherInfosPrecises($key, 'signification,code,href',$val);
3 jpm 371
				$res[$key.'.detail'][] = $this->table_retour;
372
				$this->table_retour = array();
373
			}
374
		}
375
		$this->table_retour = $res;
376
	}
8 jpm 377
 
3 jpm 378
	public function afficherTableDetails($champ, $tab) {
379
		$res = $this->table_retour;
380
		$this->table_retour = array();
381
		foreach ($tab as $num_entite => $entite) { // $t et $type valent p ou o
382
			$t = '';
8 jpm 383
			$type = '.';
3 jpm 384
			foreach ($entite as $key => $infos) {
385
				list($type, $info) = explode('.', trim($key));
8 jpm 386
				if ($type == 'contact') $type = 'p';
3 jpm 387
				if ($type != $t) { // cherche et ajoute la signification du type
388
					$this->afficherInfosPrecises('type', 'signification,code,href', trim($type));
389
					foreach ($this->table_retour as $k => $val) {
390
						$res[$champ.'.details'][$num_entite][$type.'.'.$k] = $val;
391
					}
392
					$table_retour = array();
393
					$this->table_retour = array(); // rempli par afficherInfosPrecises
394
					$t = $type;
8 jpm 395
				}
3 jpm 396
				$res[$champ.'.details'][$num_entite][$key] = $infos;
397
			}
398
		}
399
		$this->table_retour = $res;
400
	}
401
 
402
	public function ajouterSignification($champ, $val, $nom = 'nom') {
403
		$url = $this->ajouterHrefAutreProjet($champ, '', $val);
404
		if (in_array($champ, array('langue', 'langue_meta', 'couverture_spatiale'))) {
405
			$url .= '/'.$nom;
406
		}
407
		$signification = $this->consulterHref($url);
408
		if (isset($signification->$nom)) {
409
			$res = $signification->$nom;
410
		} else {
411
			$nom = 'nom.fr';
412
			$res = $signification->$nom;
413
		}
414
		return $res ;
415
	}
416
 
8 jpm 417
 
3 jpm 418
	public function recupererTableContact(&$tab) {
419
		$res = array();
420
		foreach ($tab[0] as $key => $val) {
421
			if (strrpos($key, 'contact.') !== false) {
422
				while (array_key_exists($key, $res)) { $key = ' '.$key; }
423
				$res[$key] = $val;
424
				unset($tab[0][$key]); //suppression des premiers contacts qui seront affichés après
425
			}
426
		}
427
		$resultat[0] = $res;
428
		return $resultat;
429
	}
8 jpm 430
 
431
 
3 jpm 432
	public function recupererTableCoordonnees(&$tab) {
433
		$res = array();
434
		foreach ($tab[0] as $key => $val) {
435
			if (strrpos($key, 'latitude') !== false || strrpos($key, 'longitude') !== false) {
436
				list ($coord, $datum) = explode('.', $key);
437
				$res[$coord]  = $val;
438
				$res['datum'] = $datum;
439
			}
440
		}
441
		$resultat[0] = $res;
442
		return $resultat;
443
	}
8 jpm 444
 
3 jpm 445
//-------------------------------------Fonction de formatage des resultats de /metaDonnees/#champs+champs----------------
8 jpm 446
 
3 jpm 447
	public function formaterMetaDonneesChamp($resultat) {
448
		$this->recupererNomChamp(Config::get('bdd_table_meta'));
449
		//On récupère dans un premier temps toutes les données existantes puis on pioche les champs recherchés
450
		$table_Meta = $this->formaterMetaDonnees($resultat);
451
		foreach ($table_Meta as $version) {
452
			//on affiche les informations par defaut : la version, la langue_meta et le guid :
453
			$this->afficherVersionLangueMetaGuid($version);
454
			$tab_ress = explode(' ', $this->table_ressources[0]);
8 jpm 455
			foreach ($tab_ress as $champ) {//on recupere le radical pour comparaison avec les nom des champs de la bdd :
3 jpm 456
				$this->afficherChampRecherche($champ, $version);
457
			}
458
			$table[] = $this->table_retour;
459
			$this->table_retour = array();
460
		}
461
		return $table;
462
	}
8 jpm 463
 
3 jpm 464
	public function afficherChampRecherche(&$champ, &$version) {
465
		preg_match('/^([^.]+)(?:[.][^.]+)?$/', $champ, $match);
466
		if (preg_match('/(.+)[.][*]$/', $champ, $match_2)) {
467
			$this->afficherPointEtoile($match_2, $version, $champ);
468
		} elseif (array_key_exists($champ, $version)) {
469
			$this->table_retour[$champ] = $version[$champ];
8 jpm 470
		} elseif (in_array($match[1], $this->champs_table)) {
3 jpm 471
			//si le champ est vide dans cette version on retourne null (comparaison avec les champs existants)
8 jpm 472
			$this->table_retour[$champ] = null;
3 jpm 473
		} else {
474
			$champs = implode('</li><li>', array_keys($version));
475
			$e = 'Erreur dans votre requête : </br> Le champ "'.$champ.'" n\'existe pas'.
476
				'. Les champs disponibles sont : <li>'.$champs.'</li>';
477
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
478
		}
479
	}
8 jpm 480
 
3 jpm 481
	public function afficherPointEtoile($match, $version, $ressource) {
482
		$existe = false;
483
		foreach ($version as $key => $valeur) {
484
			if (strrpos($key, $match[1].'.') !== false) {
485
				$this->table_retour[$key] = $valeur;
486
				$existe = true;
487
			}
8 jpm 488
		}
3 jpm 489
		if (!$existe) {
490
			$champs = implode('</li><li>', array_keys($version));
491
			$e = 'Erreur dans votre requête : </br> Le champ " '.$ressource.' " n\'existe pas dans la version '
492
				.$version['version'].'. Les champs disponibles sont : <li>'.$champs.'</li>';
493
			$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
494
		}
495
	}
8 jpm 496
 
3 jpm 497
	public function afficherVersionLangueMetaGuid(&$version) {
8 jpm 498
		$this->table_retour['version'] = $version['version'];
3 jpm 499
		$this->table_retour['langue_meta'] = $version['langue_meta'];
8 jpm 500
		$this->table_retour['guid'] = $version['guid'];
3 jpm 501
	}
502
 
503
 
504
 
505
 
506
}
507
 
508
?>