1 |
<?php
|
1 |
<?php
|
2 |
|
2 |
|
3 |
/**
|
3 |
/**
|
4 |
* Classe InformationsTaxonsSup.php permet de faire des requetes pour les rangs superieurs de baseflor
|
4 |
* Classe InformationsTaxonsSup.php permet de faire des requetes pour les rangs superieurs de baseflor
|
5 |
* du référentiel BDTFX et avec un numéro nomenclatural ( différent de 0 ).
|
5 |
* du référentiel BDTFX et avec un numéro nomenclatural ( différent de 0 ).
|
6 |
* fin d'url possibles :
|
6 |
* fin d'url possibles :
|
7 |
*
|
7 |
*
|
8 |
* /informations/#bdnt.nn:#num_nomen?champs=ecologie --> retourne champs ecologiques pour un BDNT et un num_nomen
|
8 |
* /informations/#bdnt.nn:#num_nomen?champs=ecologie --> retourne champs ecologiques pour un BDNT et un num_nomen
|
9 |
*
|
9 |
*
|
10 |
*
|
10 |
*
|
11 |
* Encodage en entrée : utf8
|
11 |
* Encodage en entrée : utf8
|
12 |
* Encodage en sortie : utf8
|
12 |
* Encodage en sortie : utf8
|
13 |
* @package eflore-projets
|
13 |
* @package eflore-projets
|
14 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
14 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
15 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
|
15 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
|
16 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
16 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
17 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
17 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
18 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
18 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
19 |
* @version 1.0
|
19 |
* @version 1.0
|
20 |
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
|
20 |
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
|
21 |
*/
|
21 |
*/
|
22 |
|
22 |
|
23 |
class InformationsTaxonsSup extends Commun{
|
23 |
class InformationsTaxonsSup extends Commun{
|
24 |
|
24 |
|
25 |
protected $table = "";
|
25 |
protected $table = "";
|
26 |
private $champs_ontologiques = array();
|
26 |
private $champs_ontologiques = array();
|
27 |
private $format_reponse = 'informations';
|
27 |
private $format_reponse = 'informations';
|
28 |
protected $serviceNom = 'informations';
|
28 |
protected $serviceNom = 'informations';
|
29 |
private $retour_format = 'max';
|
29 |
private $retour_format = 'max';
|
30 |
private $Bdd;
|
30 |
private $Bdd;
|
31 |
private $requete_condition = "";
|
31 |
private $requete_condition = [];
|
32 |
private $champs_recherches = '*';
|
32 |
private $champs_recherches = '*';
|
33 |
|
33 |
|
34 |
public function consulter($ressources, $parametres) {
|
34 |
public function consulter($ressources, $parametres) {
|
35 |
$this->ressources = $ressources;
|
35 |
$this->ressources = $ressources;
|
36 |
$this->parametres = $parametres;
|
36 |
$this->parametres = $parametres;
|
37 |
$this->traiterParametres();
|
37 |
$this->traiterParametres();
|
38 |
$this->definirTables();
|
38 |
$this->definirTables();
|
39 |
$this->traiterRessources();
|
39 |
$this->traiterRessources();
|
40 |
$resultats = '';
|
40 |
$resultats = '';
|
41 |
foreach ($this->table_version as $version) {
|
41 |
foreach ($this->table_version as $version) {
|
42 |
$this->table = $version;
|
42 |
$this->table = $version;
|
43 |
$requete = $this->assemblerLaRequete();
|
43 |
$requete = $this->assemblerLaRequete();
|
44 |
$resultat = $this->Bdd->recupererTous($requete);
|
44 |
$resultat = $this->Bdd->recupererTous($requete);
|
45 |
$versionResultat = $this->analyserResultat($resultat);
|
45 |
$versionResultat = $this->analyserResultat($resultat);
|
46 |
if (count($this->table_version) > 1) {
|
46 |
if (count($this->table_version) > 1) {
|
47 |
$resultats[$version] = $versionResultat;
|
47 |
$resultats[$version] = $versionResultat;
|
48 |
} else {
|
48 |
} else {
|
49 |
$resultats = $versionResultat;
|
49 |
$resultats = $versionResultat;
|
50 |
}
|
50 |
}
|
51 |
}
|
51 |
}
|
52 |
return $resultats;
|
52 |
return $resultats;
|
53 |
}
|
53 |
}
|
54 |
|
54 |
|
55 |
public function analyserResultat($resultat) {
|
55 |
public function analyserResultat($resultat) {
|
56 |
$versionResultat = null;
|
56 |
$versionResultat = null;
|
57 |
if ($resultat == '') {
|
57 |
if ($resultat == '') {
|
58 |
$message = 'La requête SQL formée comporte une erreur!';
|
58 |
$message = 'La requête SQL formée comporte une erreur!';
|
59 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
59 |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
|
60 |
throw new Exception($message, $code);
|
60 |
throw new Exception($message, $code);
|
61 |
} elseif ($resultat) {
|
61 |
} elseif ($resultat) {
|
62 |
$versionResultat = $this->retournerResultatFormate($resultat);
|
62 |
$versionResultat = $this->retournerResultatFormate($resultat);
|
63 |
}
|
63 |
}
|
64 |
return $versionResultat;
|
64 |
return $versionResultat;
|
65 |
}
|
65 |
}
|
66 |
|
66 |
|
67 |
public function __construct(Conteneur $Conteneur) {
|
67 |
public function __construct(Conteneur $Conteneur) {
|
68 |
$this->Bdd = $Conteneur->getBdd();
|
68 |
$this->Bdd = $Conteneur->getBdd();
|
69 |
}
|
69 |
}
|
70 |
|
70 |
|
71 |
//+--------------------------traitement ressources ou paramètres -------------------------------------------+
|
71 |
//+--------------------------traitement ressources ou paramètres -------------------------------------------+
|
72 |
|
72 |
|
73 |
public function traiterRessources() {
|
73 |
public function traiterRessources() {
|
74 |
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)==1){
|
74 |
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)==1){
|
75 |
switch ($retour[1]) {
|
75 |
switch ($retour[1]) {
|
76 |
case 'bdtfx' :
|
76 |
case 'bdtfx' :
|
77 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
|
77 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND bdnt = 'bdtfx' ";
|
78 |
break;
|
78 |
break;
|
79 |
default :
|
79 |
default :
|
80 |
$e = 'Erreur dans l\'url de votre requête : </br> Le référentiel " '
|
80 |
$e = 'Erreur dans l\'url de votre requête : </br> Le référentiel " '
|
81 |
.$retour[1].' " n\'existe pas.';
|
81 |
.$retour[1].' " n\'existe pas.';
|
82 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
82 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
83 |
break;
|
83 |
break;
|
84 |
}
|
84 |
}
|
85 |
|
85 |
|
86 |
}
|
86 |
}
|
87 |
|
87 |
|
88 |
}
|
88 |
}
|
89 |
|
89 |
|
90 |
//+---- paramètres ----+
|
90 |
//+---- paramètres ----+
|
91 |
|
91 |
|
92 |
public function traiterParametres() {
|
92 |
public function traiterParametres() {
|
93 |
if (isset($this->parametres) && !empty($this->parametres) ) {
|
93 |
if (isset($this->parametres) && !empty($this->parametres) ) {
|
94 |
foreach ($this->parametres as $param => $valeur) {
|
94 |
foreach ($this->parametres as $param => $valeur) {
|
95 |
switch ($param) {
|
95 |
switch ($param) {
|
96 |
case 'categorie' :
|
96 |
case 'categorie' :
|
97 |
if ($valeur == "ecologie"){
|
97 |
if ($valeur == "ecologie"){
|
98 |
$this->champs_recherches = ' num_nomen, bdnt, ve_lumiere_min , ve_lumiere_max,'
|
98 |
$this->champs_recherches = ' num_nomen, bdnt, ve_lumiere_min , ve_lumiere_max,'
|
99 |
.' ve_temperature_min, ve_temperature_max, ve_continentalite_min,'
|
99 |
.' ve_temperature_min, ve_temperature_max, ve_continentalite_min,'
|
100 |
.' ve_continentalite_max, ve_humidite_atmos_min, ve_humidite_atmos_max,'
|
100 |
.' ve_continentalite_max, ve_humidite_atmos_min, ve_humidite_atmos_max,'
|
101 |
.' ve_humidite_edaph_min, ve_humidite_edaph_max, ve_reaction_sol_min,'
|
101 |
.' ve_humidite_edaph_min, ve_humidite_edaph_max, ve_reaction_sol_min,'
|
102 |
.' ve_reaction_sol_max, ve_nutriments_sol_min, ve_nutriments_sol_max,'
|
102 |
.' ve_reaction_sol_max, ve_nutriments_sol_min, ve_nutriments_sol_max,'
|
103 |
.' ve_salinite_min, ve_salinite_max, ve_texture_sol_min,ve_texture_sol_max,'
|
103 |
.' ve_salinite_min, ve_salinite_max, ve_texture_sol_min,ve_texture_sol_max,'
|
104 |
.' ve_mat_org_sol_min, ve_mat_org_sol_max ';
|
104 |
.' ve_mat_org_sol_min, ve_mat_org_sol_max ';
|
105 |
} else {
|
105 |
} else {
|
106 |
$e = "Valeur de paramètre inconnue pour 'categorie'. Ce paramètre n'est pas autorisé pour informations/#id";
|
106 |
$e = "Valeur de paramètre inconnue pour 'categorie'. Ce paramètre n'est pas autorisé pour informations/#id";
|
107 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
107 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
108 |
}
|
108 |
}
|
109 |
break;
|
109 |
break;
|
110 |
case 'retour.format' :
|
110 |
case 'retour.format' :
|
111 |
if ($valeur == 'min' || $valeur == 'max') {
|
111 |
if ($valeur == 'min' || $valeur == 'max') {
|
112 |
$this->retour_format = $valeur;
|
112 |
$this->retour_format = $valeur;
|
113 |
break;
|
113 |
break;
|
114 |
} else {
|
114 |
} else {
|
115 |
$e = "Valeur de paramètre inconnue pour 'retour.format'. Ce paramètre n'est pas autorisé pour informations/#id";
|
115 |
$e = "Valeur de paramètre inconnue pour 'retour.format'. Ce paramètre n'est pas autorisé pour informations/#id";
|
116 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
116 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
117 |
}
|
117 |
}
|
118 |
case 'navigation.depart' :
|
118 |
case 'navigation.depart' :
|
119 |
$this->definirNavigationDepart($valeur);
|
119 |
$this->definirNavigationDepart($valeur);
|
120 |
break;
|
120 |
break;
|
121 |
case 'navigation.limite' :
|
121 |
case 'navigation.limite' :
|
122 |
$this->definirNavigationLimite($valeur);
|
122 |
$this->definirNavigationLimite($valeur);
|
123 |
break;
|
123 |
break;
|
124 |
case 'version.projet' :
|
124 |
case 'version.projet' :
|
125 |
$this->traiterVersion($valeur);
|
125 |
$this->traiterVersion($valeur);
|
126 |
break;
|
126 |
break;
|
127 |
default :
|
127 |
default :
|
128 |
$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
|
128 |
$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
|
129 |
.$param.' " n\'existe pas.';
|
129 |
.$param.' " n\'existe pas.';
|
130 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE); break;
|
130 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE); break;
|
131 |
}
|
131 |
}
|
132 |
}
|
132 |
}
|
133 |
}
|
133 |
}
|
134 |
}
|
134 |
}
|
135 |
|
135 |
|
136 |
//+++------------------------------traitement des versions----------------------------------------++
|
136 |
//+++------------------------------traitement des versions----------------------------------------++
|
137 |
|
137 |
|
138 |
public function traiterVersion($valeur) {
|
138 |
public function traiterVersion($valeur) {
|
139 |
if (preg_match('/^[0-9]+(?:[._][0-9]+)*$/', $valeur) || $valeur == '*' || $valeur == '+') {
|
139 |
if (preg_match('/^[0-9]+(?:[._][0-9]+)*$/', $valeur) || $valeur == '*' || $valeur == '+') {
|
140 |
$this->version_projet = $valeur;
|
140 |
$this->version_projet = $valeur;
|
141 |
} else {
|
141 |
} else {
|
142 |
$e = "Erreur : La version est inconnue.";
|
142 |
$e = "Erreur : La version est inconnue.";
|
143 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
143 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
144 |
}
|
144 |
}
|
145 |
if ($this->version_projet == '*' && $this->ressources == array()) {
|
145 |
if ($this->version_projet == '*' && $this->ressources == array()) {
|
146 |
$message = "L'affichage de plusieurs versions ne fonctionne que pour les ressources de type /ressources/#id";
|
146 |
$message = "L'affichage de plusieurs versions ne fonctionne que pour les ressources de type /ressources/#id";
|
147 |
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
|
147 |
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
|
148 |
throw new Exception($message, $code);
|
148 |
throw new Exception($message, $code);
|
149 |
}
|
149 |
}
|
150 |
}
|
150 |
}
|
151 |
|
151 |
|
152 |
public function definirTables() {
|
152 |
public function definirTables() {
|
153 |
$table_num_version = $this->recupererVersionDisponible();
|
153 |
$table_num_version = $this->recupererVersionDisponible();
|
154 |
$prefixe_table = config::get('bdd_table_rang_sup');
|
154 |
$prefixe_table = config::get('bdd_table_rang_sup');
|
155 |
if ( in_array($this->version_projet,$table_num_version) ) {
|
155 |
if ( in_array($this->version_projet,$table_num_version) ) {
|
156 |
$this->table_version[] = $prefixe_table.'_v'.$this->version_projet;
|
156 |
$this->table_version[] = $prefixe_table.'_v'.$this->version_projet;
|
157 |
} elseif ($this->version_projet == '+') {
|
157 |
} elseif ($this->version_projet == '+') {
|
158 |
$derniere_version = $table_num_version[count($table_num_version) - 1];
|
158 |
$derniere_version = $table_num_version[count($table_num_version) - 1];
|
159 |
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $derniere_version);
|
159 |
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $derniere_version);
|
160 |
} elseif ($this->version_projet == '*') {
|
160 |
} elseif ($this->version_projet == '*') {
|
161 |
foreach ($table_num_version as $num_version) {
|
161 |
foreach ($table_num_version as $num_version) {
|
162 |
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $num_version);
|
162 |
$this->table_version[] = $prefixe_table.'_v'.str_replace('.', '_', $num_version);
|
163 |
}
|
163 |
}
|
164 |
} else {
|
164 |
} else {
|
165 |
$e = "Erreur : La version est inconnue.";
|
165 |
$e = "Erreur : La version est inconnue.";
|
166 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
166 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
167 |
}
|
167 |
}
|
168 |
}
|
168 |
}
|
169 |
|
169 |
|
170 |
|
170 |
|
171 |
//+--------------------------formatages de resultats -------------------------------------------+
|
171 |
//+--------------------------formatages de resultats -------------------------------------------+
|
172 |
|
172 |
|
173 |
|
173 |
|
174 |
public function retournerResultatFormate($resultat) {
|
174 |
public function retournerResultatFormate($resultat) {
|
175 |
$this->resultat_json = $resultat[0];
|
175 |
$this->resultat_json = $resultat[0];
|
176 |
if ($this->retour_format == 'max') {
|
176 |
if ($this->retour_format == 'max') {
|
177 |
$graphique_presence = $this->traiterEcologie() ;
|
177 |
$graphique_presence = $this->traiterEcologie() ;
|
178 |
if ($graphique_presence) {
|
178 |
if ($graphique_presence) {
|
179 |
$this->ajouterLiensGraphique($graphique_presence);
|
179 |
$this->ajouterLiensGraphique($graphique_presence);
|
180 |
}
|
180 |
}
|
181 |
}
|
181 |
}
|
182 |
return $this->resultat_json ;
|
182 |
return $this->resultat_json ;
|
183 |
|
183 |
|
184 |
}
|
184 |
}
|
185 |
|
185 |
|
186 |
public function traiterEcologie() {
|
186 |
public function traiterEcologie() {
|
187 |
$donnees_presence = false;
|
187 |
$donnees_presence = false;
|
188 |
$this->champs_ontologiques = Commun::s_recupererTableauConfig('Paramètres.champs_ontologiques');
|
188 |
$this->champs_ontologiques = Commun::s_recupererTableauConfig('Paramètres.champs_ontologiques');
|
189 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
189 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
190 |
/* Les deux tests commentés ci-dessous étaient présents dans eflore-test (uniquement) jusqu'à juin 2013.
|
190 |
/* Les deux tests commentés ci-dessous étaient présents dans eflore-test (uniquement) jusqu'à juin 2013.
|
191 |
La valeur 0 pose question.
|
191 |
La valeur 0 pose question.
|
192 |
cf baseflor_v2012_12_31
|
192 |
cf baseflor_v2012_12_31
|
193 |
cf services/modules/0.1/baseflor/CommunGraphiques.php traiterValeursEcologiques() */
|
193 |
cf services/modules/0.1/baseflor/CommunGraphiques.php traiterValeursEcologiques() */
|
194 |
if ($this->resultat_json[$cle.'_min'] != "") { // && $this->resultat_json[$cle.'_min'] != 0) {
|
194 |
if ($this->resultat_json[$cle.'_min'] != "") { // && $this->resultat_json[$cle.'_min'] != 0) {
|
195 |
$donnees_presence[$this->getNomGraphique($valeur)] = true;
|
195 |
$donnees_presence[$this->getNomGraphique($valeur)] = true;
|
196 |
$tab_ontologie = $this->recupererOntologies($this->resultat_json[$cle.'_min'], $cle.'_min');
|
196 |
$tab_ontologie = $this->recupererOntologies($this->resultat_json[$cle.'_min'], $cle.'_min');
|
197 |
unset($this->resultat_json[$cle.'_min']);
|
197 |
unset($this->resultat_json[$cle.'_min']);
|
198 |
}
|
198 |
}
|
199 |
if ($this->resultat_json[$cle.'_max'] != "") { // && $this->resultat_json[$cle.'_max'] != 0) {
|
199 |
if ($this->resultat_json[$cle.'_max'] != "") { // && $this->resultat_json[$cle.'_max'] != 0) {
|
200 |
$this->recupererOntologies($this->resultat_json[$cle.'_max'], $cle.'_max');
|
200 |
$this->recupererOntologies($this->resultat_json[$cle.'_max'], $cle.'_max');
|
201 |
unset($this->resultat_json[$cle.'_max']);
|
201 |
unset($this->resultat_json[$cle.'_max']);
|
202 |
}
|
202 |
}
|
203 |
}
|
203 |
}
|
204 |
return $donnees_presence;
|
204 |
return $donnees_presence;
|
205 |
}
|
205 |
}
|
206 |
|
206 |
|
207 |
//donne le nom du graphique correspondant à un champ écologique
|
207 |
//donne le nom du graphique correspondant à un champ écologique
|
208 |
public function getNomGraphique($code_ecolo) {
|
208 |
public function getNomGraphique($code_ecolo) {
|
209 |
$graphique = null;
|
209 |
$graphique = null;
|
210 |
if (in_array($code_ecolo, explode(',',Config::get('Paramètres.climat')))) {
|
210 |
if (in_array($code_ecolo, explode(',',Config::get('Paramètres.climat')))) {
|
211 |
$graphique = 'climat';
|
211 |
$graphique = 'climat';
|
212 |
} elseif (in_array($code_ecolo, explode(',', Config::get('Paramètres.sol')) )) {
|
212 |
} elseif (in_array($code_ecolo, explode(',', Config::get('Paramètres.sol')) )) {
|
213 |
$graphique = 'sol';
|
213 |
$graphique = 'sol';
|
214 |
}
|
214 |
}
|
215 |
return $graphique;
|
215 |
return $graphique;
|
216 |
}
|
216 |
}
|
217 |
|
217 |
|
218 |
public function ajouterLiensGraphique($graphique_presence) {
|
218 |
public function ajouterLiensGraphique($graphique_presence) {
|
219 |
if ($graphique_presence['climat']) {
|
219 |
if ($graphique_presence['climat']) {
|
220 |
$this->resultat_json['graphique_climat']['libelle'] = 'climat';
|
220 |
$this->resultat_json['graphique_climat']['libelle'] = 'climat';
|
221 |
$this->resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat',
|
221 |
$this->resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat',
|
222 |
strtolower($this->resultat_json['bdnt']).'.nn:'.$this->resultat_json['num_nomen']);
|
222 |
strtolower($this->resultat_json['bdnt']).'.nn:'.$this->resultat_json['num_nomen']);
|
223 |
}
|
223 |
}
|
224 |
if ($graphique_presence['sol']) {
|
224 |
if ($graphique_presence['sol']) {
|
225 |
$this->resultat_json['graphique_sol']['libelle'] = 'sol';
|
225 |
$this->resultat_json['graphique_sol']['libelle'] = 'sol';
|
226 |
$this->resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol',
|
226 |
$this->resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol',
|
227 |
strtolower($this->resultat_json['bdnt']).'.nn:'.$this->resultat_json['num_nomen']);
|
227 |
strtolower($this->resultat_json['bdnt']).'.nn:'.$this->resultat_json['num_nomen']);
|
228 |
}
|
228 |
}
|
229 |
}
|
229 |
}
|
230 |
|
230 |
|
231 |
//+--------------------------traitement ontologies -------------------------------------------+
|
231 |
//+--------------------------traitement ontologies -------------------------------------------+
|
232 |
|
232 |
|
233 |
public function recupererOntologies($valeur, $champs){
|
233 |
public function recupererOntologies($valeur, $champs){
|
234 |
$chps_sans = preg_replace("/_min|_max/", '', $champs);
|
234 |
$chps_sans = preg_replace("/_min|_max/", '', $champs);
|
235 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
235 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
236 |
'/ontologies/'.$this->champs_ontologiques[$chps_sans].':'.urlencode(urlencode($valeur));
|
236 |
'/ontologies/'.$this->champs_ontologiques[$chps_sans].':'.urlencode(urlencode($valeur));
|
237 |
try {
|
237 |
try {
|
238 |
$val = $this->getBdd()->recuperer(sprintf(
|
238 |
$val = $this->getBdd()->recuperer(sprintf(
|
239 |
"SELECT a.nom FROM baseflor_ontologies a LEFT JOIN baseflor_ontologies b ON a.id = b.id LEFT JOIN baseflor_ontologies c ON b.classe_id = c.id WHERE".
|
239 |
"SELECT a.nom FROM baseflor_ontologies a LEFT JOIN baseflor_ontologies b ON a.id = b.id LEFT JOIN baseflor_ontologies c ON b.classe_id = c.id WHERE".
|
240 |
" b.code = BINARY '%s' AND c.code = BINARY '%s' LIMIT 0, 100",
|
240 |
" b.code = BINARY '%s' AND c.code = BINARY '%s' LIMIT 0, 100",
|
241 |
$valeur,
|
241 |
$valeur,
|
242 |
$this->champs_ontologiques[$chps_sans]),
|
242 |
$this->champs_ontologiques[$chps_sans]),
|
243 |
Bdd::MODE_OBJET);
|
243 |
Bdd::MODE_OBJET);
|
244 |
$this->resultat_json[$champs.'.libelle'] = $val->nom;
|
244 |
$this->resultat_json[$champs.'.libelle'] = $val->nom;
|
245 |
$this->resultat_json[$champs.'.code'] = $valeur;
|
245 |
$this->resultat_json[$champs.'.code'] = $valeur;
|
246 |
$this->resultat_json[$champs.'.href'] = $url;
|
246 |
$this->resultat_json[$champs.'.href'] = $url;
|
247 |
} catch (Exception $e) {
|
247 |
} catch (Exception $e) {
|
248 |
$this->resultat_json[$champs.'.libelle'] = '';
|
248 |
$this->resultat_json[$champs.'.libelle'] = '';
|
249 |
$this->resultat_json[$champs.'.code'] = '';
|
249 |
$this->resultat_json[$champs.'.code'] = '';
|
250 |
$this->resultat_json[$champs.'.href'] = '';
|
250 |
$this->resultat_json[$champs.'.href'] = '';
|
251 |
}
|
251 |
}
|
252 |
}
|
252 |
}
|
253 |
|
253 |
|
254 |
|
254 |
|
255 |
//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
|
255 |
//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
|
256 |
|
256 |
|
257 |
public function assemblerLaRequete() {
|
257 |
public function assemblerLaRequete() {
|
258 |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
|
258 |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
|
259 |
.$this->retournerRequeteCondition();
|
259 |
.$this->retournerRequeteCondition();
|
260 |
return $requete;
|
260 |
return $requete;
|
261 |
}
|
261 |
}
|
262 |
|
262 |
|
263 |
|
263 |
|
264 |
|
264 |
|
265 |
public function retournerRequeteCondition() {
|
265 |
public function retournerRequeteCondition() {
|
266 |
$condition = '';
|
266 |
$condition = '';
|
267 |
if (empty($this->requete_condition) == false) {
|
267 |
if (empty($this->requete_condition) == false) {
|
268 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
268 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
269 |
}
|
269 |
}
|
270 |
return $condition;
|
270 |
return $condition;
|
271 |
}
|
271 |
}
|
272 |
|
272 |
|
273 |
}
|
273 |
}
|
274 |
?>
|
274 |
?>
|