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 |
}
|
553 |
mathilde |
197 |
} else {
|
|
|
198 |
$this->resultat_json = $resultat_json;
|
452 |
mathilde |
199 |
}
|
548 |
mathilde |
200 |
return $this->resultat_json;
|
452 |
mathilde |
201 |
}
|
499 |
jpm |
202 |
|
452 |
mathilde |
203 |
public function formaterResultatsTousChamps($resultat) {
|
548 |
mathilde |
204 |
$this->resultat_json = $resultat;
|
|
|
205 |
$this->traiterTypeBio();
|
|
|
206 |
$graphique_presence = $this->traiterOntologieEcologie() ;
|
|
|
207 |
if ($graphique_presence) {
|
|
|
208 |
$graphique = $this->ajouterLiensGraphique();
|
|
|
209 |
}
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
public function formaterResultatsChampsEcologie($resultat) {
|
|
|
213 |
$this->resultat_json = $resultat;
|
|
|
214 |
$graphique_presence = $this->traiterOntologieEcologie() ;
|
|
|
215 |
if ($graphique_presence) {
|
|
|
216 |
$graphique = $this->ajouterLiensGraphique();
|
452 |
mathilde |
217 |
}
|
548 |
mathilde |
218 |
}
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
public function formaterResultatsChampsDescription($resultat) {
|
|
|
222 |
$this->resultat_json = $resultat;
|
|
|
223 |
$this->traiterTypeBio();
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
public function traiterOntologieEcologie() {
|
|
|
227 |
$donnees_presence = false;
|
452 |
mathilde |
228 |
$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
|
|
|
229 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
548 |
mathilde |
230 |
if ($this->resultat_json[$cle] != ""){
|
|
|
231 |
$donnees_presence = true;
|
|
|
232 |
$this->recupererOntologies($this->resultat_json[$cle], $cle);
|
|
|
233 |
unset($this->resultat_json[$cle]);
|
452 |
mathilde |
234 |
}
|
|
|
235 |
}
|
548 |
mathilde |
236 |
return $donnees_presence;
|
452 |
mathilde |
237 |
}
|
548 |
mathilde |
238 |
|
|
|
239 |
public function traiterTypeBio() {
|
|
|
240 |
if ($this->resultat_json['type_bio'] != ""){
|
|
|
241 |
$tab_ontologie = $this->recupererOntologiePrTypeBio($this->resultat_json['type_bio']);
|
|
|
242 |
unset($this->resultat_json['type_bio']);
|
|
|
243 |
$this->resultat_json= array_merge($this->resultat_json,$tab_ontologie);
|
452 |
mathilde |
244 |
}
|
|
|
245 |
}
|
499 |
jpm |
246 |
|
548 |
mathilde |
247 |
public function ajouterLiensGraphique() {
|
|
|
248 |
$this->resultat_json['graphique_climat']['libelle'] = 'climat';
|
|
|
249 |
$this->resultat_json['graphique_climat']['href'] =
|
|
|
250 |
$this->ajouterHref('graphiques/climat', strtolower($this->resultat_json['BDNT']).'.nn:'.$this->resultat_json['num_nomen']);
|
|
|
251 |
$this->resultat_json['graphique_sol']['libelle'] = 'sol';
|
|
|
252 |
$this->resultat_json['graphique_sol']['href'] =
|
|
|
253 |
$this->ajouterHref('graphiques/sol', strtolower($this->resultat_json['BDNT']).'.nn:'.$this->resultat_json['num_nomen']);
|
452 |
mathilde |
254 |
}
|
517 |
mathilde |
255 |
|
|
|
256 |
|
452 |
mathilde |
257 |
//+--------------------------traitement ontologies -------------------------------------------+
|
518 |
mathilde |
258 |
|
452 |
mathilde |
259 |
public function recupererOntologies($valeur, $champs){
|
518 |
mathilde |
260 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
|
|
261 |
'/ontologies/'.$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur));
|
452 |
mathilde |
262 |
$val = $this->consulterHref($url);
|
548 |
mathilde |
263 |
$this->resultat_json[$champs.'.libelle'] = $val->nom;
|
|
|
264 |
$this->resultat_json[$champs.'.code'] = $valeur;
|
|
|
265 |
$this->resultat_json[$champs.'.href'] = $url;
|
452 |
mathilde |
266 |
}
|
548 |
mathilde |
267 |
|
|
|
268 |
//+-------------ontologie pour le champs type biologique (lire le .txt)---+
|
499 |
jpm |
269 |
|
452 |
mathilde |
270 |
public function recupererOntologiePrTypeBio($type_a_traiter){
|
|
|
271 |
$resultat_typeBio = "";
|
499 |
jpm |
272 |
if ($type_a_traiter != "") {
|
452 |
mathilde |
273 |
$types_prim_sec = $this->separerTypesPrimairesSecondaires($type_a_traiter);
|
548 |
mathilde |
274 |
$types_sstypes = $this->classerPrimSecEnTypesSsTypes($types_prim_sec);
|
|
|
275 |
$resultat_typeBio = $this->formaterJsonTypeBio($types_sstypes, $type_a_traiter );
|
|
|
276 |
}
|
|
|
277 |
return $resultat_typeBio;
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
public function classerPrimSecEnTypesSsTypes($types_prim_sec) {
|
|
|
281 |
$types_sstypes = '';
|
|
|
282 |
foreach ($types_prim_sec as $cle => $tb) {
|
|
|
283 |
$types_sstypes[$cle]= $this->separerTypes_SousTypes($tb, $cle);
|
|
|
284 |
}
|
|
|
285 |
switch (count($types_sstypes)) {
|
|
|
286 |
case 1 :
|
|
|
287 |
$types_sstypes = $types_sstypes['principal'];
|
|
|
288 |
break;
|
|
|
289 |
case 2 :
|
|
|
290 |
$types_sstypes = array_merge($types_sstypes['principal'],$types_sstypes['secondaire']);
|
|
|
291 |
break;
|
|
|
292 |
}
|
|
|
293 |
return $types_sstypes;
|
|
|
294 |
}
|
|
|
295 |
|
499 |
jpm |
296 |
|
548 |
mathilde |
297 |
public function formaterJsonTypeBio( $types_sstypes, $type_a_traiter) {
|
|
|
298 |
$resultat_typeBio['type_bio.code'] = $type_a_traiter;
|
|
|
299 |
foreach ($types_sstypes as $cle => $tb) {
|
|
|
300 |
if (($cle == 'type.principal') || ($cle == 'type.secondaire')) {
|
|
|
301 |
$i = 0;
|
|
|
302 |
foreach ($tb as $types) {
|
518 |
mathilde |
303 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
548 |
mathilde |
304 |
'/ontologies/TB:'.urlencode(urlencode($types));
|
452 |
mathilde |
305 |
$val = $this->consulterHref($url);
|
550 |
mathilde |
306 |
$libelle[$cle][$i]= $val->nom;
|
549 |
mathilde |
307 |
$detail[$cle][$i]['libelle'] = $val->nom;
|
|
|
308 |
$detail[$cle][$i]['code'] = $val->code;
|
|
|
309 |
$detail[$cle][$i]['href'] = $url;
|
|
|
310 |
$i++;
|
452 |
mathilde |
311 |
}
|
548 |
mathilde |
312 |
}
|
|
|
313 |
if ($cle == 'sous_type.principal' || $cle == 'sous_type.secondaire' ) {
|
|
|
314 |
$i = 0;
|
|
|
315 |
foreach ($tb as $sstypes) {
|
|
|
316 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
|
|
317 |
'/ontologies/ssTT:'.urlencode(urlencode($sstypes));
|
|
|
318 |
$val = $this->consulterHref($url);
|
550 |
mathilde |
319 |
$libelle[$cle][$i]=$val->nom;
|
548 |
mathilde |
320 |
$detail[$cle][$i]['libelle'] = $val->nom;
|
|
|
321 |
$detail[$cle][$i]['code'] = $val->code;
|
|
|
322 |
$detail[$cle][$i]['href'] = $url;
|
|
|
323 |
$i++;
|
452 |
mathilde |
324 |
}
|
|
|
325 |
}
|
|
|
326 |
}
|
550 |
mathilde |
327 |
//var_dump($libelle); exit;
|
548 |
mathilde |
328 |
$resultat_typeBio['type_bio.libelle']= $this->formaterTypeBioPrLibelle($libelle);
|
|
|
329 |
$resultat_typeBio['type_bio.detail'] = $detail;
|
452 |
mathilde |
330 |
return $resultat_typeBio;
|
|
|
331 |
}
|
548 |
mathilde |
332 |
|
|
|
333 |
|
549 |
mathilde |
334 |
|
499 |
jpm |
335 |
public function formaterTypeBioPrLibelle($info) {
|
552 |
mathilde |
336 |
$libelle = implode(', ',$info['type.principal'])." ";
|
|
|
337 |
$libelle .= isset($info['sous_type.principal']) ? " (".implode(', ',$info['sous_type.principal']).") " : "";
|
|
|
338 |
$libelle .= isset($info['type.secondaire']) ? ", ".implode(', ',$info['type.secondaire'])." " : "";
|
|
|
339 |
$libelle .= isset($info['sous_type.secondaire']) ? "(".implode(', ',$info['sous_type.secondaire']).") " : "";
|
452 |
mathilde |
340 |
return $libelle;
|
|
|
341 |
}
|
|
|
342 |
|
548 |
mathilde |
343 |
//séparation des principaux et des secondaires
|
499 |
jpm |
344 |
public function separerTypesPrimairesSecondaires($type) {
|
548 |
mathilde |
345 |
$types = array();
|
|
|
346 |
if (preg_match("/(.+)\((.+)\)\-{0,1}(.+){0,1}/", $type,$retour)) {
|
|
|
347 |
$types['principal'] = isset($retour[3]) ? $retour[1].'-'. $retour[3] : $retour[1] ;
|
452 |
mathilde |
348 |
$types['secondaire'] = $retour[2];
|
499 |
jpm |
349 |
} else {
|
452 |
mathilde |
350 |
$types['principal'] = $type;
|
|
|
351 |
}
|
|
|
352 |
return $types;
|
|
|
353 |
}
|
499 |
jpm |
354 |
|
548 |
mathilde |
355 |
|
499 |
jpm |
356 |
public function separerTypes_SousTypes($type_a_traiter, $typePrimOuSec) {
|
452 |
mathilde |
357 |
$types = array();
|
548 |
mathilde |
358 |
if (preg_match("/^([a-zA-Zé]+)\-(.+)$|^([a-zA-Zé,]+[^\-])$/", $type_a_traiter, $retour)) {
|
|
|
359 |
//type
|
|
|
360 |
$type = array();
|
|
|
361 |
$type[0] = (isset($retour[3])) ? $retour[3] : $retour[1] ;
|
549 |
mathilde |
362 |
$type = explode(",", $type[0]);
|
548 |
mathilde |
363 |
for ($i = 0 ; $i < count($type); $i++) {
|
|
|
364 |
$types['type.'.$typePrimOuSec][$i] = $type[$i];
|
|
|
365 |
}
|
|
|
366 |
//sous types
|
|
|
367 |
$ss_types = array();
|
|
|
368 |
if (isset($retour[2]) && $retour[2] != '') {
|
|
|
369 |
$ss_types[0] = $retour[2] ;
|
549 |
mathilde |
370 |
$ss_types = explode("-", $ss_types[0]);
|
499 |
jpm |
371 |
for ($i = 0 ; $i < count($ss_types); $i++) {
|
548 |
mathilde |
372 |
$types['sous_type.'.$typePrimOuSec][$i] = $ss_types[$i];
|
|
|
373 |
}
|
|
|
374 |
}
|
452 |
mathilde |
375 |
}
|
|
|
376 |
return $types;
|
548 |
mathilde |
377 |
}
|
|
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
|
383 |
//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
|
|
|
384 |
|
|
|
385 |
public function assemblerLaRequete() {
|
|
|
386 |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
|
|
|
387 |
.$this->retournerRequeteCondition();
|
|
|
388 |
return $requete;
|
452 |
mathilde |
389 |
}
|
548 |
mathilde |
390 |
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
public function retournerRequeteCondition() {
|
|
|
394 |
$condition = '';
|
|
|
395 |
if (empty($this->requete_condition) == false) {
|
|
|
396 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
|
|
397 |
}
|
|
|
398 |
return $condition;
|
|
|
399 |
}
|
499 |
jpm |
400 |
|
|
|
401 |
|
525 |
mathilde |
402 |
|
452 |
mathilde |
403 |
}
|
|
|
404 |
?>
|