Line 1... |
Line 1... |
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¶m2=val2&...
|
9 |
* L'url peut contenir des paramètres optionnels passés après le ? : /observations?param1=val1¶m2=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 |
|
- |
|
25 |
class NomsVernaculaires extends Commun {
|
24 |
class NomsVernaculaires extends Commun {
|
26 |
protected $champ_infos = array(
|
25 |
protected $champ_infos = array(
|
27 |
'taxon' => array('service' => 'taxons', 'ressource' => 'nt:', 'projet' => 'bdtfx', 'nom' => 'nom_sci'),
|
26 |
'taxon' => array('service' => 'taxons', 'ressource' => 'nt:', 'projet' => 'bdtfx', 'nom' => 'nom_sci'),
|
28 |
'conseil_emploi' => array('service' => 'ontologies', 'ressource' => 'numStatut:', 'projet' => 'nvjfl', 'nom' => 'nom'),
|
27 |
'conseil_emploi' => array('service' => 'ontologies', 'ressource' => 'numStatut:', 'projet' => 'nvjfl', 'nom' => 'nom'),
|
29 |
'genre' => array('service' => 'ontologies', 'ressource' => 'genreNombre:', 'projet' => 'nvjfl', 'nom' => 'nom'));
|
28 |
'genre' => array('service' => 'ontologies', 'ressource' => 'genreNombre:', 'projet' => 'nvjfl', 'nom' => 'nom'));
|
30 |
|
29 |
|
31 |
protected $service = 'noms-vernaculaires';
|
30 |
protected $service = 'noms-vernaculaires';
|
32 |
|
31 |
|
33 |
/**
|
32 |
/**
|
34 |
* 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 |
|
35 |
* /noms-vernaculaires/#id/champ | /noms-vernaculaires/#id/relations
|
34 |
* /noms-vernaculaires/#id/champ | /noms-vernaculaires/#id/relations
|
36 |
* 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.
|
37 |
* 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. */
|
38 |
protected $format_reponse = 'noms-vernaculaires';
|
37 |
protected $format_reponse = 'noms-vernaculaires';
|
39 |
|
38 |
|
40 |
/** 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
|
41 |
* selon ressources et paramètres */
|
40 |
* selon ressources et paramètres */
|
42 |
protected $requete_champ = array(' * ');
|
41 |
protected $requete_champ = array(' * ');
|
43 |
protected $requete_condition = '';
|
42 |
protected $requete_condition = '';
|
44 |
protected $limite_requete = array(
|
43 |
protected $limite_requete = array(
|
45 |
'depart' => 0,
|
44 |
'depart' => 0,
|
46 |
'limite' => 100
|
45 |
'limite' => 100
|
47 |
);
|
46 |
);
|
48 |
|
47 |
|
49 |
/** Stockage des ressources et paramétres */
|
- |
|
50 |
protected $table_ressources = array();
|
- |
|
51 |
protected $table_param = array();
|
- |
|
52 |
/**
|
48 |
/**
|
53 |
* Precise la contenance plus ou moins précise du tableau à retourner :
|
49 |
* Precise la contenance plus ou moins précise du tableau à retourner :
|
54 |
* - min = les données présentes dans la table
|
50 |
* - min = les données présentes dans la table
|
55 |
* - 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)
|
56 |
* - oss = la liste des nom_sci (uniquement pour noms et taxons) */
|
52 |
* - oss = la liste des nom_sci (uniquement pour noms et taxons) */
|
57 |
protected $retour_format = 'max';
|
53 |
protected $retour_format = 'max';
|
58 |
/** Valeur du paramètre de requete recherche :
|
54 |
/** Valeur du paramètre de requete recherche :
|
59 |
* - stricte : le masque est passé tel quel à l'opérateur LIKE.
|
55 |
* - stricte : le masque est passé tel quel à l'opérateur LIKE.
|
60 |
* - 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.
|
61 |
* - 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) */
|
62 |
protected $recherche;
|
58 |
protected $recherche;
|
63 |
|
59 |
|
64 |
/** 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) */
|
65 |
protected $table_retour = array();
|
61 |
protected $table_retour = array();
|
66 |
/** 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 */
|
67 |
protected $total_resultat;
|
63 |
protected $total_resultat;
|
68 |
|
- |
|
69 |
// +-------------------------------------------------------------------------------------------------------------------+
|
- |
|
70 |
// fonction principale qui permet de construire la requête à partir de l'analyse des paramétres et ressources
|
- |
|
71 |
public function consulter($ressources, $parametres) {
|
- |
|
72 |
$this->traiterParametres($parametres);
|
- |
|
73 |
$this->traiterVersionProjet($ressources);
|
- |
|
74 |
$this->traiterRessources($ressources);
|
- |
|
75 |
$resultat_formate = '';
|
- |
|
76 |
|
- |
|
77 |
if ($this->corps_http == '' && $this->entete_http == '') {
|
- |
|
78 |
foreach ($this->table_version as $version) {
|
- |
|
79 |
$this->table = $version; //on stocke le nom de la table correspondant à la version du projet en cours
|
- |
|
80 |
$requete = $this->assemblerLaRequete(); //print_r($requete);
|
- |
|
81 |
$resultat = $this->getBdd()->recupererTous($requete);
|
- |
|
82 |
$res_version = $this->testerResultat($resultat, $requete);
|
- |
|
83 |
}
|
- |
|
84 |
if ($this->corps_http == '' && $this->entete_http == '') {
|
- |
|
85 |
if (isset($res_version)) {
|
- |
|
86 |
$resultat_formate = json_encode($res_version);
|
- |
|
87 |
}
|
- |
|
88 |
}
|
- |
|
89 |
}
|
- |
|
90 |
return $this->formerReponseHTTP($resultat_formate);
|
- |
|
91 |
}
|
- |
|
92 |
|
- |
|
93 |
public function testerResultat($resultat, $requete) {
|
- |
|
94 |
if ($resultat == '') { //cas ou la requete comporte des erreurs
|
- |
|
95 |
$s = 'La requête SQL formée comporte une erreur !!';
|
- |
|
96 |
Debug::printr($requete);
|
- |
|
97 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $s);
|
- |
|
98 |
} elseif ($resultat) {
|
- |
|
99 |
if (count($this->table_version) > 1) {
|
- |
|
100 |
$res_version[$version] = $this->retournerResultatFormate($resultat);
|
- |
|
101 |
} else {
|
- |
|
102 |
$res_version = $this->retournerResultatFormate($resultat);
|
- |
|
103 |
}
|
- |
|
104 |
} else {
|
- |
|
105 |
if ($this->format_reponse == 'noms-vernaculaires/id/relations') {
|
- |
|
106 |
//si aucune relation n'existe, la valeur null est retournée
|
- |
|
107 |
$res_version = null;
|
- |
|
108 |
} else {
|
- |
|
109 |
$d = 'Données recherchées introuvables dans la base';
|
- |
|
110 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $d);
|
- |
|
111 |
Debug::printr($requete);
|
- |
|
112 |
}
|
- |
|
113 |
}
|
- |
|
114 |
return $res_version;
|
- |
|
115 |
}
|
- |
|
116 |
|
64 |
|
117 |
// +-------------------------------------------------------------------------------------------------------------------+
|
65 |
//+------------------------------------------------------------------------------------------------------+
|
118 |
// créer une condition en fonction du paramétre
|
66 |
// créer une condition en fonction du paramétre
|
119 |
public function traiterParametres($parametres) {
|
67 |
public function traiterParametres() {
|
120 |
if (isset($parametres) && !empty($parametres)) {
|
68 |
if (isset($this->parametres) && !empty($this->parametres)) {
|
121 |
$this->table_param = $parametres;
|
- |
|
122 |
|
69 |
|
123 |
if (isset($parametres['recherche']) && $parametres['recherche'] != '') {
|
70 |
if (isset($this->parametres['recherche']) && $this->parametres['recherche'] != '') {
|
124 |
$this->recherche = $parametres['recherche'];
|
71 |
$this->recherche = $this->parametres['recherche'];
|
125 |
}
|
72 |
}
|
126 |
foreach ($parametres as $param => $valeur) {
|
73 |
foreach ($this->parametres as $param => $valeur) {
|
127 |
switch ($param) {
|
74 |
switch ($param) {
|
- |
|
75 |
case 'masque' :
|
128 |
case 'masque' : $this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);break;
|
76 |
$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
|
- |
|
77 |
break;
|
- |
|
78 |
case 'masque.nt' :
|
129 |
case 'masque_nt' : $this->ajouterLeFiltreMasque('num_taxon', $valeur); break;
|
79 |
$this->ajouterLeFiltreMasque('num_taxon', $valeur);
|
- |
|
80 |
break;
|
- |
|
81 |
case 'masque.nv' :
|
130 |
case 'masque_nv' : $this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);break;
|
82 |
$this->ajouterLeFiltreMasque('nom_vernaculaire', $valeur);
|
- |
|
83 |
break;
|
- |
|
84 |
case 'masque.lg' :
|
131 |
case 'masque_lg' : $this->ajouterLeFiltreMasque('code_langue', $valeur); break;
|
85 |
$this->ajouterLeFiltreMasque('code_langue', $valeur);
|
- |
|
86 |
break;
|
- |
|
87 |
case 'masque.cce' :
|
132 |
case 'masque_cce' : $this->ajouterLeFiltreMasque('num_statut', $valeur); break;
|
88 |
$this->ajouterLeFiltreMasque('num_statut', $valeur);
|
- |
|
89 |
break;
|
- |
|
90 |
case 'retour.format' :
|
133 |
case 'retour_format' : $this->retour_format = $valeur; break;
|
91 |
$this->retour_format = $valeur;
|
- |
|
92 |
break;
|
- |
|
93 |
case 'navigation.depart' :
|
134 |
case 'navigation_depart' : $this->limite_requete['depart'] = $valeur; break;
|
94 |
$this->limite_requete['depart'] = $valeur;
|
- |
|
95 |
break;
|
- |
|
96 |
case 'navigation.limite' :
|
135 |
case 'navigation_limite' : $this->limite_requete['limite'] = $valeur; break;
|
97 |
$this->limite_requete['limite'] = $valeur;
|
- |
|
98 |
break;
|
136 |
case 'recherche' : break;
|
99 |
case 'recherche' :
|
- |
|
100 |
break;
|
- |
|
101 |
default :
|
137 |
default : $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 : '.
|
138 |
'</br> Le paramètre " '.$param.' " n\'existe pas.';
|
103 |
'</br> Le paramètre " '.$param.' " n\'existe pas.';
|
139 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $p); break;
|
104 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $p);
|
140 |
}
|
105 |
}
|
141 |
}
|
106 |
}
|
142 |
}
|
107 |
}
|
143 |
}
|
108 |
}
|
144 |
|
109 |
|
145 |
public function ajouterLeFiltreMasque($nom_champ, $valeur) {
|
110 |
public function ajouterLeFiltreMasque($nom_champ, $valeur) {
|
146 |
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
|
147 |
$this->requete_condition[] = $nom_champ.' = '.$this->getBdd()->proteger($valeur);
|
112 |
$this->requete_condition[] = $nom_champ.' = '.$this->getBdd()->proteger($valeur);
|
148 |
} else {
|
113 |
} else {
|
149 |
if ($this->recherche == 'floue') {
|
114 |
if ($this->recherche == 'floue') {
|
Line 156... |
Line 121... |
156 |
}
|
121 |
}
|
157 |
$this->requete_condition[] = $nom_champ.' LIKE '.$this->getBdd()->proteger($valeur);
|
122 |
$this->requete_condition[] = $nom_champ.' LIKE '.$this->getBdd()->proteger($valeur);
|
158 |
}
|
123 |
}
|
159 |
}
|
124 |
}
|
160 |
}
|
125 |
}
|
161 |
|
- |
|
Line 162... |
Line 126... |
162 |
|
126 |
|
163 |
// +-------------------------------------------------------------------------------------------------------------------+
|
127 |
//+------------------------------------------------------------------------------------------------------+
|
164 |
// 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
|
165 |
public function traiterRessources(&$ressources) {
|
129 |
public function traiterRessources() {
|
166 |
if (isset($ressources) && !empty($ressources)) {
|
- |
|
167 |
$this->table_ressources = $ressources;
|
130 |
if (isset($this->ressources) && !empty($this->ressources)) {
|
168 |
if (isset($this->table_ressources[0]) && !empty($this->table_ressources[0])) {
|
131 |
if (isset($this->ressources[0]) && !empty($this->ressources[0])) {
|
169 |
$this->traiterRessourceId(); // ajoute condition id=#valeur
|
132 |
$this->traiterRessourceId(); // ajoute condition id=#valeur
|
170 |
if (isset($this->table_ressources[1]) && !empty($this->table_ressources[1])) {
|
133 |
if (isset($this->ressources[1]) && !empty($this->ressources[1])) {
|
171 |
$this->traiterRessourceChampOuRelations(); //modifie requete_champ ou requete_condition
|
134 |
$this->traiterRessourceChampOuRelations(); //modifie requete_champ ou requete_condition
|
172 |
}
|
135 |
}
|
173 |
}
|
136 |
}
|
174 |
} 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
|
175 |
$this->requete_champ = array('distinct(id)', 'nom_vernaculaire ');
|
138 |
$this->requete_champ = array('distinct(id)', 'nom_vernaculaire ');
|
176 |
}
|
139 |
}
|
177 |
}
|
140 |
}
|
178 |
|
141 |
|
179 |
//requete : /noms-vernaculaires/#id (ex : /noms-vernaculaires/7)
|
142 |
//requete : /noms-vernaculaires/#id (ex : /noms-vernaculaires/7)
|
180 |
public function traiterRessourceId() {
|
143 |
public function traiterRessourceId() {
|
181 |
if (is_numeric($this->table_ressources[0])) {
|
144 |
if (is_numeric($this->ressources[0])) {
|
182 |
$this->requete_condition[] = ' id = '.$this->getBdd()->proteger($this->table_ressources[0]);
|
145 |
$this->requete_condition[] = ' id = '.$this->getBdd()->proteger($this->ressources[0]);
|
183 |
$this->format_reponse .= '/id';
|
146 |
$this->format_reponse .= '/id';
|
184 |
} else {
|
147 |
} else {
|
185 |
$r = 'Erreur dans les ressources de votre requête : </br> La ressource " '.$this->table_ressources[0].
|
148 |
$r = 'Erreur dans les ressources de votre requête : </br> La ressource " '.$this->ressources[0].
|
186 |
' " n\'existe pas.';
|
149 |
' " n\'existe pas.';
|
187 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $r);
|
150 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $r);
|
188 |
}
|
151 |
}
|
189 |
}
|
152 |
}
|
190 |
|
153 |
|
191 |
|
154 |
|
192 |
public function traiterRessourceChampOuRelations() {
|
155 |
public function traiterRessourceChampOuRelations() {
|
193 |
//requete = /noms-vernaculaires/#id/relations :
|
156 |
//requete = /noms-vernaculaires/#id/relations :
|
194 |
if ($this->table_ressources[1] == 'relations') {
|
157 |
if ($this->ressources[1] == 'relations') {
|
195 |
$this->format_reponse .= '/relations';
|
158 |
$this->format_reponse .= '/relations';
|
196 |
$this->requete_condition[] = 'num_taxon = (SELECT region FROM '.$this->table.' WHERE '
|
159 |
$this->requete_condition[] = 'num_taxon = (SELECT region FROM '.$this->table.' WHERE '
|
197 |
.implode(' AND ', $this->requete_condition).')';
|
160 |
.implode(' AND ', $this->requete_condition).')';
|
198 |
//requete = /noms-vernaculaires/#id/#champ :
|
161 |
//requete = /noms-vernaculaires/#id/#champ :
|
199 |
} else {
|
162 |
} else {
|
200 |
$this->format_reponse .= '/champ';
|
163 |
$this->format_reponse .= '/champ';
|
201 |
$this->analyserChamp();
|
164 |
$this->analyserChamp();
|
202 |
}
|
165 |
}
|
203 |
}
|
166 |
}
|
204 |
|
167 |
|
205 |
public function analyserChamp() {
|
168 |
public function analyserChamp() {
|
206 |
$this->requete_champ = array();
|
169 |
$this->requete_champ = array();
|
207 |
$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 |
|
208 |
$champs = explode(' ', $this->table_ressources[1]);
|
171 |
$champs = explode(' ', $this->ressources[1]);
|
209 |
foreach ($champs as $champ) {
|
172 |
foreach ($champs as $champ) {
|
210 |
preg_match('/^([^.]+)(\.([^.]+))?$/', $champ, $match);
|
173 |
preg_match('/^([^.]+)(\.([^.]+))?$/', $champ, $match);
|
211 |
if (isset($this->champs_possibles[$match[1]])) {
|
174 |
if (isset($this->champs_possibles[$match[1]])) {
|
212 |
$this->requete_champ[] = str_replace('|', ', ', $this->champs_possibles[$match[1]]);
|
175 |
$this->requete_champ[] = str_replace('|', ', ', $this->champs_possibles[$match[1]]);
|
Line 218... |
Line 181... |
218 |
'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").';
|
219 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $c);
|
182 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $c);
|
220 |
}
|
183 |
}
|
221 |
}
|
184 |
}
|
222 |
}
|
185 |
}
|
223 |
|
186 |
|
224 |
// +-------------------------------------------------------------------------------------------------------------------+
|
187 |
//+------------------------------------------------------------------------------------------------------+
|
225 |
public function assemblerLaRequete() {
|
188 |
public function assemblerLaRequete() {
|
226 |
$requete = ' SELECT '.$this->formerRequeteChamp().
|
189 |
$requete = ' SELECT '.$this->formerRequeteChamp().
|
227 |
' FROM '.$this->table
|
190 |
' FROM '.$this->table
|
228 |
.$this->formerRequeteCondition()
|
191 |
.$this->formerRequeteCondition()
|
229 |
.$this->formerRequeteLimite();
|
192 |
.$this->formerRequeteLimite();
|
230 |
return $requete;
|
193 |
return $requete;
|
231 |
}
|
194 |
}
|
232 |
|
195 |
|
233 |
public function formerRequeteChamp() {
|
196 |
public function formerRequeteChamp() {
|
234 |
if (in_array('*', $this->requete_champ)) {
|
197 |
if (in_array('*', $this->requete_champ)) {
|
235 |
$champ = ' * ';
|
198 |
$champ = ' * ';
|
236 |
} else {
|
199 |
} else {
|
237 |
$champ = implode(', ', $this->requete_champ);
|
200 |
$champ = implode(', ', $this->requete_champ);
|
238 |
}
|
201 |
}
|
239 |
return $champ;
|
202 |
return $champ;
|
240 |
}
|
203 |
}
|
241 |
|
204 |
|
242 |
public function formerRequeteCondition() {
|
205 |
public function formerRequeteCondition() {
|
243 |
$condition = '';
|
206 |
$condition = '';
|
244 |
if ($this->requete_condition != null) {
|
207 |
if ($this->requete_condition != null) {
|
245 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
208 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
246 |
}
|
209 |
}
|
247 |
return $condition;
|
210 |
return $condition;
|
248 |
}
|
211 |
}
|
249 |
|
212 |
|
250 |
//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
|
251 |
// suivantes : /noms-vernaculaires et /noms-vernaculaires/#id/relations)
|
214 |
// suivantes : /noms-vernaculaires et /noms-vernaculaires/#id/relations)
|
252 |
public function formerRequeteLimite() {
|
215 |
public function formerRequeteLimite() {
|
253 |
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'))) {
|
254 |
$this->requete_limite = '';
|
217 |
$this->requete_limite = '';
|
255 |
} elseif (($depart = $this->limite_requete['depart']) > ($this->total_resultat = $this->recupererTotalResultat())) {
|
218 |
} elseif (($depart = $this->limite_requete['depart']) > ($this->total_resultat = $this->recupererTotalResultat())) {
|
256 |
$this->limite_requete['depart'] =
|
219 |
$this->limite_requete['depart'] =
|
257 |
(($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']);
|
258 |
$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'];
|
259 |
} else {
|
222 |
} else {
|
260 |
$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'];
|
261 |
}
|
224 |
}
|
262 |
return $this->requete_limite;
|
225 |
return $this->requete_limite;
|
263 |
}
|
226 |
}
|
264 |
|
227 |
|
265 |
//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)
|
266 |
public function recupererTotalResultat() {
|
229 |
public function recupererTotalResultat() {
|
267 |
$requete = 'SELECT count(distinct(id)) as nombre FROM '
|
230 |
$requete = 'SELECT count(distinct(id)) as nombre FROM '
|
268 |
.$this->table
|
231 |
.$this->table
|
269 |
.$this->formerRequeteCondition();
|
232 |
.$this->formerRequeteCondition();
|
270 |
$res = $this->getBdd()->recuperer($requete);
|
233 |
$res = $this->getBdd()->recuperer($requete);
|
271 |
|
234 |
|
272 |
if ($res) {
|
235 |
if ($res) {
|
273 |
$total = $res['nombre'];
|
236 |
$total = $res['nombre'];
|
274 |
} else {
|
237 |
} else {
|
275 |
$t = 'Fonction recupererTotalResultat() : <br/>Données introuvables dans la base';
|
238 |
$t = 'Fonction recupererTotalResultat() : <br/>Données introuvables dans la base';
|
276 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $t);
|
239 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $t);
|
277 |
}
|
240 |
}
|
278 |
return $total;
|
241 |
return $total;
|
279 |
}
|
242 |
}
|
280 |
|
243 |
|
281 |
// +-------------------------------------------------------------------------------------------------------------------+
|
244 |
//+------------------------------------------------------------------------------------------------------+
|
282 |
// 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 |
|
283 |
// /noms-vernaculaires/#id/relations) le format du tableau à retourner.
|
246 |
// /noms-vernaculaires/#id/relations) le format du tableau à retourner.
|
284 |
public function retournerResultatFormate($resultat) {
|
247 |
public function retournerResultatFormate($resultat) {
|
285 |
$this->recupererTableConfig('correspondance_champs');
|
248 |
$this->recupererTableConfig('correspondance_champs');
|
286 |
switch ($this->format_reponse) {
|
249 |
switch ($this->format_reponse) {
|
287 |
case 'noms-vernaculaires' : $reponse = $this->formaterNomsVernaculaires($resultat); break;
|
250 |
case 'noms-vernaculaires' : $reponse = $this->formaterNomsVernaculaires($resultat); break;
|
Line 289... |
Line 252... |
289 |
case 'noms-vernaculaires/id/champ' : $reponse = $this->formaterNomsVernaculairesIdChamp($resultat); break;
|
252 |
case 'noms-vernaculaires/id/champ' : $reponse = $this->formaterNomsVernaculairesIdChamp($resultat); break;
|
290 |
default : break;
|
253 |
default : break;
|
291 |
}
|
254 |
}
|
292 |
return $reponse;
|
255 |
return $reponse;
|
293 |
}
|
256 |
}
|
294 |
|
257 |
|
295 |
public function formaterNomsVernaculaires($resultat) {
|
258 |
public function formaterNomsVernaculaires($resultat) {
|
296 |
//on remplit la table $table_retour_json['entete']
|
259 |
//on remplit la table $table_retour_json['entete']
|
297 |
$table_retour_json['entete']['depart'] = $this->limite_requete['depart'];
|
260 |
$table_retour_json['entete']['depart'] = $this->limite_requete['depart'];
|
298 |
$table_retour_json['entete']['limite'] = $this->limite_requete['limite'];
|
261 |
$table_retour_json['entete']['limite'] = $this->limite_requete['limite'];
|
299 |
$table_retour_json['entete']['total'] = $this->total_resultat;
|
262 |
$table_retour_json['entete']['total'] = $this->total_resultat;
|
300 |
$url = $this->formulerUrl($this->total_resultat, '/noms-vernaculaires');
|
263 |
$url = $this->formulerUrl($this->total_resultat, '/noms-vernaculaires');
|
301 |
if ($url['precedent'] != '') { $table_retour_json['entete']['href.precedent'] = $url['precedent']; }
|
264 |
if (isset($url['precedent']) && $url['precedent'] != '') { $table_retour_json['entete']['href.precedent'] = $url['precedent']; }
|
302 |
if ($url['suivant'] != '') { $table_retour_json['entete']['href.suivant'] = $url['suivant']; }
|
265 |
if (isset($url['suivant']) && $url['suivant'] != '') { $table_retour_json['entete']['href.suivant'] = $url['suivant']; }
|
303 |
|
266 |
|
304 |
//on remplit la table $table_retour_json['resultat']
|
267 |
//on remplit la table $table_retour_json['resultat']
|
305 |
if (isset($this->table_param['masque_nv'])) {
|
268 |
if (isset($this->parametres['masque_nv'])) {
|
306 |
$resultat = $this->trierRechercheFloue($this->table_param['masque_nv'], $resultat, 'nom_vernaculaire');
|
269 |
$resultat = $this->trierRechercheFloue($this->parametres['masque_nv'], $resultat, 'nom_vernaculaire');
|
307 |
}
|
270 |
}
|
308 |
foreach ($resultat as $tab) {
|
271 |
foreach ($resultat as $tab) {
|
309 |
foreach ($tab as $key => $valeur) {
|
272 |
foreach ($tab as $key => $valeur) {
|
310 |
if ($valeur != '') {
|
273 |
if ($valeur != '') {
|
311 |
switch ($key) {
|
274 |
switch ($key) {
|
Line 317... |
Line 280... |
317 |
}
|
280 |
}
|
318 |
if ($this->retour_format == 'max') $this->table_retour['href'] = $this->ajouterHref('noms-vernaculaires', $num);
|
281 |
if ($this->retour_format == 'max') $this->table_retour['href'] = $this->ajouterHref('noms-vernaculaires', $num);
|
319 |
$resultat_json[$num] = $this->table_retour;
|
282 |
$resultat_json[$num] = $this->table_retour;
|
320 |
$this->table_retour = array();
|
283 |
$this->table_retour = array();
|
321 |
}
|
284 |
}
|
322 |
|
285 |
|
323 |
$table_retour_json['resultat'] = $resultat_json;
|
286 |
$table_retour_json['resultat'] = $resultat_json;
|
324 |
return $table_retour_json;
|
287 |
return $table_retour_json;
|
325 |
}
|
288 |
}
|
326 |
|
289 |
|
327 |
// formatage de la reponse /id ss la forme
|
290 |
// formatage de la reponse /id ss la forme
|
328 |
// id, nom_vernaculaire, attributions
|
291 |
// id, nom_vernaculaire, attributions
|
329 |
// langue
|
292 |
// langue
|
330 |
// num_nom (correspond à un taxon bdtfx)
|
293 |
// num_nom (correspond à un taxon bdtfx)
|
331 |
public function formaterNomsVernaculairesId($resultat) {
|
294 |
public function formaterNomsVernaculairesId($resultat) {
|
Line 333... |
Line 296... |
333 |
// on crée les variables qui serviront de clés et on les enléves du tableau
|
296 |
// on crée les variables qui serviront de clés et on les enléves du tableau
|
334 |
$num_nom = $taxon['num_nom_vernaculaire']; // unique pour un trinôme id, langue, taxon
|
297 |
$num_nom = $taxon['num_nom_vernaculaire']; // unique pour un trinôme id, langue, taxon
|
335 |
unset($taxon['num_nom_vernaculaire']);
|
298 |
unset($taxon['num_nom_vernaculaire']);
|
336 |
$langue = $taxon['code_langue'];
|
299 |
$langue = $taxon['code_langue'];
|
337 |
unset($taxon['code_langue']);
|
300 |
unset($taxon['code_langue']);
|
338 |
|
301 |
|
339 |
foreach ($this->correspondance_champs as $key => $correspondance) { // ordonne les infos pour affichage
|
302 |
foreach ($this->correspondance_champs as $key => $correspondance) { // ordonne les infos pour affichage
|
340 |
if (isset($taxon[$key]) && $taxon[$key] != "") {
|
303 |
if (isset($taxon[$key]) && $taxon[$key] != "") {
|
341 |
$this->afficherDonnees($correspondance, $taxon[$key], $langue, $num_nom);
|
304 |
$this->afficherDonnees($correspondance, $taxon[$key], $langue, $num_nom);
|
342 |
}
|
305 |
}
|
343 |
}
|
306 |
}
|
Line 350... |
Line 313... |
350 |
}
|
313 |
}
|
351 |
if ($this->retour_format == 'max') $this->afficherTaxons(); // va chercher les noms de tous les taxons
|
314 |
if ($this->retour_format == 'max') $this->afficherTaxons(); // va chercher les noms de tous les taxons
|
352 |
unset($this->table_retour['href']);
|
315 |
unset($this->table_retour['href']);
|
353 |
return $this->table_retour;
|
316 |
return $this->table_retour;
|
354 |
}
|
317 |
}
|
355 |
|
318 |
|
356 |
public function afficherDonnees($champ, $valeur, $langue = '', $num_nom = '') {
|
319 |
public function afficherDonnees($champ, $valeur, $langue = '', $num_nom = '') {
|
357 |
if ($champ == 'id' || $champ == 'nom_vernaculaire') {
|
320 |
if ($champ == 'id' || $champ == 'nom_vernaculaire') {
|
358 |
$this->table_retour[$champ] = $valeur;
|
321 |
$this->table_retour[$champ] = $valeur;
|
359 |
} elseif (preg_match('/^(.*)\.code$/', $champ, $match)) {
|
322 |
} elseif (preg_match('/^(.*)\.code$/', $champ, $match)) {
|
360 |
switch ($match[1]) {
|
323 |
switch ($match[1]) {
|
361 |
case 'taxon' : if ($this->retour_format == 'max') {$this->taxons[$num_nom] = $valeur;}
|
324 |
case 'taxon' : if ($this->retour_format == 'max') {$this->taxons[$num_nom] = $valeur;}
|
362 |
$this->afficherPointCode($match[1], $langue, $num_nom, $valeur); break;
|
325 |
$this->afficherPointCode($match[1], $langue, $num_nom, $valeur); break;
|
363 |
case 'langue' : //$this->afficherPointCode($match[1], 'iso-639-3', 'langues', $valeur);
|
326 |
case 'langue' : //$this->afficherPointCode($match[1], 'iso-639-3', 'langues', $valeur);
|
364 |
break;
|
327 |
break;
|
365 |
case 'genre' : $this->afficherPointCode($match[1], $langue, $num_nom, $valeur); break;
|
328 |
case 'genre' : $this->afficherPointCode($match[1], $langue, $num_nom, $valeur); break;
|
366 |
case 'conseil_emploi' : $this->afficherPointCode($match[1], $langue, $num_nom, $valeur); break;
|
329 |
case 'conseil_emploi' : $this->afficherPointCode($match[1], $langue, $num_nom, $valeur); break;
|
367 |
default : break;
|
330 |
default : break;
|
368 |
}
|
331 |
}
|
369 |
|
332 |
|
370 |
} elseif ($langue != '') {
|
333 |
} elseif ($langue != '') {
|
371 |
$this->table_retour['attributions'][$langue][$num_nom][$champ] = $valeur;
|
334 |
$this->table_retour['attributions'][$langue][$num_nom][$champ] = $valeur;
|
372 |
} else {
|
335 |
} else {
|
373 |
$this->table_retour[$champ] = $valeur;
|
336 |
$this->table_retour[$champ] = $valeur;
|
374 |
}
|
337 |
}
|
375 |
}
|
338 |
}
|
376 |
|
339 |
|
377 |
public function afficherPointCode($nomChamp, $langue, $num_nom, $valeur) {
|
340 |
public function afficherPointCode($nomChamp, $langue, $num_nom, $valeur) {
|
378 |
if (isset($this->champ_infos[$nomChamp])) {
|
341 |
if (isset($this->champ_infos[$nomChamp])) {
|
379 |
extract($this->champ_infos[$nomChamp]);
|
342 |
extract($this->champ_infos[$nomChamp]);
|
380 |
}
|
343 |
}
|
381 |
|
344 |
|
382 |
if ($this->retour_format == 'max') {
|
345 |
if ($this->retour_format == 'max') {
|
383 |
$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
|
346 |
$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
|
384 |
if ($service == 'taxons') {
|
347 |
if ($service == 'taxons') {
|
385 |
$code_valeur = '';
|
348 |
$code_valeur = '';
|
386 |
} else {
|
349 |
} else {
|
387 |
$code_valeur = $this->chercherSignificationCode($url, $nom);
|
350 |
$code_valeur = $this->chercherSignificationCode($url, $nom);
|
388 |
}
|
351 |
}
|
389 |
if ($projet != '') $projet .= '.';
|
352 |
if ($projet != '') $projet .= '.';
|
390 |
$this->table_retour['attributions'][$langue][$num_nom][$nomChamp] = $code_valeur;
|
353 |
$this->table_retour['attributions'][$langue][$num_nom][$nomChamp] = $code_valeur;
|
391 |
$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
354 |
$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
Line 393... |
Line 356... |
393 |
} else {
|
356 |
} else {
|
394 |
if ($projet != '') $projet .= '.';
|
357 |
if ($projet != '') $projet .= '.';
|
395 |
$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
358 |
$this->table_retour['attributions'][$langue][$num_nom][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
396 |
}
|
359 |
}
|
397 |
}
|
360 |
}
|
398 |
|
361 |
|
399 |
public function chercherSignificationCode($url, $nom) {
|
362 |
public function chercherSignificationCode($url, $nom) {
|
400 |
if (isset($this->signification_code[$url])) {
|
363 |
if (isset($this->signification_code[$url])) {
|
401 |
$valeur = $this->signification_code[$url];
|
364 |
$valeur = $this->signification_code[$url];
|
402 |
} else {
|
365 |
} else {
|
403 |
$res = $this->consulterHref($url);
|
366 |
$res = $this->consulterHref($url);
|
404 |
$valeur = $res->$nom;
|
367 |
$valeur = $res->$nom;
|
405 |
$this->signification_code[$url] = $valeur;
|
368 |
$this->signification_code[$url] = $valeur;
|
406 |
}
|
369 |
}
|
407 |
return $valeur;
|
370 |
return $valeur;
|
408 |
}
|
371 |
}
|
409 |
|
372 |
|
410 |
public function afficherTaxons() {
|
373 |
public function afficherTaxons() {
|
411 |
$url = Config::get('url_service_base').'bdtfx/taxons?navigation.limite=500&masque.nt='.$this->getBdd()->proteger(implode(',', $this->taxons));
|
374 |
$url = Config::get('url_service_base').'bdtfx/taxons?navigation.limite=500&masque.nt='.$this->getBdd()->proteger(implode(',', $this->taxons));
|
412 |
$res = $this->consulterHref($url);
|
375 |
$res = $this->consulterHref($url);
|
413 |
foreach ($res->resultat as $id=>$taxon) {
|
376 |
foreach ($res->resultat as $id=>$taxon) {
|
414 |
$resultat[$taxon->num_taxonomique] = $taxon->nom_sci;
|
377 |
$resultat[$taxon->num_taxonomique] = $taxon->nom_sci;
|
Line 421... |
Line 384... |
421 |
}
|
384 |
}
|
422 |
}
|
385 |
}
|
423 |
}
|
386 |
}
|
424 |
}
|
387 |
}
|
Line 425... |
Line -... |
425 |
|
- |
|
426 |
|
- |
|
427 |
|
- |
|
428 |
|
388 |
|
429 |
public function formaterNomsVernaculairesIdChamp($resultat) {
|
389 |
public function formaterNomsVernaculairesIdChamp($resultat) {
|
430 |
$this->table_retour['id'] = $this->table_ressources[0];
|
390 |
$this->table_retour['id'] = $this->ressources[0];
|
431 |
$champs = explode(' ', $this->table_ressources[1]);
|
391 |
$champs = explode(' ', $this->ressources[1]);
|
432 |
if (in_array('attributions', $champs) != false) {
|
392 |
if (in_array('attributions', $champs) != false) {
|
433 |
$this->formaterNomsVernaculairesId($resultat);
|
393 |
$this->formaterNomsVernaculairesId($resultat);
|
434 |
unset($this->table_retour['nom_vernaculaire']);
|
394 |
unset($this->table_retour['nom_vernaculaire']);
|
435 |
} else {//print_r($resultat);
|
395 |
} else {//print_r($resultat);
|
Line 448... |
Line 408... |
448 |
}
|
408 |
}
|
449 |
if (in_array('biblio', $champs) != false && array_search('biblio.num_ref', $this->table_retour) != false) $this->table_retour['biblio'] = null;
|
409 |
if (in_array('biblio', $champs) != false && array_search('biblio.num_ref', $this->table_retour) != false) $this->table_retour['biblio'] = null;
|
450 |
}
|
410 |
}
|
451 |
return $this->table_retour;
|
411 |
return $this->table_retour;
|
452 |
}
|
412 |
}
|
453 |
|
413 |
|
454 |
public function afficherPoint($champ, $valeur, $langue, $num_nom) {
|
414 |
public function afficherPoint($champ, $valeur, $langue, $num_nom) {
|
455 |
preg_match('/^(.*)\.code$/', $champ, $match);
|
415 |
preg_match('/^(.*)\.code$/', $champ, $match);
|
456 |
$champ = $match[1];
|
416 |
$champ = $match[1];
|
457 |
if (isset($this->champ_infos[$champ])) {
|
417 |
if (isset($this->champ_infos[$champ])) {
|
458 |
extract($this->champ_infos[$champ]);
|
418 |
extract($this->champ_infos[$champ]);
|
459 |
$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
|
419 |
$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur, $projet);
|
460 |
$projet .= '.';
|
420 |
$projet .= '.';
|
461 |
}
|
421 |
}
|
462 |
|
422 |
|
463 |
$champs = explode(' ', $this->table_ressources[1]);
|
423 |
$champs = explode(' ', $this->ressources[1]);
|
464 |
if (in_array($champ.'.*', $champs) !== false && isset($projet)) {
|
424 |
if (in_array($champ.'.*', $champs) !== false && isset($projet)) {
|
465 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
|
425 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
|
466 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
|
426 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
|
467 |
}
|
427 |
}
|
468 |
if (in_array($champ.'.code', $champs) !== false && isset($projet)) {
|
428 |
if (in_array($champ.'.code', $champs) !== false && isset($projet)) {
|
469 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
|
429 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.code'] = $projet.$ressource.$valeur;
|
470 |
}
|
430 |
}
|
471 |
if (in_array($champ.'.href', $champs) !== false && isset($projet)) {
|
431 |
if (in_array($champ.'.href', $champs) !== false && isset($projet)) {
|
472 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
|
432 |
$this->table_retour['attributions'][$langue][$num_nom][$champ.'.href'] = $url;
|
473 |
}
|
433 |
}
|
474 |
if (in_array($champ, $champs) !== false) {
|
434 |
if (in_array($champ, $champs) !== false) {
|
475 |
if (isset($url)) {
|
435 |
if (isset($url)) {
|
476 |
$this->table_retour['attributions'][$langue][$num_nom][$champ] = $this->chercherSignificationCode($url, $nom);
|
436 |
$this->table_retour['attributions'][$langue][$num_nom][$champ] = $this->chercherSignificationCode($url, $nom);
|
477 |
} else {
|
437 |
} else {
|
478 |
$this->table_retour['attributions'][$langue][$champ] = $valeur;
|
438 |
$this->table_retour['attributions'][$langue][$champ] = $valeur;
|
479 |
}
|
439 |
}
|
480 |
}
|
440 |
}
|
481 |
}
|
441 |
}
|
Line 482... |
Line -... |
482 |
|
- |
|
483 |
|
442 |
|
484 |
public function afficherLangue($nomChamp, $projet, $service, $valeur, $ressource = '', $nom = 'nom') {
|
443 |
public function afficherLangue($nomChamp, $projet, $service, $valeur, $ressource = '', $nom = 'nom') {
|
485 |
if ($this->retour_format == 'max') {
|
444 |
if ($this->retour_format == 'max') {
|
486 |
$this->table_retour['attributions'][$nomChamp] = $nom;
|
445 |
$this->table_retour['attributions'][$nomChamp] = $nom;
|
487 |
$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
446 |
$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
488 |
$this->table_retour['attributions'][$nomChamp.'.href'] = $url;
|
447 |
$this->table_retour['attributions'][$nomChamp.'.href'] = $url;
|
489 |
} else {
|
448 |
} else {
|
490 |
$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
449 |
$this->table_retour['attributions'][$nomChamp.'.code'] = $projet.$ressource.$valeur;
|
491 |
}
|
450 |
}
|
492 |
}
|
451 |
}
|
493 |
|
452 |
|
494 |
public function chargerBiblio($num_nom, $langue) {
|
453 |
public function chargerBiblio($num_nom, $langue) {
|
495 |
list($table, $version) = explode('_v',$this->table);
|
454 |
list($table, $version) = explode('_v',$this->table);
|
496 |
$requete = "SELECT b.*, lb.notes FROM nvjfl_lien_biblio_v$version lb, nvjfl_biblio_v$version b ".
|
455 |
$requete = "SELECT b.*, lb.notes FROM nvjfl_lien_biblio_v$version lb, nvjfl_biblio_v$version b ".
|
497 |
"WHERE b.num_ref = lb.num_ref AND lb.num_nom = '$num_nom' ;";
|
456 |
"WHERE b.num_ref = lb.num_ref AND lb.num_nom = '$num_nom' ;";
|
498 |
$resultat = $this->getBdd()->recupererTous($requete); //Debug::printr($resultat);
|
457 |
$resultat = $this->getBdd()->recupererTous($requete); //Debug::printr($resultat);
|
499 |
|
458 |
|
500 |
if ($resultat == '') { //cas ou la requete comporte des erreurs
|
459 |
if ($resultat == '') { //cas ou la requete comporte des erreurs
|
501 |
$r = 'La requête SQL formée comporte une erreur !!';
|
460 |
$r = 'La requête SQL formée comporte une erreur !!';
|
502 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $r);
|
461 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $r);
|
503 |
Debug::printr($requete);
|
462 |
Debug::printr($requete);
|
Line 509... |
Line 468... |
509 |
}
|
468 |
}
|
510 |
}
|
469 |
}
|
511 |
}
|
470 |
}
|
512 |
}
|
471 |
}
|
513 |
}
|
472 |
}
|
514 |
|
473 |
|
515 |
}
|
474 |
}
|
516 |
?>
|
475 |
?>
|
517 |
|
476 |
|