Line 5... |
Line 5... |
5 |
*( BDTFX, BDAFX, BDBFX ) et d'un numéro nomenclatural ( différent de 0 ).
|
5 |
*( BDTFX, BDAFX, BDBFX ) et d'un numéro nomenclatural ( différent de 0 ).
|
6 |
* fin d'url possibles :
|
6 |
* fin d'url possibles :
|
7 |
* /informations/#bdnt.nn:#num_nomen --> retourne tous les champs pour un BDNT et un num_nomen
|
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
|
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
|
9 |
* /informations/#bdnt.nn:#num_nomen?champs=ecologie --> retourne champs ecologiques pour un BDNT et un num_nomen
|
10 |
* /informations --> retourne les 10 premiers résultats
|
- |
|
11 |
* /informations?navigation.limite=..&navigation.depart=.. --> retourne les 10 premiers résultats avec limites
|
- |
|
- |
|
10 |
*
|
12 |
*
|
11 |
*
|
13 |
* Encodage en entrée : utf8
|
12 |
* Encodage en entrée : utf8
|
14 |
* Encodage en sortie : utf8
|
13 |
* Encodage en sortie : utf8
|
15 |
* @package eflore-projets
|
14 |
* @package eflore-projets
|
16 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
15 |
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
|
Line 27... |
Line 26... |
27 |
protected $table = "";
|
26 |
protected $table = "";
|
28 |
private $format_reponse = 'informations';
|
27 |
private $format_reponse = 'informations';
|
29 |
private $retour_format = 'max';
|
28 |
private $retour_format = 'max';
|
30 |
private $champs_ontologiques = array();
|
29 |
private $champs_ontologiques = array();
|
31 |
protected $serviceNom = 'informations';
|
30 |
protected $serviceNom = 'informations';
|
32 |
private $Requete;
|
- |
|
33 |
private $Conteneur;
|
- |
|
34 |
private $Requete_assemblage;
|
- |
|
35 |
private $Bdd;
|
31 |
private $Bdd;
|
- |
|
32 |
private $requete_condition = "";
|
- |
|
33 |
private $champs_recherches = '*';
|
- |
|
34 |
private $resultat_json;
|
Line 36... |
Line 35... |
36 |
|
35 |
|
37 |
|
36 |
|
38 |
public function consulter($ressources, $parametres) {
|
37 |
public function consulter($ressources, $parametres) {
|
39 |
$this->ressources = $ressources;
|
38 |
$this->ressources = $ressources;
|
40 |
$this->parametres = $parametres;
|
39 |
$this->parametres = $parametres;
|
41 |
$this->traiterParametres();
|
40 |
$this->traiterParametres();
|
42 |
$this->DefinirTables();
|
41 |
$this->definirTables();
|
43 |
$this->traiterRessources();
|
42 |
$this->traiterRessources();
|
44 |
$resultats = null;
|
43 |
$resultats = null;
|
45 |
foreach ($this->table_version as $version) {
|
44 |
foreach ($this->table_version as $version) {
|
46 |
$this->Requete->table = $version;
|
45 |
$this->table = $version;
|
47 |
$requete = $this->Requete_assemblage->assemblerLaRequete($this->Requete);
|
46 |
$requete = $this->assemblerLaRequete();
|
48 |
$resultat = $this->Bdd->recupererTous($requete);
|
47 |
$resultat = $this->Bdd->recupererTous($requete);
|
49 |
$versionResultat = $this->analyserResultat($resultat);
|
48 |
$versionResultat = $this->analyserResultat($resultat);
|
50 |
if (count($this->table_version) > 1) {
|
49 |
if (count($this->table_version) > 1) {
|
Line 55... |
Line 54... |
55 |
}
|
54 |
}
|
56 |
return $resultats;
|
55 |
return $resultats;
|
57 |
}
|
56 |
}
|
Line 58... |
Line 57... |
58 |
|
57 |
|
59 |
public function __construct(Conteneur $Conteneur) {
|
- |
|
60 |
$this->Conteneur = $Conteneur;
|
- |
|
61 |
$this->Requete = new Requete();
|
58 |
public function __construct(Conteneur $Conteneur) {
|
62 |
$this->Bdd = $Conteneur->getBdd();
|
- |
|
63 |
$this->Requete_assemblage = $Conteneur->getRequetesAssemblage();
|
59 |
$this->Bdd = $Conteneur->getBdd();
|
Line -... |
Line 60... |
- |
|
60 |
}
|
64 |
}
|
61 |
|
65 |
|
62 |
|
66 |
public function analyserResultat($resultat) {
|
63 |
public function analyserResultat($resultat) {
|
67 |
$versionResultat = null;
|
64 |
$versionResultat = null;
|
68 |
if ($resultat == '') {
|
65 |
if ($resultat == '') {
|
Line 80... |
Line 77... |
80 |
if (isset($this->parametres) && !empty($this->parametres)) {
|
77 |
if (isset($this->parametres) && !empty($this->parametres)) {
|
81 |
foreach ($this->parametres as $param => $valeur) {
|
78 |
foreach ($this->parametres as $param => $valeur) {
|
82 |
switch ($param) {
|
79 |
switch ($param) {
|
83 |
case 'categorie' :
|
80 |
case 'categorie' :
|
84 |
if ($valeur == "description") {
|
81 |
if ($valeur == "description") {
|
85 |
$this->Requete->champs_recherches = "num_nomen, BDNT, chorologie, inflorescence,"
|
82 |
$this->champs_recherches = "num_nomen, BDNT, chorologie, inflorescence,"
|
86 |
." sexualite, ordre_maturation, "
|
83 |
." sexualite, ordre_maturation, "
|
87 |
."pollinisation, fruit, dissemination, couleur_fleur, macule, floraison, type_bio, "
|
84 |
."pollinisation, fruit, dissemination, couleur_fleur, macule, floraison, type_bio, "
|
88 |
."form_vegetale ";
|
85 |
."form_vegetale ";
|
89 |
$this->Requete->requete_condition[] = "( chorologie != '' OR inflorescence != '' ".
|
86 |
$this->requete_condition[] = "( chorologie != '' OR inflorescence != '' ".
|
90 |
"OR sexualite != '' OR ordre_maturation != '' OR pollinisation != '' ".
|
87 |
"OR sexualite != '' OR ordre_maturation != '' OR pollinisation != '' ".
|
91 |
"OR fruit != '' OR dissemination != '' OR couleur_fleur != '' OR macule != '' ".
|
88 |
"OR fruit != '' OR dissemination != '' OR couleur_fleur != '' OR macule != '' ".
|
92 |
"OR floraison != '' OR type_bio != '' OR form_vegetale != '' )";
|
89 |
"OR floraison != '' OR type_bio != '' OR form_vegetale != '' )";
|
93 |
}elseif ($valeur == "ecologie") {
|
90 |
}elseif ($valeur == "ecologie") {
|
94 |
$this->Requete->champs_recherches = " num_nomen, BDNT, ve_lumiere , ve_temperature,"
|
91 |
$this->champs_recherches = " num_nomen, BDNT, ve_lumiere , ve_temperature,"
|
95 |
." ve_continentalite, ve_humidite_atmos, ve_humidite_edaph, ve_reaction_sol,"
|
92 |
." ve_continentalite, ve_humidite_atmos, ve_humidite_edaph, ve_reaction_sol,"
|
96 |
." ve_nutriments_sol, ve_salinite, ve_texture_sol, ve_mat_org_sol, "
|
93 |
." ve_nutriments_sol, ve_salinite, ve_texture_sol, ve_mat_org_sol, "
|
97 |
." vi_lumiere, vi_temperature, vi_continentalite, vi_humidite_edaph,"
|
94 |
." vi_lumiere, vi_temperature, vi_continentalite, vi_humidite_edaph,"
|
98 |
." vi_reaction_sol, vi_nutriments_sol, vi_salinite ";
|
95 |
." vi_reaction_sol, vi_nutriments_sol, vi_salinite ";
|
99 |
$this->Requete->requete_condition[] = "( ve_lumiere != '' OR ve_temperature != '' ".
|
96 |
$this->requete_condition[] = "( ve_lumiere != '' OR ve_temperature != '' ".
|
100 |
"OR ve_continentalite != '' OR ve_humidite_atmos != '' ".
|
97 |
"OR ve_continentalite != '' OR ve_humidite_atmos != '' ".
|
101 |
"OR ve_humidite_edaph != '' OR ve_reaction_sol != '' ".
|
98 |
"OR ve_humidite_edaph != '' OR ve_reaction_sol != '' ".
|
102 |
"OR ve_nutriments_sol != '' OR ve_salinite != '' ".
|
99 |
"OR ve_nutriments_sol != '' OR ve_salinite != '' ".
|
103 |
"OR ve_texture_sol != '' OR ve_mat_org_sol != '' )";
|
100 |
"OR ve_texture_sol != '' OR ve_mat_org_sol != '' )";
|
104 |
} else {
|
101 |
} else {
|
Line 131... |
Line 128... |
131 |
|
128 |
|
132 |
public function traiterRessources() {
|
129 |
public function traiterRessources() {
|
133 |
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)){
|
130 |
if(preg_match('/^(.+)\.nn:([0-9]+)$/', $this->ressources[0], $retour)){
|
134 |
switch ($retour[1]) {
|
131 |
switch ($retour[1]) {
|
135 |
case 'bdtfx' :
|
132 |
case 'bdtfx' :
|
136 |
$this->Requete->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDTFX' ";
|
- |
|
137 |
|
133 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDTFX' ";
|
138 |
break;
|
134 |
break;
|
139 |
case 'bdafx' :
|
135 |
case 'bdafx' :
|
140 |
$this->Requete->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDAFX' ";
|
136 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDAFX' ";
|
141 |
break;
|
137 |
break;
|
142 |
case 'bdbfx' :
|
138 |
case 'bdbfx' :
|
143 |
$this->Requete->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDBFX' ";
|
139 |
$this->requete_condition[] = "num_nomen = ".$retour[2]." AND BDNT = 'BDBFX' ";
|
144 |
break;
|
140 |
break;
|
145 |
default :
|
141 |
default :
|
146 |
$e = 'Erreur dans l\'url de votre requête : </br> Le référentiel " '
|
142 |
$e = 'Erreur dans l\'url de votre requête : </br> Le référentiel " '
|
147 |
.$retour[1].' " n\'existe pas.';
|
143 |
.$retour[1].' " n\'existe pas.';
|
Line 166... |
Line 162... |
166 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
162 |
throw new Exception($e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
167 |
}
|
163 |
}
|
Line 168... |
Line 164... |
168 |
|
164 |
|
Line 169... |
Line 165... |
169 |
}
|
165 |
}
|
170 |
|
166 |
|
171 |
public function DefinirTables() {
|
167 |
public function definirTables() {
|
172 |
$table_num_version = $this->recupererVersionDisponible();
|
168 |
$table_num_version = $this->recupererVersionDisponible();
|
173 |
$prefixe_table = config::get('bdd_table');
|
169 |
$prefixe_table = config::get('bdd_table');
|
174 |
if ( in_array($this->version_projet,$table_num_version) ) {
|
170 |
if ( in_array($this->version_projet,$table_num_version) ) {
|
Line 190... |
Line 186... |
190 |
|
186 |
|
191 |
public function retournerResultatFormate($resultat) {
|
187 |
public function retournerResultatFormate($resultat) {
|
192 |
$resultat_json = $resultat[0];
|
188 |
$resultat_json = $resultat[0];
|
193 |
if ($this->retour_format == 'max'){
|
189 |
if ($this->retour_format == 'max'){
|
194 |
if (!isset($this->parametres['categorie']) ) {
|
190 |
if (!isset($this->parametres['categorie']) ) {
|
195 |
$resultat_json = $this->formaterResultatsTousChamps($resultat_json);
|
191 |
$this->formaterResultatsTousChamps($resultat_json);
|
196 |
} elseif ($this->parametres['categorie'] == 'ecologie') {
|
192 |
} elseif ($this->parametres['categorie'] == 'ecologie') {
|
197 |
$resultat_json = $this->formaterResultatsChampsEcologie($resultat_json);
|
193 |
$this->formaterResultatsChampsEcologie($resultat_json);
|
198 |
} elseif ($this->parametres['categorie'] == 'description') {
|
194 |
} elseif ($this->parametres['categorie'] == 'description') {
|
199 |
$resultat_json = $this->formaterResultatsChampsDescription($resultat_json);
|
195 |
$this->formaterResultatsChampsDescription($resultat_json);
|
200 |
}
|
196 |
}
|
201 |
}
|
197 |
}
|
202 |
return $resultat_json;
|
198 |
return $this->resultat_json;
|
Line 203... |
Line 199... |
203 |
}
|
199 |
}
|
204 |
|
200 |
|
205 |
public function formaterResultatsTousChamps($resultat) {
|
- |
|
206 |
$resultat_json = $resultat;
|
- |
|
207 |
if ($resultat_json['type_bio'] != ""){
|
201 |
public function formaterResultatsTousChamps($resultat) {
|
208 |
$tab_ontologie = $this->recupererOntologiePrTypeBio($resultat_json['type_bio']);
|
- |
|
209 |
unset($resultat_json['type_bio']);
|
- |
|
210 |
$resultat_json= array_merge($resultat_json,$tab_ontologie);
|
- |
|
211 |
}
|
202 |
$this->resultat_json = $resultat;
|
212 |
$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
|
- |
|
213 |
$Graphique_presence = false;
|
- |
|
214 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
- |
|
215 |
if ($resultat_json[$cle] != ""){
|
- |
|
216 |
$Graphique_presence = true;
|
- |
|
217 |
$tab_ontologie = $this->recupererOntologies($resultat_json[$cle], $cle);
|
- |
|
218 |
unset($resultat_json[$cle]);
|
- |
|
219 |
$resultat_json = array_merge($resultat_json,$tab_ontologie);
|
- |
|
220 |
}
|
203 |
$this->traiterTypeBio();
|
221 |
}
|
- |
|
222 |
if ($Graphique_presence) {
|
- |
|
223 |
$resultat_json['graphique_climat']['libelle'] = 'climat';
|
204 |
$graphique_presence = $this->traiterOntologieEcologie() ;
|
224 |
$resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat', strtolower($resultat_json['BDNT']).'.nn:'.$resultat_json['num_nomen']);
|
- |
|
225 |
$resultat_json['graphique_sol']['libelle'] = 'sol';
|
205 |
if ($graphique_presence) {
|
226 |
$resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol', strtolower($resultat_json['BDNT']).'.nn:'.$resultat_json['num_nomen']);
|
- |
|
227 |
}
|
206 |
$graphique = $this->ajouterLiensGraphique();
|
228 |
return $resultat_json ;
|
207 |
}
|
229 |
}
|
208 |
}
|
230 |
|
209 |
|
- |
|
210 |
public function formaterResultatsChampsEcologie($resultat) {
|
- |
|
211 |
$this->resultat_json = $resultat;
|
- |
|
212 |
$graphique_presence = $this->traiterOntologieEcologie() ;
|
- |
|
213 |
if ($graphique_presence) {
|
- |
|
214 |
$graphique = $this->ajouterLiensGraphique();
|
- |
|
215 |
}
|
- |
|
216 |
}
|
- |
|
217 |
|
- |
|
218 |
|
- |
|
219 |
public function formaterResultatsChampsDescription($resultat) {
|
- |
|
220 |
$this->resultat_json = $resultat;
|
- |
|
221 |
$this->traiterTypeBio();
|
- |
|
222 |
}
|
- |
|
223 |
|
231 |
public function formaterResultatsChampsEcologie($resultat) {
|
224 |
public function traiterOntologieEcologie() {
|
232 |
$resultat_json = $resultat;
|
- |
|
233 |
$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
|
225 |
$donnees_presence = false;
|
234 |
$Graphique_presence = false;
|
226 |
$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
|
235 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
227 |
foreach ($this->champs_ontologiques as $cle => $valeur){
|
236 |
if ($resultat_json[$cle] != ""){
|
228 |
if ($this->resultat_json[$cle] != ""){
|
237 |
$Graphique_presence = true;
|
229 |
$donnees_presence = true;
|
238 |
$tab_ontologie = $this->recupererOntologies($resultat_json[$cle], $cle);
|
- |
|
239 |
unset($resultat_json[$cle]);
|
230 |
$this->recupererOntologies($this->resultat_json[$cle], $cle);
|
240 |
$resultat_json = array_merge($resultat_json,$tab_ontologie);
|
231 |
unset($this->resultat_json[$cle]);
|
241 |
}
|
232 |
}
|
- |
|
233 |
}
|
- |
|
234 |
return $donnees_presence;
|
- |
|
235 |
}
|
242 |
}
|
236 |
|
243 |
if ($Graphique_presence) {
|
237 |
public function traiterTypeBio() {
|
244 |
$resultat_json['graphique_climat']['libelle'] = 'climat';
|
238 |
if ($this->resultat_json['type_bio'] != ""){
|
245 |
$resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat', strtolower($resultat_json['BDNT']).'.nn:'.$resultat_json['num_nomen']);
|
239 |
$tab_ontologie = $this->recupererOntologiePrTypeBio($this->resultat_json['type_bio']);
|
246 |
$resultat_json['graphique_sol']['libelle'] = 'sol';
|
240 |
unset($this->resultat_json['type_bio']);
|
247 |
$resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol', strtolower($resultat_json['BDNT']).'.nn:'.$resultat_json['num_nomen']);
|
- |
|
248 |
}
|
241 |
$this->resultat_json= array_merge($this->resultat_json,$tab_ontologie);
|
Line 249... |
Line 242... |
249 |
return $resultat_json ;
|
242 |
}
|
250 |
}
|
243 |
}
|
251 |
|
244 |
|
252 |
public function formaterResultatsChampsDescription($resultat) {
|
245 |
public function ajouterLiensGraphique() {
|
253 |
$resultat_json = $resultat;
|
246 |
$this->resultat_json['graphique_climat']['libelle'] = 'climat';
|
254 |
if ($resultat_json['type_bio'] != ""){
|
247 |
$this->resultat_json['graphique_climat']['href'] =
|
255 |
$tab_ontologie = $this->recupererOntologiePrTypeBio($resultat_json['type_bio']);
|
- |
|
256 |
unset($resultat_json['type_bio']);
|
248 |
$this->ajouterHref('graphiques/climat', strtolower($this->resultat_json['BDNT']).'.nn:'.$this->resultat_json['num_nomen']);
|
257 |
$resultat_json = array_merge($resultat_json,$tab_ontologie);
|
249 |
$this->resultat_json['graphique_sol']['libelle'] = 'sol';
|
Line 258... |
Line -... |
258 |
}
|
- |
|
259 |
return $resultat_json ;
|
- |
|
260 |
}
|
- |
|
261 |
|
250 |
$this->resultat_json['graphique_sol']['href'] =
|
Line 262... |
Line 251... |
262 |
|
251 |
$this->ajouterHref('graphiques/sol', strtolower($this->resultat_json['BDNT']).'.nn:'.$this->resultat_json['num_nomen']);
|
263 |
|
252 |
}
|
264 |
|
253 |
|
265 |
|
254 |
|
266 |
//+--------------------------traitement ontologies -------------------------------------------+
|
255 |
//+--------------------------traitement ontologies -------------------------------------------+
|
267 |
|
256 |
|
268 |
public function recupererOntologies($valeur, $champs){
|
257 |
public function recupererOntologies($valeur, $champs){
|
269 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
- |
|
270 |
'/ontologies/'.$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur));
|
258 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
- |
|
259 |
'/ontologies/'.$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur));
|
- |
|
260 |
$val = $this->consulterHref($url);
|
Line 271... |
Line 261... |
271 |
$val = $this->consulterHref($url);
|
261 |
$this->resultat_json[$champs.'.libelle'] = $val->nom;
|
272 |
$resultat_json[$champs.'.libelle'] = $val->nom;
|
262 |
$this->resultat_json[$champs.'.code'] = $valeur;
|
273 |
$resultat_json[$champs.'.code'] = $valeur;
|
263 |
$this->resultat_json[$champs.'.href'] = $url;
|
274 |
$resultat_json[$champs.'.href'] = $url;
|
- |
|
275 |
return $resultat_json;
|
264 |
}
|
- |
|
265 |
|
- |
|
266 |
//+-------------ontologie pour le champs type biologique (lire le .txt)---+
|
- |
|
267 |
|
- |
|
268 |
public function recupererOntologiePrTypeBio($type_a_traiter){
|
- |
|
269 |
$resultat_typeBio = "";
|
- |
|
270 |
if ($type_a_traiter != "") {
|
- |
|
271 |
$types_prim_sec = $this->separerTypesPrimairesSecondaires($type_a_traiter);
|
- |
|
272 |
$types_sstypes = $this->classerPrimSecEnTypesSsTypes($types_prim_sec);
|
276 |
}
|
273 |
$resultat_typeBio = $this->formaterJsonTypeBio($types_sstypes, $type_a_traiter );
|
277 |
|
274 |
}
|
278 |
public function recupererOntologiePrTypeBio($type_a_traiter){
|
275 |
return $resultat_typeBio;
|
279 |
$resultat_typeBio = "";
|
276 |
}
|
280 |
if ($type_a_traiter != "") {
|
277 |
|
281 |
$resultat_typeBio['type_bio.code'] = $type_a_traiter;
|
278 |
public function classerPrimSecEnTypesSsTypes($types_prim_sec) {
|
282 |
$types_prim_sec = $this->separerTypesPrimairesSecondaires($type_a_traiter);
|
279 |
$types_sstypes = '';
|
283 |
foreach ($types_prim_sec as $cle => $tb) {
|
280 |
foreach ($types_prim_sec as $cle => $tb) {
|
284 |
$types_sstypes[$cle]= $this->separerTypes_SousTypes($tb, $cle);
|
281 |
$types_sstypes[$cle]= $this->separerTypes_SousTypes($tb, $cle);
|
285 |
}
|
282 |
}
|
286 |
switch (count($types_sstypes)) {
|
283 |
switch (count($types_sstypes)) {
|
287 |
case 1 :
|
- |
|
288 |
$types_sstypes = $types_sstypes['principal'];
|
- |
|
289 |
break;
|
284 |
case 1 :
|
290 |
case 2 :
|
- |
|
291 |
$types_sstypes = array_merge($types_sstypes['principal'],$types_sstypes['secondaire']);
|
285 |
$types_sstypes = $types_sstypes['principal'];
|
- |
|
286 |
break;
|
Line -... |
Line 287... |
- |
|
287 |
case 2 :
|
- |
|
288 |
$types_sstypes = array_merge($types_sstypes['principal'],$types_sstypes['secondaire']);
|
292 |
break;
|
289 |
break;
|
293 |
case 3 :
|
290 |
}
|
- |
|
291 |
return $types_sstypes;
|
- |
|
292 |
}
|
294 |
$types_sstypes = array_merge($types_sstypes['principal'],
|
293 |
|
295 |
$types_sstypes['secondaire'],
|
294 |
|
296 |
$types_sstypes['special']);
|
295 |
public function formaterJsonTypeBio( $types_sstypes, $type_a_traiter) {
|
297 |
break;
|
296 |
$resultat_typeBio['type_bio.code'] = $type_a_traiter;
|
298 |
}
|
297 |
foreach ($types_sstypes as $cle => $tb) {
|
299 |
|
298 |
if (($cle == 'type.principal') || ($cle == 'type.secondaire')) {
|
300 |
foreach ($types_sstypes as $cle => $tb) {
|
299 |
$i = 0;
|
301 |
if (($cle == 'type.principal') || ($cle == 'type.secondaire')) {
|
300 |
foreach ($tb as $types) {
|
- |
|
301 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
302 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
302 |
'/ontologies/TB:'.urlencode(urlencode($types));
|
303 |
'/ontologies/TB:'.urlencode(urlencode($tb));
|
303 |
$val = $this->consulterHref($url);
|
304 |
$val = $this->consulterHref($url);
|
304 |
$libelle[$cle]= $val->nom;
|
305 |
$libelle[$cle]= $val->nom;
|
305 |
$detail[$cle]['libelle'] = $val->nom;
|
306 |
$detail[$cle]['libelle'] = $val->nom;
|
306 |
$detail[$cle]['code'] = $val->code;
|
307 |
$detail[$cle]['code'] = $val->code;
|
307 |
$detail[$cle]['href'] = $url;
|
308 |
$detail[$cle]['href'] = $url;
|
308 |
}
|
309 |
}
|
309 |
}
|
310 |
if ($cle == 'sous_type.principal' || $cle == 'sous_type.secondaire' || $cle == 'sous_type.special') {
|
310 |
if ($cle == 'sous_type.principal' || $cle == 'sous_type.secondaire' ) {
|
311 |
$i = 0;
|
311 |
$i = 0;
|
312 |
foreach ($tb as $sstypes) {
|
312 |
foreach ($tb as $sstypes) {
|
313 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
- |
|
314 |
'/ontologies/ssTT:'.urlencode(urlencode($sstypes));
|
313 |
$url = Config::get('url_service_base').Config::get('nom_projet').
|
315 |
$val = $this->consulterHref($url);
|
314 |
'/ontologies/ssTT:'.urlencode(urlencode($sstypes));
|
316 |
$libelle[$cle]=$val->nom;
|
- |
|
317 |
$detail[$cle][$i]['libelle'] = $val->nom;
|
- |
|
318 |
$detail[$cle][$i]['code'] = $val->code;
|
315 |
$val = $this->consulterHref($url);
|
- |
|
316 |
$libelle[$cle]=$val->nom;
|
- |
|
317 |
$detail[$cle][$i]['libelle'] = $val->nom;
|
319 |
$detail[$cle][$i]['href'] = $url;
|
318 |
$detail[$cle][$i]['code'] = $val->code;
|
320 |
$i++;
|
319 |
$detail[$cle][$i]['href'] = $url;
|
- |
|
320 |
$i++;
|
321 |
}
|
321 |
}
|
322 |
}
|
322 |
}
|
323 |
}
|
323 |
}
|
324 |
$resultat_typeBio['type_bio.libelle']= $this->formaterTypeBioPrLibelle($libelle);
|
324 |
$resultat_typeBio['type_bio.libelle']= $this->formaterTypeBioPrLibelle($libelle);
|
325 |
$resultat_typeBio['type_bio.detail'] = $detail;
|
325 |
$resultat_typeBio['type_bio.detail'] = $detail;
|
326 |
}
|
326 |
return $resultat_typeBio;
|
327 |
return $resultat_typeBio;
|
- |
|
328 |
}
|
327 |
}
|
329 |
|
328 |
|
Line -... |
Line 329... |
- |
|
329 |
|
330 |
public function formaterTypeBioPrLibelle($info) {
|
330 |
public function formaterTypeBioPrLibelle($info) {
|
331 |
$libelle = $info['type.principal']." ";
|
331 |
$libelle = $info['type.principal']." ";
|
332 |
$libelle .= isset($info['sous_type.principal']) ? " (".$info['sous_type.principal'].") " : "";
|
- |
|
333 |
$libelle .= isset($info['type.secondaire']) ? ", ".$info['type.secondaire']." " : "";
|
332 |
$libelle .= isset($info['sous_type.principal']) ? " (".$info['sous_type.principal'].") " : "";
|
334 |
$libelle .= isset($info['sous_type.secondaire']) ? "(".$info['sous_type.secondaire'].") " : "";
|
333 |
$libelle .= isset($info['type.secondaire']) ? ", ".$info['type.secondaire']." " : "";
|
335 |
$libelle .= isset($info['sous_type.special']) ? "(".$info['sous_type.special'].") " : "";
|
334 |
$libelle .= isset($info['sous_type.secondaire']) ? "(".$info['sous_type.secondaire'].") " : "";
|
336 |
return $libelle;
|
- |
|
337 |
}
|
335 |
return $libelle;
|
338 |
|
336 |
}
|
339 |
public function separerTypesPrimairesSecondaires($type) {
|
337 |
|
340 |
$types = array();
|
338 |
//séparation des principaux et des secondaires
|
341 |
//séparation des principaux et des secondaires
|
339 |
public function separerTypesPrimairesSecondaires($type) {
|
Line -... |
Line 340... |
- |
|
340 |
$types = array();
|
342 |
if (preg_match("/(.+)\((.+)\)\-{0,1}(.+){0,1}/", $type,$retour) == 1) {
|
341 |
if (preg_match("/(.+)\((.+)\)\-{0,1}(.+){0,1}/", $type,$retour)) {
|
343 |
$types['principal'] = $retour[1];
|
342 |
$types['principal'] = isset($retour[3]) ? $retour[1].'-'. $retour[3] : $retour[1] ;
|
344 |
$types['secondaire'] = $retour[2];
|
343 |
$types['secondaire'] = $retour[2];
|
- |
|
344 |
} else {
|
345 |
if (isset($retour[3])){$types['special'] = $retour[3];}
|
345 |
$types['principal'] = $type;
|
346 |
} else {
|
- |
|
347 |
$types['principal'] = $type;
|
346 |
}
|
348 |
}
|
347 |
return $types;
|
349 |
return $types;
|
348 |
}
|
- |
|
349 |
|
350 |
}
|
350 |
|
351 |
|
351 |
public function separerTypes_SousTypes($type_a_traiter, $typePrimOuSec) {
|
- |
|
352 |
$types = array();
|
- |
|
353 |
if (preg_match("/^([a-zA-Zé]+)\-(.+)$|^([a-zA-Zé,]+[^\-])$/", $type_a_traiter, $retour)) {
|
352 |
public function separerTypes_SousTypes($type_a_traiter, $typePrimOuSec) {
|
354 |
//type
|
353 |
$types = array();
|
355 |
$type = array();
|
354 |
if (preg_match("/^([a-zA-Zé]+)\-(.+)$|^([a-zA-Zé]+[^\-])$/", $type_a_traiter, $retour) == 1) {
|
- |
|
355 |
//recupère le type unique
|
356 |
$type[0] = (isset($retour[3])) ? $retour[3] : $retour[1] ;
|
356 |
|
357 |
if (preg_match("/,/", $type[0])) {
|
357 |
$type = (isset($retour[3]) && ($typePrimOuSec != 'special') ) ? $retour[3] : $retour[1] ;
|
358 |
$type = preg_split("/,/", $type[0]);
|
358 |
$types['type.'.$typePrimOuSec]= $type;
|
359 |
}
|
359 |
//recupère le ou les sous-types
|
360 |
for ($i = 0 ; $i < count($type); $i++) {
|
360 |
if (isset($retour[3]) && $typePrimOuSec == 'special') {
|
361 |
$types['type.'.$typePrimOuSec][$i] = $type[$i];
|
361 |
$ss_types[0] = (isset($retour[3]) && ($typePrimOuSec == 'special') ) ? $retour[3] : "" ;
|
362 |
}
|
362 |
} elseif (isset($retour[2]) && $retour[2] != '') {
|
363 |
//sous types
|
363 |
$ss_types[0]= (isset($retour[2]) && ($retour[2] != "") ) ? $retour[2] : "" ;
|
364 |
$ss_types = array();
|
364 |
}
|
365 |
if (isset($retour[2]) && $retour[2] != '') {
|
- |
|
366 |
$ss_types[0] = $retour[2] ;
|
- |
|
367 |
if (preg_match("/\-/", $ss_types[0])) {
|
- |
|
368 |
$ss_types = preg_split("/\-/", $ss_types[0]);
|
- |
|
369 |
}
|
- |
|
370 |
for ($i = 0 ; $i < count($ss_types); $i++) {
|
- |
|
371 |
$types['sous_type.'.$typePrimOuSec][$i] = $ss_types[$i];
|
- |
|
372 |
}
|
- |
|
373 |
}
|
- |
|
374 |
}
|
- |
|
375 |
return $types;
|
- |
|
376 |
}
|
- |
|
377 |
|
- |
|
378 |
|
- |
|
379 |
|
- |
|
380 |
|
- |
|
381 |
|
- |
|
382 |
//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
|
- |
|
383 |
|
- |
|
384 |
public function assemblerLaRequete() {
|
- |
|
385 |
$requete = ' SELECT '.$this->champs_recherches.' FROM '.$this->table.' '
|
- |
|
386 |
.$this->retournerRequeteCondition();
|
- |
|
387 |
return $requete;
|
365 |
if (isset($ss_types[0])) {
|
388 |
}
|
Line 366... |
Line 389... |
366 |
if (preg_match("/\-/", $ss_types[0]) == 1) {
|
389 |
|