Line 42... |
Line 42... |
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 |
|
- |
|
48 |
protected $champ_tri = 'code_langue';
|
- |
|
49 |
protected $direction_tri = 'asc';
|
Line 47... |
Line 50... |
47 |
|
50 |
|
48 |
/**
|
51 |
/**
|
49 |
* Precise la contenance plus ou moins précise du tableau à retourner :
|
52 |
* Precise la contenance plus ou moins précise du tableau à retourner :
|
50 |
* - min = les données présentes dans la table
|
53 |
* - min = les données présentes dans la table
|
Line 54... |
Line 57... |
54 |
/** Valeur du paramètre de requete recherche :
|
57 |
/** Valeur du paramètre de requete recherche :
|
55 |
* - stricte : le masque est passé tel quel à l'opérateur LIKE.
|
58 |
* - 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.
|
59 |
* - 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) */
|
60 |
* - floue : recherche tolérante vis-à-vis d'approximations ou d'erreurs (fautes d'orthographe par exemple) */
|
58 |
protected $recherche;
|
61 |
protected $recherche;
|
59 |
|
62 |
|
60 |
/** Permet de stocker le tableau de résultat (non encodé en json) */
|
63 |
/** Permet de stocker le tableau de résultat (non encodé en json) */
|
61 |
protected $table_retour = array();
|
64 |
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 */
|
65 |
/** 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;
|
66 |
protected $total_resultat;
|
Line 71... |
Line 74... |
71 |
$this->recherche = $this->parametres['recherche'];
|
74 |
$this->recherche = $this->parametres['recherche'];
|
72 |
}
|
75 |
}
|
73 |
foreach ($this->parametres as $param => $valeur) {
|
76 |
foreach ($this->parametres as $param => $valeur) {
|
74 |
switch ($param) {
|
77 |
switch ($param) {
|
75 |
case 'masque' :
|
78 |
case 'masque' :
|
76 |
$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
|
79 |
$this->ajouterFiltreMasque('nom_vernaculaire', $valeur);
|
77 |
break;
|
80 |
break;
|
78 |
case 'masque.nt' :
|
81 |
case 'masque.nt' :
|
79 |
$this->ajouterLeFiltreMasque('num_taxon', $valeur);
|
82 |
$this->ajouterFiltreMasque('num_taxon', $valeur);
|
80 |
break;
|
83 |
break;
|
81 |
case 'masque.nv' :
|
84 |
case 'masque.nv' :
|
82 |
$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
|
85 |
$this->ajouterFiltreMasque('nom_vernaculaire', $valeur);
|
83 |
break;
|
86 |
break;
|
84 |
case 'masque.lg' :
|
87 |
case 'masque.lg' :
|
85 |
$this->ajouterLeFiltreMasque('code_langue', $valeur);
|
88 |
$this->ajouterFiltreMasque('code_langue', $valeur);
|
86 |
break;
|
89 |
break;
|
87 |
case 'masque.cce' :
|
90 |
case 'masque.cce' :
|
88 |
$this->ajouterLeFiltreMasque('num_statut', $valeur);
|
91 |
$this->ajouterFiltreMasque('num_statut', $valeur);
|
89 |
break;
|
92 |
break;
|
90 |
case 'retour.format' :
|
93 |
case 'retour.format' :
|
91 |
$this->retour_format = $valeur;
|
94 |
$this->retour_format = $valeur;
|
92 |
break;
|
95 |
break;
|
93 |
case 'navigation.depart' :
|
96 |
case 'navigation.depart' :
|
Line 107... |
Line 110... |
107 |
}
|
110 |
}
|
108 |
}
|
111 |
}
|
109 |
}
|
112 |
}
|
110 |
}
|
113 |
}
|
Line 111... |
Line 114... |
111 |
|
114 |
|
112 |
public function ajouterLeFiltreMasque($nom_champ, $valeur) {
|
115 |
public function ajouterFiltreMasque($nom_champ, $valeur) {
|
113 |
if ($nom_champ == 'num_taxon') { // si il s'agit d'un chiffre
|
116 |
if ($nom_champ == 'num_taxon') { // si il s'agit d'un chiffre
|
114 |
$this->requete_condition[] = $nom_champ.' = '.$this->getBdd()->proteger($valeur);
|
117 |
$this->requete_condition[] = $nom_champ.' = '.$this->getBdd()->proteger($valeur);
|
115 |
} else {
|
118 |
} else {
|
116 |
if ($this->recherche == 'floue') {
|
119 |
if ($this->recherche == 'floue') {
|
Line 329... |
Line 332... |
329 |
$table_retour_json['entete']['href.precedent'] = $url['precedent'];
|
332 |
$table_retour_json['entete']['href.precedent'] = $url['precedent'];
|
330 |
}
|
333 |
}
|
331 |
if (isset($url['suivant']) && $url['suivant'] != '') {
|
334 |
if (isset($url['suivant']) && $url['suivant'] != '') {
|
332 |
$table_retour_json['entete']['href.suivant'] = $url['suivant'];
|
335 |
$table_retour_json['entete']['href.suivant'] = $url['suivant'];
|
333 |
}
|
336 |
}
|
334 |
|
337 |
|
335 |
foreach ($resultat as $tab) {
|
338 |
foreach ($resultat as &$tab) {
|
336 |
$resultat_json[$tab['num_nom_vernaculaire']]['id'] = $tab['id'];
|
339 |
$resultat_json[$tab['num_nom_vernaculaire']]['id'] = $tab['id'];
|
337 |
$resultat_json[$tab['num_nom_vernaculaire']]['nom_vernaculaire'] = $tab['nom_vernaculaire'];
|
340 |
$resultat_json[$tab['num_nom_vernaculaire']]['nom_vernaculaire'] = $tab['nom_vernaculaire'];
|
338 |
$resultat_json[$tab['num_nom_vernaculaire']]['langue.code'] = $tab['code_langue'];
|
341 |
$resultat_json[$tab['num_nom_vernaculaire']]['code_langue'] = $tab['code_langue'];
|
339 |
$resultat_json[$tab['num_nom_vernaculaire']]['taxon.code'] = 'bdtfx.nt:'.$tab['num_taxon'];
|
342 |
$resultat_json[$tab['num_nom_vernaculaire']]['taxon.code'] = 'bdtfx.nt:'.$tab['num_taxon'];
|
340 |
if ($this->retour_format == 'max') {
|
343 |
if ($this->retour_format == 'max') {
|
341 |
$resultat_json[$tab['num_nom_vernaculaire']]['taxon'] = $tab['num_taxon'];
|
344 |
$resultat_json[$tab['num_nom_vernaculaire']]['taxon'] = $tab['num_taxon'];
|
342 |
$resultat_json[$tab['num_nom_vernaculaire']]['nom_retenu.code'] = $tab['num_taxon'];
|
345 |
$resultat_json[$tab['num_nom_vernaculaire']]['nom_retenu.code'] = $tab['num_taxon'];
|
343 |
$this->taxons[] = $tab['num_taxon']; // utiliser pour chercher les noms latins
|
346 |
$this->taxons[] = $tab['num_taxon']; // utilisé pour chercher les noms latins plus bas
|
344 |
$resultat_json[$tab['num_nom_vernaculaire']]['href'] = $this->ajouterHref('noms-vernaculaires', $tab['id']);
|
347 |
$resultat_json[$tab['num_nom_vernaculaire']]['href'] = $this->ajouterHref('noms-vernaculaires', $tab['id']);
|
- |
|
348 |
$resultat_json[$tab['num_nom_vernaculaire']] = $this->ajouterChampsOntologieLigneResultat($tab);
|
345 |
}
|
349 |
}
|
346 |
}
|
350 |
}
|
Line 347... |
Line 351... |
347 |
|
351 |
|
- |
|
352 |
if ($this->retour_format == 'max') {
|
- |
|
353 |
// 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
|
- |
|
355 |
$noms_sci = $this->recupererNomTaxons();
|
348 |
if ($this->retour_format == 'max') {
|
356 |
foreach ($resultat_json as &$tab) {
|
- |
|
357 |
$tab = $this->ajouterTaxonsAttributionsLigneResultat($resultat_json[$tab['num_nom_vernaculaire']], $noms_sci);
|
349 |
$resultat_json = $this->afficherTaxonsAttributions($resultat_json);
|
358 |
}
|
Line -... |
Line 359... |
- |
|
359 |
}
|
350 |
}
|
360 |
|
351 |
|
361 |
uasort($resultat_json, array($this,'trierLigneTableau'));
|
352 |
$table_retour_json['resultat'] = $resultat_json;
|
362 |
$table_retour_json['resultat'] = $resultat_json;
|
Line 353... |
Line 363... |
353 |
return $table_retour_json;
|
363 |
return $table_retour_json;
|
- |
|
364 |
}
|
- |
|
365 |
|
- |
|
366 |
public function ajouterChampsOntologieLigneResultat($ligne_resultat) {
|
354 |
}
|
367 |
|
- |
|
368 |
$intitule = '';
|
- |
|
369 |
foreach($this->champ_infos as $cle => $champs_supplementaires) {
|
- |
|
370 |
extract($champs_supplementaires);
|
355 |
|
371 |
$valeur_recherche = '';
|
356 |
public function afficherTaxonsAttributions($resultat) {
|
372 |
switch($cle) {
|
- |
|
373 |
case 'taxon':
|
- |
|
374 |
$valeur_recherche = $ligne_resultat['num_taxon'];
|
357 |
$nom_sci = $this->recupererNomTaxons();
|
375 |
$intitule = 'taxon.code';
|
- |
|
376 |
break;
|
- |
|
377 |
case 'genre':
|
- |
|
378 |
$valeur_recherche = $ligne_resultat['num_genre'];
|
358 |
foreach ($resultat as $num=>$tab) {
|
379 |
$intitule = 'genre';
|
- |
|
380 |
break;
|
- |
|
381 |
case 'conseil_emploi':
|
- |
|
382 |
$valeur_recherche = $ligne_resultat['num_statut'];
|
- |
|
383 |
$intitule = 'conseil_emploi';
|
- |
|
384 |
break;
|
- |
|
385 |
}
|
- |
|
386 |
$code_valeur = '';
|
359 |
if (isset($nom_sci[$tab['taxon']])) {
|
387 |
if(trim($valeur_recherche) != '') {
|
- |
|
388 |
$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur_recherche, $projet);
|
- |
|
389 |
$code_valeur = $this->chercherSignificationCode($url, $nom);
|
- |
|
390 |
}
|
- |
|
391 |
$ligne_resultat[$intitule] = $code_valeur;
|
- |
|
392 |
}
|
- |
|
393 |
return $ligne_resultat;
|
- |
|
394 |
}
|
- |
|
395 |
|
- |
|
396 |
/**
|
- |
|
397 |
* Fonction qui ajoute les attributions à une ligne de résultats
|
- |
|
398 |
*
|
- |
|
399 |
* @param array $ligne_tableau_resultat
|
- |
|
400 |
* @param array $nom_sci
|
- |
|
401 |
*/
|
- |
|
402 |
public function ajouterTaxonsAttributionsLigneResultat(&$ligne_tableau_resultat, &$noms_sci) {
|
- |
|
403 |
if (isset($nom_sci[$ligne_tableau_resultat['taxon.code']])) {
|
- |
|
404 |
$ligne_tableau_resultat['nom_retenu.code'] = $nom_sci[$ligne_tableau_resultat['taxon']]['id'];
|
- |
|
405 |
$ligne_tableau_resultat['taxon'] = $nom_sci[$ligne_tableau_resultat['taxon']]['nom_sci'];
|
- |
|
406 |
}
|
- |
|
407 |
return $ligne_tableau_resultat;
|
- |
|
408 |
}
|
- |
|
409 |
|
- |
|
410 |
private function trierLigneTableau($a, $b) {
|
- |
|
411 |
$retour = 0;
|
- |
|
412 |
|
- |
|
413 |
if ($a[$this->champ_tri] == $b[$this->champ_tri]) {
|
- |
|
414 |
$retour = 0;
|
- |
|
415 |
}
|
- |
|
416 |
|
- |
|
417 |
if($this->champ_tri == 'code_langue') {
|
- |
|
418 |
if ($a[$this->champ_tri] == 'fra' && $b[$this->champ_tri] != 'fra') {
|
- |
|
419 |
$retour = ($this->direction_tri == 'asc') ? -1 : 1;
|
- |
|
420 |
} else if ($a[$this->champ_tri] != 'fra' && $b[$this->champ_tri] == 'fra') {
|
- |
|
421 |
$retour = ($this->direction_tri == 'asc') ? 1 : -1;
|
- |
|
422 |
} else {
|
- |
|
423 |
$retour = $this->comparerChaineSelonDirectionTri($a[$this->champ_tri], $b[$this->champ_tri]);
|
- |
|
424 |
}
|
- |
|
425 |
} else {
|
- |
|
426 |
$retour = $this->comparerChaineSelonDirectionTri($a[$this->champ_tri], $b[$this->champ_tri]);
|
- |
|
427 |
}
|
- |
|
428 |
return $retour;
|
- |
|
429 |
}
|
- |
|
430 |
|
- |
|
431 |
private function comparerChaineSelonDirectionTri($a, $b) {
|
- |
|
432 |
if($this->direction_tri == 'asc') {
|
360 |
$resultat[$num]['nom_retenu.code'] = $nom_sci[$tab['taxon']]['id'];
|
433 |
return ($a < $b) ? -1 : 1;
|
361 |
$resultat[$num]['taxon'] = $nom_sci[$tab['taxon']]['nom_sci'];
|
- |
|
362 |
}
|
434 |
} else {
|
Line 363... |
Line 435... |
363 |
}
|
435 |
return ($a > $b) ? -1 : 1;
|
364 |
return $resultat;
|
436 |
}
|
365 |
}
|
437 |
}
|
Line 538... |
Line 610... |
538 |
|
610 |
|
539 |
public function chargerBiblio($num_nom, $langue) {
|
611 |
public function chargerBiblio($num_nom, $langue) {
|
540 |
list($table, $version) = explode('_v',$this->table);
|
612 |
list($table, $version) = explode('_v',$this->table);
|
541 |
$requete = "SELECT b.*, lb.notes FROM nvjfl_lien_biblio_v$version lb, nvjfl_biblio_v$version b ".
|
613 |
$requete = "SELECT b.*, lb.notes FROM nvjfl_lien_biblio_v$version lb, nvjfl_biblio_v$version b ".
|
542 |
"WHERE b.num_ref = lb.num_ref AND lb.num_nom = '$num_nom' ;";
|
614 |
"WHERE b.num_ref = lb.num_ref AND lb.num_nom = '$num_nom' ;";
|
Line 543... |
Line 615... |
543 |
$resultat = $this->getBdd()->recupererTous($requete); //Debug::printr($resultat);
|
615 |
$resultat = $this->getBdd()->recupererTous($requete);
|
544 |
|
616 |
|
545 |
if ($resultat == '') { //cas ou la requete comporte des erreurs
|
617 |
if ($resultat == '') { //cas ou la requete comporte des erreurs
|
546 |
$r = 'La requête SQL formée comporte une erreur !!';
|
618 |
$r = 'La requête SQL formée comporte une erreur !!';
|