452 |
mathilde |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Classe InformationsBaseflor.php permet de faire des requetes de baseflor en fonction d'un référentiel
|
499 |
jpm |
5 |
*( BDTFX, BDAFX, BDBFX ) et d'un numéro nomenclatural ( différent de 0 ).
|
452 |
mathilde |
6 |
* fin d'url possibles :
|
|
|
7 |
* /informations/#bdnt.nn:#num_nomen --> retourne tous les champs pour un BDNT et un num_nomen
|
|
|
8 |
* /informations/#bdnt.nn:#num_nomen?champs=description --> retourne champs description pour un BDNT et un num_nomen
|
|
|
9 |
* /informations/#bdnt.nn:#num_nomen?champs=ecologie --> retourne champs ecologiques pour un BDNT et un num_nomen
|
548 |
mathilde |
10 |
*
|
452 |
mathilde |
11 |
*
|
|
|
12 |
* Encodage en entrée : utf8
|
|
|
13 |
* Encodage en sortie : utf8
|
|
|
14 |
* @package eflore-projets
|
|
|
15 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
|
|
16 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
|
|
|
17 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
18 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
19 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
20 |
* @version 1.0
|
|
|
21 |
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
class InformationsBaseflor extends Commun{
|
499 |
jpm |
25 |
|
452 |
mathilde |
26 |
protected $table = "";
|
|
|
27 |
private $format_reponse = 'informations';
|
|
|
28 |
private $retour_format = 'max';
|
|
|
29 |
private $champs_ontologiques = array();
|
|
|
30 |
protected $serviceNom = 'informations';
|
525 |
mathilde |
31 |
private $Bdd;
|
548 |
mathilde |
32 |
private $requete_condition = "";
|
|
|
33 |
private $champs_recherches = '*';
|
|
|
34 |
private $resultat_json;
|
525 |
mathilde |
35 |
|
499 |
jpm |
36 |
|
452 |
mathilde |
37 |
public function consulter($ressources, $parametres) {
|
|
|
38 |
$this->ressources = $ressources;
|
|
|
39 |
$this->parametres = $parametres;
|
|
|
40 |
$this->traiterParametres();
|
548 |
mathilde |
41 |
$this->definirTables();
|
518 |
mathilde |
42 |
$this->traiterRessources();
|
452 |
mathilde |
43 |
$resultats = null;
|
499 |
jpm |
44 |
foreach ($this->table_version as $version) {
|
548 |
mathilde |
45 |
$this->table = $version;
|
|
|
46 |
$requete = $this->assemblerLaRequete();
|
525 |
mathilde |
47 |
$resultat = $this->Bdd->recupererTous($requete);
|
|
|
48 |
$versionResultat = $this->analyserResultat($resultat);
|
452 |
mathilde |
49 |
if (count($this->table_version) > 1) {
|
|
|
50 |
$resultats[$version] = $versionResultat;
|
|
|
51 |
} else {
|
|
|
52 |
$resultats = $versionResultat;
|
|
|
53 |
}
|
|
|
54 |
}
|
499 |
jpm |
55 |
return $resultats;
|
452 |
mathilde |
56 |
}
|
499 |
jpm |
57 |
|
525 |
mathilde |
58 |
public function __construct(Conteneur $Conteneur) {
|
|
|
59 |
$this->Bdd = $Conteneur->getBdd();
|
|
|
60 |
}
|
|
|
61 |
|
548 |
mathilde |
62 |
|
525 |
mathilde |
63 |
public function analyserResultat($resultat) {
|
452 |
mathilde |
64 |
$versionResultat = null;
|
|
|
65 |
if ($resultat == '') {
|
|
|
66 |
$message = 'La requête SQL formée comporte une erreur!';
|
|
|
67 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
|
|
68 |
throw new Exception($message, $code);
|
|
|
69 |
} elseif ($resultat) {
|
525 |
mathilde |
70 |
$versionResultat = $this->retournerResultatFormate($resultat);
|
499 |
jpm |
71 |
}
|
452 |
mathilde |
72 |
return $versionResultat;
|
|
|
73 |
}
|
499 |
jpm |
74 |
|
|
|
75 |
//+--------------------------traitement ressources ou paramètres -------------------------------------------+
|
452 |
mathilde |
76 |
public function traiterParametres() {
|
|
|
77 |
if (isset($this->parametres) && !empty($this->parametres)) {
|
|
|
78 |
foreach ($this->parametres as $param => $valeur) {
|
|
|
79 |
switch ($param) {
|
516 |
mathilde |
80 |
case 'categorie' :
|
452 |
mathilde |
81 |
if ($valeur == "description") {
|
548 |
mathilde |
82 |
$this->champs_recherches = "num_nomen, BDNT, chorologie, inflorescence,"
|
499 |
jpm |
83 |
." sexualite, ordre_maturation, "
|
|
|
84 |
."pollinisation, fruit, dissemination, couleur_fleur, macule, floraison, type_bio, "
|
|
|
85 |
."form_vegetale ";
|
548 |
mathilde |
86 |
$this->requete_condition[] = "( chorologie != '' OR inflorescence != '' ".
|
499 |
jpm |
87 |
"OR sexualite != '' OR ordre_maturation != '' OR pollinisation != '' ".
|
|
|
88 |
"OR fruit != '' OR dissemination != '' OR couleur_fleur != '' OR macule != '' ".
|
|
|
89 |
"OR floraison != '' OR type_bio != '' OR form_vegetale != '' )";
|
|
|
90 |
}elseif ($valeur == "ecologie") {
|
548 |
mathilde |
91 |
$this->champs_recherches = " num_nomen, BDNT, ve_lumiere , ve_temperature,"
|
499 |
jpm |
92 |
." ve_continentalite, ve_humidite_atmos, ve_humidite_edaph, ve_reaction_sol,"
|
517 |
mathilde |
93 |
." ve_nutriments_sol, ve_salinite, ve_texture_sol, ve_mat_org_sol, "
|
|
|
94 |
." vi_lumiere, vi_temperature, vi_continentalite, vi_humidite_edaph,"
|
|
|
95 |
." vi_reaction_sol, vi_nutriments_sol, vi_salinite ";
|
548 |
mathilde |
96 |
$this->requete_condition[] = "( ve_lumiere != '' OR ve_temperature != '' ".
|
466 |
mathilde |
97 |
"OR ve_continentalite != '' OR ve_humidite_atmos != '' ".
|
|
|
98 |
"OR ve_humidite_edaph != '' OR ve_reaction_sol != '' ".
|
|
|
99 |
"OR ve_nutriments_sol != '' OR ve_salinite != '' ".
|
499 |
jpm |
100 |
"OR ve_texture_sol != '' OR ve_mat_org_sol != '' )";
|
|
|
101 |
} else {
|
517 |
mathilde |
102 |
$e = "Valeur de paramètre inconnue pour 'categorie'.";
|
525 |
mathilde |
103 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
452 |
mathilde |
104 |
}
|
|
|
105 |
break;
|
|
|
106 |
case 'retour.format' :
|
517 |
mathilde |
107 |
if ($valeur == 'min' || $valeur == 'max') {
|
|
|
108 |
$this->retour_format = $valeur;
|
|
|
109 |
break;
|
|
|
110 |
} else {
|
|
|
111 |
$e = "Valeur de paramètre inconnue pour 'retour.format'.";
|
525 |
mathilde |
112 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
517 |
mathilde |
113 |
}
|
518 |
mathilde |
114 |
case 'version.projet' :
|
|
|
115 |
$this->traiterVersion($valeur);
|
|
|
116 |
break;
|
452 |
mathilde |
117 |
default :
|
|
|
118 |
$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
|
|
|
119 |
.$param.' " n\'existe pas.';
|
525 |
mathilde |
120 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
|
|
121 |
break;
|
452 |
mathilde |
122 |
}
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
}
|
517 |
mathilde |
126 |
|
|
|
127 |
|
452 |
mathilde |
128 |
|
|
|
129 |
public function traiterRessources() {
|
525 |
mathilde |
130 |
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)){
|
452 |
mathilde |
131 |
switch ($retour[1]) {
|
|
|
132 |
case 'bdtfx' :
|
548 |
mathilde |
133 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDTFX' ";
|
452 |
mathilde |
134 |
break;
|
|
|
135 |
case 'bdafx' :
|
548 |
mathilde |
136 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDAFX' ";
|
452 |
mathilde |
137 |
break;
|
|
|
138 |
case 'bdbfx' :
|
548 |
mathilde |
139 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDBFX' ";
|
452 |
mathilde |
140 |
break;
|
|
|
141 |
default :
|
516 |
mathilde |
142 |
$e = 'Erreur dans l\'url de votre requête : </br> Le référentiel " '
|
452 |
mathilde |
143 |
.$retour[1].' " n\'existe pas.';
|
525 |
mathilde |
144 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
452 |
mathilde |
145 |
break;
|
499 |
jpm |
146 |
}
|
|
|
147 |
|
516 |
mathilde |
148 |
} else {
|
|
|
149 |
$e = 'Erreur dans l\'url de votre requête : </br> La ressource demandée n\'existe pas.';
|
525 |
mathilde |
150 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
516 |
mathilde |
151 |
break;
|
452 |
mathilde |
152 |
}
|
|
|
153 |
}
|
518 |
mathilde |
154 |
|
|
|
155 |
//+++------------------------------traitement des versions----------------------------------------++
|
|
|
156 |
|
|
|
157 |
public function traiterVersion($valeur) {
|
|
|
158 |
if (preg_match('/^[0-9]+(?:[._][0-9]+)*$/', $valeur) || $valeur == '*' || $valeur == '+') {
|
|
|
159 |
$this->version_projet = $valeur;
|
|
|
160 |
} else {
|
|
|
161 |
$e = "Erreur : La version est inconnue.";
|
525 |
mathilde |
162 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
518 |
mathilde |
163 |
}
|
525 |
mathilde |
164 |
|
518 |
mathilde |
165 |
}
|
|
|
166 |
|
548 |
mathilde |
167 |
public function definirTables() {
|
518 |
mathilde |
168 |
$table_num_version = $this->recupererVersionDisponible();
|
|
|
169 |
$prefixe_table = config::get('bdd_table');
|
|
|
170 |
if ( in_array($this->version_projet,$table_num_version) ) {
|
|
|
171 |
$this->table_version[] = $prefixe_table.'_v'.$this->version_projet;
|
|
|
172 |
} elseif ($this->version_projet == '+') {
|
|
|
173 |
$derniere_version = $table_num_version[count($table_num_version) - 1];
|
|
|
174 |
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $derniere_version);
|
|
|
175 |
} elseif ($this->version_projet == '*') {
|
|
|
176 |
foreach ($table_num_version as $num_version) {
|
|
|
177 |
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $num_version);
|
|
|
178 |
}
|
|
|
179 |
} else {
|
|
|
180 |
$e = "Erreur : La version est inconnue.";
|
525 |
mathilde |
181 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
518 |
mathilde |
182 |
}
|
|
|
183 |
}
|
|
|
184 |
|
452 |
mathilde |
185 |
//+--------------------------formatages de resultats -------------------------------------------+
|
525 |
mathilde |
186 |
|
452 |
mathilde |
187 |
public function retournerResultatFormate($resultat) {
|
499 |
jpm |
188 |
$resultat_json = $resultat[0];
|
|
|
189 |
if ($this->retour_format == 'max'){
|
516 |
mathilde |
190 |
if (!isset($this->parametres['categorie']) ) {
|
548 |
mathilde |
191 |
$this->formaterResultatsTousChamps($resultat_json);
|
516 |
mathilde |
192 |
} elseif ($this->parametres['categorie'] == 'ecologie') {
|
548 |
mathilde |
193 |
$this->formaterResultatsChampsEcologie($resultat_json);
|
516 |
mathilde |
194 |
} elseif ($this->parametres['categorie'] == 'description') {
|
548 |
mathilde |
195 |
$this->formaterResultatsChampsDescription($resultat_json);
|
499 |
jpm |
196 |
}
|
452 |
mathilde |
197 |
}
|
548 |
mathilde |
198 |
return $this->resultat_json;
|
452 |
mathilde |
199 |
}
|
499 |
jpm |
200 |
|
452 |
mathilde |
201 |
public function formaterResultatsTousChamps($resultat) {
|
548 |
mathilde |
202 |
$this->resultat_json = $resultat;
|
|
|
203 |
$this->traiterTypeBio();
|
|
|
204 |
$graphique_presence = $this->traiterOntologieEcologie() ;
|
|
|
205 |
if ($graphique_presence) {
|
|
|
206 |
$graphique = $this->ajouterLiensGraphique();
|
|
|
207 |
}
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
public function formaterResultatsChampsEcologie($resultat) {
|
|
|
211 |
$this->resultat_json = $resultat;
|
|
|
212 |
$graphique_presence = $this->traiterOntologieEcologie() ;
|
|
|
213 |
if ($graphique_presence) {
|
|
|
214 |
$graphique = $this->ajouterLiensGraphique();
|
452 |
mathilde |
215 |
}
|
548 |
mathilde |
216 |
}
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
public function formaterResultatsChampsDescription($resultat) {
|
|
|
220 |
$this->resultat_json = $resultat;
|
|
|
221 |
$this->traiterTypeBio();
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
public function traiterOntologieEcologie() {
|
|
|
225 |
$donnees_presence = false;
|
452 |
mathilde |
226 |
$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
|
|
|
227 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
548 |
mathilde |
228 |
if ($this->resultat_json[$cle] != ""){
|
|
|
229 |
$donnees_presence = true;
|
|
|
230 |
$this->recupererOntologies($this->resultat_json[$cle], $cle);
|
|
|
231 |
unset($this->resultat_json[$cle]);
|
452 |
mathilde |
232 |
}
|
|
|
233 |
}
|
548 |
mathilde |
234 |
return $donnees_presence;
|
452 |
mathilde |
235 |
}
|
548 |
mathilde |
236 |
|
|
|
237 |
public function traiterTypeBio() {
|
|
|
238 |
if ($this->resultat_json['type_bio'] != ""){
|
|
|
239 |
$tab_ontologie = $this->recupererOntologiePrTypeBio($this->resultat_json['type_bio']);
|
|
|
240 |
unset($this->resultat_json['type_bio']);
|
|
|
241 |
$this->resultat_json= array_merge($this->resultat_json,$tab_ontologie);
|
452 |
mathilde |
242 |
}
|
|
|
243 |
}
|
499 |
jpm |
244 |
|
548 |
mathilde |
245 |
public function ajouterLiensGraphique() {
|
|
|
246 |
$this->resultat_json['graphique_climat']['libelle'] = 'climat';
|
|
|
247 |
$this->resultat_json['graphique_climat']['href'] =
|
|
|
248 |
$this->ajouterHref('graphiques/climat', strtolower($this->resultat_json['BDNT']).'.nn:'.$this->resultat_json['num_nomen']);
|
|
|
249 |
$this->resultat_json['graphique_sol']['libelle'] = 'sol';
|
|
|
250 |
$this->resultat_json['graphique_sol']['href'] =
|
|
|
251 |
$this->ajouterHref('graphiques/sol', strtolower($this->resultat_json['BDNT']).'.nn:'.$this->resultat_json['num_nomen']);
|
452 |
mathilde |
252 |
}
|
517 |
mathilde |
253 |
|
|
|
254 |
|
452 |
mathilde |
255 |
//+--------------------------traitement ontologies -------------------------------------------+
|
518 |
mathilde |
256 |
|
452 |
mathilde |
257 |
public function recupererOntologies($valeur, $champs){
|
518 |
mathilde |
258 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
|
|
259 |
'/ontologies/'.$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur));
|
452 |
mathilde |
260 |
$val = $this->consulterHref($url);
|
548 |
mathilde |
261 |
$this->resultat_json[$champs.'.libelle'] = $val->nom;
|
|
|
262 |
$this->resultat_json[$champs.'.code'] = $valeur;
|
|
|
263 |
$this->resultat_json[$champs.'.href'] = $url;
|
452 |
mathilde |
264 |
}
|
548 |
mathilde |
265 |
|
|
|
266 |
//+-------------ontologie pour le champs type biologique (lire le .txt)---+
|
499 |
jpm |
267 |
|
452 |
mathilde |
268 |
public function recupererOntologiePrTypeBio($type_a_traiter){
|
|
|
269 |
$resultat_typeBio = "";
|
499 |
jpm |
270 |
if ($type_a_traiter != "") {
|
452 |
mathilde |
271 |
$types_prim_sec = $this->separerTypesPrimairesSecondaires($type_a_traiter);
|
548 |
mathilde |
272 |
$types_sstypes = $this->classerPrimSecEnTypesSsTypes($types_prim_sec);
|
|
|
273 |
$resultat_typeBio = $this->formaterJsonTypeBio($types_sstypes, $type_a_traiter );
|
|
|
274 |
}
|
|
|
275 |
return $resultat_typeBio;
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
public function classerPrimSecEnTypesSsTypes($types_prim_sec) {
|
|
|
279 |
$types_sstypes = '';
|
|
|
280 |
foreach ($types_prim_sec as $cle => $tb) {
|
|
|
281 |
$types_sstypes[$cle]= $this->separerTypes_SousTypes($tb, $cle);
|
|
|
282 |
}
|
|
|
283 |
switch (count($types_sstypes)) {
|
|
|
284 |
case 1 :
|
|
|
285 |
$types_sstypes = $types_sstypes['principal'];
|
|
|
286 |
break;
|
|
|
287 |
case 2 :
|
|
|
288 |
$types_sstypes = array_merge($types_sstypes['principal'],$types_sstypes['secondaire']);
|
|
|
289 |
break;
|
|
|
290 |
}
|
|
|
291 |
return $types_sstypes;
|
|
|
292 |
}
|
|
|
293 |
|
499 |
jpm |
294 |
|
548 |
mathilde |
295 |
public function formaterJsonTypeBio( $types_sstypes, $type_a_traiter) {
|
|
|
296 |
$resultat_typeBio['type_bio.code'] = $type_a_traiter;
|
|
|
297 |
foreach ($types_sstypes as $cle => $tb) {
|
|
|
298 |
if (($cle == 'type.principal') || ($cle == 'type.secondaire')) {
|
|
|
299 |
$i = 0;
|
|
|
300 |
foreach ($tb as $types) {
|
518 |
mathilde |
301 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
548 |
mathilde |
302 |
'/ontologies/TB:'.urlencode(urlencode($types));
|
452 |
mathilde |
303 |
$val = $this->consulterHref($url);
|
|
|
304 |
$libelle[$cle]= $val->nom;
|
549 |
mathilde |
305 |
$detail[$cle][$i]['libelle'] = $val->nom;
|
|
|
306 |
$detail[$cle][$i]['code'] = $val->code;
|
|
|
307 |
$detail[$cle][$i]['href'] = $url;
|
|
|
308 |
$i++;
|
452 |
mathilde |
309 |
}
|
548 |
mathilde |
310 |
}
|
|
|
311 |
if ($cle == 'sous_type.principal' || $cle == 'sous_type.secondaire' ) {
|
|
|
312 |
$i = 0;
|
|
|
313 |
foreach ($tb as $sstypes) {
|
|
|
314 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
|
|
315 |
'/ontologies/ssTT:'.urlencode(urlencode($sstypes));
|
|
|
316 |
$val = $this->consulterHref($url);
|
|
|
317 |
$libelle[$cle]=$val->nom;
|
|
|
318 |
$detail[$cle][$i]['libelle'] = $val->nom;
|
|
|
319 |
$detail[$cle][$i]['code'] = $val->code;
|
|
|
320 |
$detail[$cle][$i]['href'] = $url;
|
|
|
321 |
$i++;
|
452 |
mathilde |
322 |
}
|
|
|
323 |
}
|
|
|
324 |
}
|
548 |
mathilde |
325 |
$resultat_typeBio['type_bio.libelle']= $this->formaterTypeBioPrLibelle($libelle);
|
|
|
326 |
$resultat_typeBio['type_bio.detail'] = $detail;
|
452 |
mathilde |
327 |
return $resultat_typeBio;
|
|
|
328 |
}
|
548 |
mathilde |
329 |
|
|
|
330 |
|
549 |
mathilde |
331 |
|
499 |
jpm |
332 |
public function formaterTypeBioPrLibelle($info) {
|
452 |
mathilde |
333 |
$libelle = $info['type.principal']." ";
|
|
|
334 |
$libelle .= isset($info['sous_type.principal']) ? " (".$info['sous_type.principal'].") " : "";
|
|
|
335 |
$libelle .= isset($info['type.secondaire']) ? ", ".$info['type.secondaire']." " : "";
|
|
|
336 |
$libelle .= isset($info['sous_type.secondaire']) ? "(".$info['sous_type.secondaire'].") " : "";
|
|
|
337 |
return $libelle;
|
|
|
338 |
}
|
|
|
339 |
|
548 |
mathilde |
340 |
//séparation des principaux et des secondaires
|
499 |
jpm |
341 |
public function separerTypesPrimairesSecondaires($type) {
|
548 |
mathilde |
342 |
$types = array();
|
|
|
343 |
if (preg_match("/(.+)\((.+)\)\-{0,1}(.+){0,1}/", $type,$retour)) {
|
|
|
344 |
$types['principal'] = isset($retour[3]) ? $retour[1].'-'. $retour[3] : $retour[1] ;
|
452 |
mathilde |
345 |
$types['secondaire'] = $retour[2];
|
499 |
jpm |
346 |
} else {
|
452 |
mathilde |
347 |
$types['principal'] = $type;
|
|
|
348 |
}
|
|
|
349 |
return $types;
|
|
|
350 |
}
|
499 |
jpm |
351 |
|
548 |
mathilde |
352 |
|
499 |
jpm |
353 |
public function separerTypes_SousTypes($type_a_traiter, $typePrimOuSec) {
|
452 |
mathilde |
354 |
$types = array();
|
548 |
mathilde |
355 |
if (preg_match("/^([a-zA-Zé]+)\-(.+)$|^([a-zA-Zé,]+[^\-])$/", $type_a_traiter, $retour)) {
|
|
|
356 |
//type
|
|
|
357 |
$type = array();
|
|
|
358 |
$type[0] = (isset($retour[3])) ? $retour[3] : $retour[1] ;
|
549 |
mathilde |
359 |
$type = explode(",", $type[0]);
|
548 |
mathilde |
360 |
for ($i = 0 ; $i < count($type); $i++) {
|
|
|
361 |
$types['type.'.$typePrimOuSec][$i] = $type[$i];
|
|
|
362 |
}
|
|
|
363 |
//sous types
|
|
|
364 |
$ss_types = array();
|
|
|
365 |
if (isset($retour[2]) && $retour[2] != '') {
|
|
|
366 |
$ss_types[0] = $retour[2] ;
|
549 |
mathilde |
367 |
$ss_types = explode("-", $ss_types[0]);
|
499 |
jpm |
368 |
for ($i = 0 ; $i < count($ss_types); $i++) {
|
548 |
mathilde |
369 |
$types['sous_type.'.$typePrimOuSec][$i] = $ss_types[$i];
|
|
|
370 |
}
|
|
|
371 |
}
|
452 |
mathilde |
372 |
}
|
|
|
373 |
return $types;
|
548 |
mathilde |
374 |
}
|
|
|
375 |
|
|
|
376 |
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
|
|
|
381 |
|
|
|
382 |
public function assemblerLaRequete() {
|
|
|
383 |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
|
|
|
384 |
.$this->retournerRequeteCondition();
|
|
|
385 |
return $requete;
|
452 |
mathilde |
386 |
}
|
548 |
mathilde |
387 |
|
|
|
388 |
|
|
|
389 |
|
|
|
390 |
public function retournerRequeteCondition() {
|
|
|
391 |
$condition = '';
|
|
|
392 |
if (empty($this->requete_condition) == false) {
|
|
|
393 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
|
|
394 |
}
|
|
|
395 |
return $condition;
|
|
|
396 |
}
|
499 |
jpm |
397 |
|
|
|
398 |
|
525 |
mathilde |
399 |
|
452 |
mathilde |
400 |
}
|
|
|
401 |
?>
|