Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 104 Rev 272
Line 291... Line 291...
291
	}
291
	}
Line 292... Line 292...
292
	
292
	
Line 293... Line 293...
293
	
293
	
294
//-------------------FONCTIONS POUR LE FORMATAGE EN JSON----------------------------------------------------------------
294
//-------------------FONCTIONS POUR LE FORMATAGE EN JSON----------------------------------------------------------------
295
	
295
	
296
	public function retournerResultatFormate($resultat, $version) {
296
	public function retournerResultatFormate($resultat) {
297
		switch ($this->format_reponse) {
297
		switch ($this->format_reponse) {
298
			case 'noms/relations' :
298
			case 'noms/relations' :
Line 347... Line 347...
347
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
347
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
348
		$this->resultat_req = $resultat;	
348
		$this->resultat_req = $resultat;	
349
		$retour_id_rel = array ('entete' => array()); //on initialise pr que l'entete apparaisse en premier lors de l'affichage
349
		$retour_id_rel = array ('entete' => array()); //on initialise pr que l'entete apparaisse en premier lors de l'affichage
Line 350... Line 350...
350
		
350
		
351
		//on recupère le resultat de chaque relation (appel du WS correspondant)
351
		//on recupère le resultat de chaque relation (appel du WS correspondant)
352
		$flores = $this->ajouterRelations('flores', $version);
352
		$flores = $this->ajouterRelations('flores');
353
		if (isset($flores)) $retour_id_rel['resultat']['flores'] = $flores;
353
		if (isset($flores)) $retour_id_rel['resultat']['flores'] = $flores;
354
		$homonymes = $this->ajouterRelations('homonymie', $version);
354
		$homonymes = $this->ajouterRelations('homonymie');
355
		if (isset($homonymes)) $retour_id_rel['resultat']['homonymes'] = $homonymes;
355
		if (isset($homonymes)) $retour_id_rel['resultat']['homonymes'] = $homonymes;
356
		$synonymes = $this->ajouterRelations('synonymie', $version);
356
		$synonymes = $this->ajouterRelations('synonymie');
Line 357... Line 357...
357
		if (isset($synonymes)) $retour_id_rel['resultat']['synonymes'] = $synonymes;
357
		if (isset($synonymes)) $retour_id_rel['resultat']['synonymes'] = $synonymes;
358
		
358
		
359
		//on renvoit null si il n'existe aucune relations (on efface l'entete en premier lieu)
359
		//on renvoit null si il n'existe aucune relations (on efface l'entete en premier lieu)
Line 369... Line 369...
369
	
369
	
370
	/**
370
	/**
371
	 * Recupere les relations (type de la relation passée en paramètres :[type_relation] = synonymie, homonymie ou 
371
	 * Recupere les relations (type de la relation passée en paramètres :[type_relation] = synonymie, homonymie ou 
372
	 * flores) par l'appel du web service [version]/noms/#id/relations/[type_relation]
372
	 * flores) par l'appel du web service [version]/noms/#id/relations/[type_relation]
373
	 */
373
	 */
374
	public function ajouterRelations($relation, $version) {
374
	public function ajouterRelations($relation) {
375
		$version = str_replace(Config::get('bdd_table').'_', '', $version);
375
		$version = str_replace(Config::get('bdd_table').'_', '', $this->table);
376
		$res = null;
376
		$res = null;
377
		$parametres_url = '';
377
		$parametres_url = '';
378
		if ($this->parametres != array()) $parametres_url = '?'.http_build_query($this->parametres, '', '&');
378
		if ($this->parametres != array()) $parametres_url = '?'.http_build_query($this->parametres, '', '&');
379
		$url = Config::get('url_service').'/'.$version.'/'.$this->service.'/'
379
		$url = Config::get('url_service').'/'.$this->service.'/'
380
									.$this->ressources[0].'/relations/'
380
									.$this->ressources[0].'/relations/'
381
									.$relation.$parametres_url;	
381
									.$relation.$parametres_url;	Debug::printr($url);
382
		$relation = $this->consulterHref($url);
382
		$relation = $this->consulterHref($url);
383
		$res = $relation->resultat;
383
		$res = $relation->resultat;
384
		return $res;
384
		return $res;
Line 412... Line 412...
412
		return $retour_id_syn;
412
		return $retour_id_syn;
413
	}
413
	}
Line 414... Line 414...
414
	
414
	
415
	public function formaterIdHomonymie($resultat) {
415
	public function formaterIdHomonymie($resultat) {
416
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
416
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp');
417
		if (count($res_version) != 1) {
417
		if (count($resultat) != 1) {
418
			$this->table_retour['id'] = $this->ressources[0];
418
			$this->table_retour['id'] = $this->ressources[0];
419
			$this->afficherEnteteResultat($resultat, '/'.$this->service.'/'.$this->ressources[0].'/relations/homonymie');
419
			$this->afficherEnteteResultat($resultat, '/'.$this->service.'/'.$this->ressources[0].'/relations/homonymie');
420
			$retour_id_hom['entete'] = $this->table_retour;
420
			$retour_id_hom['entete'] = $this->table_retour;
421
			$this->table_retour = array();
421
			$this->table_retour = array();
Line 429... Line 429...
429
				}						
429
				}						
430
				$retour_id_hom['resultat'][$id] = $this->table_retour;
430
				$retour_id_hom['resultat'][$id] = $this->table_retour;
431
				unset($retour_id_hom['resultat'][$id]['id']);
431
				unset($retour_id_hom['resultat'][$id]['id']);
432
				$this->table_retour = array();
432
				$this->table_retour = array();
433
			}
433
			}
434
		} else {
434
		} else {Debug::printr($resultat);
435
			$retour_id_hom = null; 
435
			$retour_id_hom = null; 
436
		}
436
		}
437
		return $retour_id_hom;
437
		return $retour_id_hom;
438
	}
438
	}
Line 442... Line 442...
442
		$this->resultat_req = $resultat;	
442
		$this->resultat_req = $resultat;	
443
		$id = array_shift($resultat);
443
		$id = array_shift($resultat);
444
		$reponse['entete']['id'] = $id;
444
		$reponse['entete']['id'] = $id;
445
		foreach ($resultat as $flores => $valeur) {
445
		foreach ($resultat as $flores => $valeur) {
446
			if ($valeur != '' && $valeur != '0') {
446
			if ($valeur != '' && $valeur != '0') {
447
				$this->afficherInfosFlore($res_version, $flores, $valeur);
447
				$this->afficherInfosFlore($resultat, $flores, $valeur);
448
			}
448
			}
449
		}
449
		}
450
		if ($this->table_retour != array()) {
450
		if ($this->table_retour != array()) {
451
			$reponse['resultat'] = $this->table_retour;
451
			$reponse['resultat'] = $this->table_retour;
452
			$this->table_retour = array();
452
			$this->table_retour = array();