Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 285 Rev 286
Line 45... Line 45...
45
		'limite' => 100
45
		'limite' => 100
46
	);
46
	);
Line 47... Line 47...
47
	
47
	
48
	protected $champ_tri = 'code_langue';
48
	protected $champ_tri = 'code_langue';
-
 
49
	protected $direction_tri = 'asc';
-
 
50
	
-
 
51
	/**
-
 
52
	 * Indique les champs supplémentaires à retourner
-
 
53
	 *  - conseil_emploi = conseil d'emploi du nom vernaculaire
-
 
54
	 *  - genre = genre et nombre du nom
-
 
55
	 *  - taxon = nom retenu associé à ce nom
-
 
56
	 */
Line 49... Line 57...
49
	protected $direction_tri = 'asc';
57
	protected $champs_supp = array();
50
 
58
 
51
	/**
59
	/**
52
	 * Precise la contenance plus ou moins précise du tableau à retourner :
60
	 * Precise la contenance plus ou moins précise du tableau à retourner :
Line 97... Line 105...
97
						$this->limite_requete['depart'] = $valeur;
105
						$this->limite_requete['depart'] = $valeur;
98
						break;
106
						break;
99
					case 'navigation.limite' :
107
					case 'navigation.limite' :
100
						$this->limite_requete['limite'] = $valeur;
108
						$this->limite_requete['limite'] = $valeur;
101
						break;
109
						break;
-
 
110
					case 'retour.champs' :
-
 
111
						$this->champs_supp = explode(',',$valeur);
-
 
112
					break;
102
					case 'recherche' :
113
					case 'recherche' :
103
						break;
114
						break;
104
					case 'version.projet' :
115
					case 'version.projet' :
105
						break;
116
						break;
106
					default :
117
					default :
Line 339... Line 350...
339
			$resultat_json[$tab['num_nom_vernaculaire']]['id'] = $tab['id'];
350
			$resultat_json[$tab['num_nom_vernaculaire']]['id'] = $tab['id'];
340
			$resultat_json[$tab['num_nom_vernaculaire']]['nom_vernaculaire'] = $tab['nom_vernaculaire'];
351
			$resultat_json[$tab['num_nom_vernaculaire']]['nom_vernaculaire'] = $tab['nom_vernaculaire'];
341
			$resultat_json[$tab['num_nom_vernaculaire']]['code_langue'] = $tab['code_langue'];
352
			$resultat_json[$tab['num_nom_vernaculaire']]['code_langue'] = $tab['code_langue'];
342
			$resultat_json[$tab['num_nom_vernaculaire']]['taxon.code'] = 'bdtfx.nt:'.$tab['num_taxon'];
353
			$resultat_json[$tab['num_nom_vernaculaire']]['taxon.code'] = 'bdtfx.nt:'.$tab['num_taxon'];
343
			if ($this->retour_format == 'max') {
354
			if ($this->retour_format == 'max') {
344
				$resultat_json[$tab['num_nom_vernaculaire']]['taxon'] = $tab['num_taxon'];
355
				$resultat_json[$tab['num_nom_vernaculaire']]['num_taxon'] = $tab['num_taxon'];
345
				$resultat_json[$tab['num_nom_vernaculaire']]['nom_retenu.code'] = $tab['num_taxon'];
356
				$resultat_json[$tab['num_nom_vernaculaire']]['nom_retenu.code'] = $tab['num_taxon'];
-
 
357
				$resultat_json[$tab['num_nom_vernaculaire']]['taxon'] = $tab['num_taxon'];
346
				$this->taxons[] = $tab['num_taxon']; // utilisé pour chercher les noms latins plus bas
358
				$this->taxons[] = $tab['num_taxon']; // utilisé pour chercher les noms latins plus bas
347
				$resultat_json[$tab['num_nom_vernaculaire']]['href'] = $this->ajouterHref('noms-vernaculaires', $tab['id']);
359
				$resultat_json[$tab['num_nom_vernaculaire']]['href'] = $this->ajouterHref('noms-vernaculaires', $tab['id']);
-
 
360
				
-
 
361
				if($this->champs_supp != array()) {
348
				$resultat_json[$tab['num_nom_vernaculaire']] = $this->ajouterChampsOntologieLigneResultat($tab);
362
					$resultat_json[$tab['num_nom_vernaculaire']] = $this->ajouterChampsOntologieLigneResultat($tab);
-
 
363
				}
349
			}
364
			}
350
		}
365
		}
Line 351... Line 366...
351
		
366
		
352
		if ($this->retour_format == 'max') {
367
		if ($this->retour_format == 'max') {
353
			// On est obligé de faire un deuxième boucle pour demander tous les taxons présents en une 
368
			// On est obligé de faire un deuxième boucle pour demander tous les taxons présents en une 
354
			// fois et les attribuer aux noms car c'est beaucoup plus rapide
369
			// fois et les attribuer aux noms car c'est beaucoup plus rapide
355
			$noms_sci = $this->recupererNomTaxons();
370
			$noms_sci = $this->recupererNomTaxons();
356
			foreach ($resultat_json as &$tab) {
371
			foreach ($resultat_json as $num_nom => &$tab) {
357
				$tab = $this->ajouterTaxonsAttributionsLigneResultat($resultat_json[$tab['num_nom_vernaculaire']], $noms_sci);
372
				$tab = $this->ajouterTaxonsAttributionsLigneResultat($tab, $noms_sci);
358
			}
373
			}
Line 359... Line 374...
359
		}
374
		}
360
		
375
		
361
		uasort($resultat_json, array($this,'trierLigneTableau'));
376
		uasort($resultat_json, array($this,'trierLigneTableau'));
362
		$table_retour_json['resultat'] = $resultat_json;
377
		$table_retour_json['resultat'] = $resultat_json;
Line -... Line 378...
-
 
378
		return $table_retour_json;
-
 
379
	}
-
 
380
	
-
 
381
	/**
-
 
382
	 * Ajoute les champs d'ontologie supplémentaires si necéssaire
-
 
383
	 * en faisant appels aux web services associés
-
 
384
	 * @param array $ligne_resultat
363
		return $table_retour_json;
385
	 * 
Line 364... Line 386...
364
	}
386
	 * @return array la ligne modifiée
365
	
387
	 */
-
 
388
	public function ajouterChampsOntologieLigneResultat($ligne_resultat) {
366
	public function ajouterChampsOntologieLigneResultat($ligne_resultat) {
389
		
367
		
390
		$intitule = '';
368
		$intitule = '';
391
		foreach($this->champ_infos as $cle => $champs_supplementaires) {
369
		foreach($this->champ_infos as $cle => $champs_supplementaires) {
392
			if(in_array($cle, $this->champs_supp)) {
370
			extract($champs_supplementaires);
393
				extract($champs_supplementaires);
371
			$valeur_recherche = '';
394
				$valeur_recherche = '';
372
			switch($cle) {
395
				switch($cle) {
373
				case 'taxon':
396
					case 'taxon':
374
					$valeur_recherche = $ligne_resultat['num_taxon'];
397
						$valeur_recherche = $ligne_resultat['num_taxon'];
375
					$intitule = 'taxon.code';
398
						$intitule = 'taxon.code';
376
					break;
399
						break;
377
				case 'genre':
400
					case 'genre':
378
					$valeur_recherche = $ligne_resultat['num_genre'];
401
						$valeur_recherche = $ligne_resultat['num_genre'];
379
					$intitule = 'genre';
402
						$intitule = 'genre';
380
					break;
403
						break;
381
				case 'conseil_emploi':
404
					case 'conseil_emploi':
382
					$valeur_recherche = $ligne_resultat['num_statut'];
405
						$valeur_recherche = $ligne_resultat['num_statut'];
383
					$intitule = 'conseil_emploi'; 
406
						$intitule = 'conseil_emploi'; 
384
					break;
407
						break;
385
			}
408
				}
-
 
409
				$code_valeur = '';
-
 
410
				if(trim($valeur_recherche) != '') {
386
			$code_valeur = '';
411
					$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur_recherche, $projet);
387
			if(trim($valeur_recherche) != '') {
-
 
388
				$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur_recherche, $projet);
412
					$code_valeur = $this->chercherSignificationCode($url, $nom);
389
				$code_valeur = $this->chercherSignificationCode($url, $nom);
413
				}
390
			}
414
				$ligne_resultat[$intitule] = $code_valeur;
Line 391... Line 415...
391
			$ligne_resultat[$intitule] = $code_valeur;
415
			}