1 |
<?php
|
1 |
<?php
|
2 |
|
2 |
|
3 |
/**
|
3 |
/**
|
4 |
* Description :
|
4 |
* Description :
|
5 |
* Classe Textes.php est une classe qui contient les méthodes permettant la consultation des textes (clé de détermination
|
5 |
* Classe Textes.php est une classe qui contient les méthodes permettant la consultation des textes (clé de détermination
|
6 |
* ou description). Les identifiants des textes correspondent au tag de type CleCoste1937TXXPXXNomSci pour le projet
|
6 |
* ou description). Les identifiants des textes correspondent au tag de type CleCoste1937TXXPXXNomSci pour le projet
|
7 |
* coste.
|
7 |
* coste.
|
8 |
* Encodage en entrée : utf8
|
8 |
* Encodage en entrée : utf8
|
9 |
* Encodage en sortie : utf8
|
9 |
* Encodage en sortie : utf8
|
10 |
* @package framework-v3
|
10 |
* @package framework-v3
|
11 |
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
|
11 |
* @author Jennifer Dhé <jennifer.dhe@tela-botanica.org>
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
14 |
* @version 1.0
|
14 |
* @version 1.0
|
15 |
* @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
|
15 |
* @copyright 1999-${year} Tela Botanica (accueil@tela-botanica.org)
|
16 |
*/
|
16 |
*/
|
17 |
|
17 |
|
18 |
|
18 |
|
19 |
class Textes extends Commun {
|
19 |
class Textes extends Commun {
|
20 |
|
20 |
|
21 |
protected $limite_requete = array('depart' => 0, 'limite' => 100);
|
21 |
protected $limite_requete = array('depart' => 0, 'limite' => 100);
|
22 |
protected $requete_champ = ' t1.resource AS tag, t1.value AS num_nom, t2.value AS titre, p.body AS texte';
|
22 |
protected $requete_champ = ' t1.resource AS tag, t1.value AS num_nom, t2.value AS titre, p.body AS texte';
|
23 |
protected $requete_condition = null;
|
23 |
protected $requete_condition = null;
|
24 |
protected $requete_group_by = ' ORDER BY CAST( t1.value AS DECIMAL )';
|
24 |
protected $requete_group_by = ' ORDER BY CAST( t1.value AS DECIMAL )';
|
25 |
protected $table_retour;
|
25 |
protected $table_retour;
|
26 |
protected $retour_format = 'max';
|
26 |
protected $retour_format = 'max';
|
27 |
protected $format_reponse = 'textes';
|
27 |
protected $format_reponse = 'textes';
|
28 |
protected $table_param = array();
|
28 |
protected $table_param = array();
|
29 |
protected $total_resultat;
|
29 |
protected $total_resultat;
|
30 |
protected $table_ressources = array();
|
30 |
protected $table_ressources = array();
|
31 |
protected $html = 'txt';
|
31 |
protected $html = 'txt';
|
32 |
protected $recherche = 'stricte';
|
32 |
protected $recherche = 'stricte';
|
33 |
protected $service = 'textes';
|
33 |
protected $service = 'textes';
|
34 |
protected $masque = null;
|
34 |
protected $masque = null;
|
35 |
protected $config;
|
35 |
protected $config;
|
36 |
|
36 |
|
37 |
public function __construct($config) {
|
37 |
public function __construct($config) {
|
38 |
$this->config = is_null($config) ? Config::get('Textes') : $config;
|
38 |
$this->config = is_null($config) ? Config::get('Textes') : $config;
|
39 |
}
|
39 |
}
|
40 |
|
40 |
|
41 |
public function consulter($ressources, $parametres) {
|
41 |
public function consulter($ressources, $parametres) {
|
42 |
|
42 |
|
43 |
$resultat_formate = '';
|
43 |
$resultat_formate = '';
|
44 |
$this->table = array(Config::get("bdd_triples")." t1", Config::get("bdd_triples")." t2", Config::get("bdd_pages")." p");
|
44 |
$this->table = array(Config::get("bdd_triples")." t1", Config::get("bdd_triples")." t2", Config::get("bdd_pages")." p");
|
45 |
$this->traiterParametres($parametres);
|
45 |
$this->traiterParametres($parametres);
|
46 |
$this->traiterRessources($ressources);
|
46 |
$this->traiterRessources($ressources);
|
47 |
if ($this->corps_http == '' && $this->entete_http == '') {
|
47 |
if ($this->corps_http == '' && $this->entete_http == '') {
|
48 |
$requete = $this->assemblerLaRequete();
|
48 |
$requete = $this->assemblerLaRequete();
|
49 |
$resultat = $this->getBdd()->recupererTous($requete);
|
49 |
$resultat = $this->getBdd()->recupererTous($requete);
|
50 |
$this->testerResultat($resultat, $resultat_formate, $requete);
|
50 |
$this->testerResultat($resultat, $resultat_formate, $requete);
|
51 |
}
|
51 |
}
|
52 |
return $this->formerReponseHTTP($resultat_formate);
|
52 |
return $this->formerReponseHTTP($resultat_formate);
|
53 |
}
|
53 |
}
|
54 |
|
54 |
|
55 |
public function formerReponseHTTP($resultat_formate, $mime = 'application/json', $encodage= 'utf-8') {
|
55 |
public function formerReponseHTTP($resultat_formate, $mime = 'application/json', $encodage= 'utf-8') {
|
56 |
// Si aucune erreur n'a été établie (donc un tableau de résultat a bien ete renvoyé...)
|
56 |
// Si aucune erreur n'a été établie (donc un tableau de résultat a bien ete renvoyé...)
|
57 |
if ($this->corps_http == '' && $this->entete_http == '') {
|
57 |
if ($this->corps_http == '' && $this->entete_http == '') {
|
58 |
$this->entete_http = RestServeur::HTTP_CODE_OK;
|
58 |
$this->entete_http = RestServeur::HTTP_CODE_OK;
|
59 |
$this->corps_http = $resultat_formate;
|
59 |
$this->corps_http = $resultat_formate;
|
60 |
}
|
60 |
}
|
61 |
if ($this->entete_http != RestServeur::HTTP_CODE_OK) {
|
61 |
if ($this->entete_http != RestServeur::HTTP_CODE_OK) {
|
62 |
$mime = 'text/html';
|
62 |
$mime = 'text/html';
|
63 |
}
|
63 |
}
|
64 |
// Gestion du type de contenu
|
64 |
// Gestion du type de contenu
|
65 |
if (!is_null($mime) && !is_null($encodage)) {
|
65 |
if (!is_null($mime) && !is_null($encodage)) {
|
66 |
header("Content-Type: $mime; charset=$encodage");
|
66 |
header("Content-Type: $mime; charset=$encodage");
|
67 |
} else if (!is_null($mime) && is_null($encodage)) {
|
67 |
} else if (!is_null($mime) && is_null($encodage)) {
|
68 |
header("Content-Type: $mime");
|
68 |
header("Content-Type: $mime");
|
69 |
}
|
69 |
}
|
70 |
// Envoie de l'entête
|
70 |
// Envoie de l'entête
|
71 |
RestServeur::envoyerEnteteStatutHttp($this->entete_http);
|
71 |
RestServeur::envoyerEnteteStatutHttp($this->entete_http);
|
72 |
// Envoie du corps
|
72 |
// Envoie du corps
|
73 |
return $this->corps_http;
|
73 |
return $this->corps_http;
|
74 |
}
|
74 |
}
|
75 |
|
75 |
|
76 |
|
76 |
|
77 |
public function testerResultat($resultat, &$resultat_formate, $requete) {
|
77 |
public function testerResultat($resultat, &$resultat_formate, $requete) {
|
78 |
if ($resultat == '') { //cas ou coste/services/ ou la requete comporte des erreurs
|
78 |
if ($resultat == '') { //cas ou coste/services/ ou la requete comporte des erreurs
|
79 |
$e = 'La requête SQL formée comporte une erreur!';
|
79 |
$e = 'La requête SQL formée comporte une erreur!';
|
80 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$e);
|
80 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$e);
|
81 |
Debug::printr($requete);
|
81 |
Debug::printr($requete);
|
82 |
} elseif ($resultat) {
|
82 |
} elseif ($resultat) {
|
83 |
$resultat_formate = $this->retournerResultatFormate($resultat);
|
83 |
$resultat_formate = $this->retournerResultatFormate($resultat);
|
84 |
} else {
|
84 |
} else {
|
85 |
if ($this->format_reponse == 'textes/relations') {
|
85 |
if ($this->format_reponse == 'textes/relations') {
|
86 |
$resultat_formate = 'null';
|
86 |
$resultat_formate = 'null';
|
87 |
} else {
|
87 |
} else {
|
88 |
$m = 'Données introuvables dans la base';
|
88 |
$m = 'Données introuvables dans la base';
|
89 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$m);
|
89 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE,$m);
|
90 |
Debug::printr($requete);
|
90 |
Debug::printr($requete);
|
91 |
}
|
91 |
}
|
92 |
}
|
92 |
}
|
93 |
}
|
93 |
}
|
94 |
|
94 |
|
95 |
|
95 |
|
96 |
//---------------------------------TRAITER RESSOURCES-----------------------------------------------------------------
|
96 |
//---------------------------------TRAITER RESSOURCES-----------------------------------------------------------------
|
97 |
|
97 |
|
98 |
public function traiterRessources(&$ressources) {
|
98 |
public function traiterRessources(&$ressources) {
|
99 |
if (isset($ressources) && !empty($ressources)) {
|
99 |
if (isset($ressources) && !empty($ressources)) {
|
100 |
$this->table = Config::get('bdd_triples');
|
100 |
$this->table = Config::get('bdd_triples');
|
101 |
$this->table_ressources = $ressources;
|
101 |
$this->table_ressources = $ressources;
|
102 |
if ($ressources[0] == 'relations') {
|
102 |
if ($ressources[0] == 'relations') {
|
103 |
$this->traiterRelationsProjet($ressources);
|
103 |
$this->traiterRelationsProjet($ressources);
|
104 |
$this->format_reponse .= '/relations';
|
104 |
$this->format_reponse .= '/relations';
|
105 |
} elseif (isset($this->table_ressources[0]) && !empty($this->table_ressources[0])) {
|
105 |
} elseif (isset($this->table_ressources[0]) && !empty($this->table_ressources[0])) {
|
106 |
$this->traiterRessourceId($this->table_ressources[0]);
|
106 |
$this->traiterRessourceId($this->table_ressources[0]);
|
107 |
if (isset($this->table_ressources[1]) && !empty($this->table_ressources[1])) {
|
107 |
if (isset($this->table_ressources[1]) && !empty($this->table_ressources[1])) {
|
108 |
$this->format_reponse .= '/champ';
|
108 |
$this->format_reponse .= '/champ';
|
109 |
}
|
109 |
}
|
110 |
} else {
|
110 |
} else {
|
111 |
$e = "Erreur dans votre requête. <br/> Les ressources disponibles sont :
|
111 |
$e = "Erreur dans votre requête. <br/> Les ressources disponibles sont :
|
112 |
<li> /textes/#id (id correspondant au tag de la page </li>
|
112 |
<li> /textes/#id (id correspondant au tag de la page </li>
|
113 |
<li> /textes/#id/#champ+#champ </li>
|
113 |
<li> /textes/#id/#champ+#champ </li>
|
114 |
<li> /textes/relations/bdtfx/#id (id correspondant au num_nom du projet bdtfx </li>";
|
114 |
<li> /textes/relations/bdtfx/#id (id correspondant au num_nom du projet bdtfx </li>";
|
115 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
115 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
116 |
}
|
116 |
}
|
117 |
} else {
|
117 |
} else {
|
118 |
$this->traiterRessourcesListe();
|
118 |
$this->traiterRessourcesListe();
|
119 |
}
|
119 |
}
|
120 |
$this->requete_condition[] = "p.latest = 'Y'";
|
120 |
$this->requete_condition[] = "p.latest = 'Y'";
|
121 |
}
|
121 |
}
|
122 |
|
122 |
|
123 |
public function traiterRessourceId($id) {
|
123 |
public function traiterRessourceId($id) {
|
124 |
$this->format_reponse .= '/id';
|
124 |
$this->format_reponse .= '/id';
|
125 |
if ($this->recherche == 'etendue') {
|
125 |
if ($this->recherche == 'etendue') {
|
126 |
$id = '%'.str_replace(' ','%', $id).'%';
|
126 |
$id = '%'.str_replace(' ','%', $id).'%';
|
127 |
}
|
127 |
}
|
128 |
if (is_numeric($id)) {
|
128 |
if (is_numeric($id)) {
|
129 |
$this->requete_condition[] = 'c.id ='.$this->getBdd()->proteger($id);
|
129 |
$this->requete_condition[] = 'c.id ='.$this->getBdd()->proteger($id);
|
130 |
} else {
|
130 |
} else {
|
131 |
$id = explode('bdtfx.nn:', $id);
|
131 |
$id = explode('bdtfx.nn:', $id);
|
132 |
if (is_numeric($id[1])) {
|
132 |
if (isset($id[1]) && is_numeric($id[1])) {
|
133 |
$this->requete_condition[] = 'c.num_nom ='.$this->getBdd()->proteger($id[1]);
|
133 |
$this->requete_condition[] = 'c.num_nom ='.$this->getBdd()->proteger($id[1]);
|
- |
|
134 |
} else {
|
- |
|
135 |
$e = "Erreur dans votre requête. <br/> Dans le cas d'une ressource bdtfx.nn: le num nom est obligatoire !";
|
- |
|
136 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
134 |
}
|
137 |
}
|
135 |
}
|
138 |
}
|
136 |
|
139 |
|
137 |
$this->requete_champ = 'c.id AS num_nom, i.nom_sci AS titre, t1.resource AS tag, p.body AS texte';
|
140 |
$this->requete_champ = 'c.id AS num_nom, i.nom_sci AS titre, t1.resource AS tag, p.body AS texte';
|
138 |
$this->table = array(Config::get("bdd_correspondance_bdnff").' c',
|
141 |
$this->table = array(Config::get("bdd_correspondance_bdnff").' c',
|
139 |
Config::get("bdd_triples").' t1',
|
142 |
Config::get("bdd_triples").' t1',
|
140 |
Config::get("bdd_index").' i',
|
143 |
Config::get("bdd_index").' i',
|
141 |
Config::get("bdd_pages").' p');
|
144 |
Config::get("bdd_pages").' p');
|
142 |
|
145 |
|
143 |
$this->requete_condition[] = 'c.id = i.num_nom';
|
146 |
$this->requete_condition[] = 'c.id = i.num_nom';
|
144 |
$this->requete_condition[] = 'i.nom_sci = t1.value';
|
147 |
$this->requete_condition[] = 'i.nom_sci = t1.value';
|
145 |
$this->requete_condition[] = 't1.resource = p.tag';
|
148 |
$this->requete_condition[] = 't1.resource = p.tag';
|
146 |
|
149 |
|
147 |
/*$this->requete_champ = ' t1.resource AS tag, t1.value AS num_nom, t2.value AS titre, p.body AS texte';
|
150 |
/*$this->requete_champ = ' t1.resource AS tag, t1.value AS num_nom, t2.value AS titre, p.body AS texte';
|
148 |
$this->requete_condition[] = 't1.resource LIKE '.$this->getBdd()->proteger($id);
|
151 |
$this->requete_condition[] = 't1.resource LIKE '.$this->getBdd()->proteger($id);
|
149 |
$this->requete_condition[] = 't1.property = "num_nom"';
|
152 |
$this->requete_condition[] = 't1.property = "num_nom"';
|
150 |
$this->requete_condition[] = '(t1.resource = t2.resource AND t2.property = "titre")';
|
153 |
$this->requete_condition[] = '(t1.resource = t2.resource AND t2.property = "titre")';
|
151 |
$this->requete_condition[] = 't1.resource = p.tag';
|
154 |
$this->requete_condition[] = 't1.resource = p.tag';
|
152 |
$this->table = array(Config::get("bdd_triples").' t1',
|
155 |
$this->table = array(Config::get("bdd_triples").' t1',
|
153 |
Config::get("bdd_triples").' t2',
|
156 |
Config::get("bdd_triples").' t2',
|
154 |
Config::get("bdd_pages").' p');
|
157 |
Config::get("bdd_pages").' p');
|
155 |
$this->ajouterRechercheFloue('t1.resource', $id);*/
|
158 |
$this->ajouterRechercheFloue('t1.resource', $id);*/
|
156 |
}
|
159 |
}
|
157 |
|
160 |
|
158 |
public function traiterRessourcesListe() {
|
161 |
public function traiterRessourcesListe() {
|
159 |
$this->requete_condition[] = "t1.property = 'num_nom'";
|
162 |
$this->requete_condition[] = "t1.property = 'num_nom'";
|
160 |
$this->requete_condition[] = "(t1.resource = t2.resource AND t2.property = 'titre')";
|
163 |
$this->requete_condition[] = "(t1.resource = t2.resource AND t2.property = 'titre')";
|
161 |
$this->requete_condition[] = "t1.resource = p.tag";
|
164 |
$this->requete_condition[] = "t1.resource = p.tag";
|
162 |
}
|
165 |
}
|
163 |
|
166 |
|
164 |
public function traiterRelationsProjet($tab_ress) {
|
167 |
public function traiterRelationsProjet($tab_ress) {
|
165 |
$this->table = array(Config::get("bdd_triples")." t1", Config::get("bdd_pages")." p", Config::get("bdd_table").'_v0_1 c');
|
168 |
$this->table = array(Config::get("bdd_triples")." t1", Config::get("bdd_pages")." p", Config::get("bdd_table").'_v0_1 c');
|
166 |
$projet = $tab_ress[1];
|
169 |
$projet = $tab_ress[1];
|
167 |
$num_nom = $tab_ress[2];
|
170 |
$num_nom = $tab_ress[2];
|
168 |
$nom_champ_projet = "flore_$projet"."_num";
|
171 |
$nom_champ_projet = "flore_$projet"."_num";
|
169 |
if (isset($tab_ress[3])) {
|
172 |
if (isset($tab_ress[3])) {
|
170 |
$type = $tab_ress[3];
|
173 |
$type = $tab_ress[3];
|
171 |
if (!in_array($type, array('cle', 'dsc'))) {
|
174 |
if (!in_array($type, array('cle', 'dsc'))) {
|
172 |
$e = "Le type de texte ne peut etre que clé ou description";
|
175 |
$e = "Le type de texte ne peut etre que clé ou description";
|
173 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
176 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
174 |
}
|
177 |
}
|
175 |
}
|
178 |
}
|
176 |
$this->requete_condition[] = "c.flore_bdnff_num = ".$this->getBdd()->proteger($num_nom);
|
179 |
$this->requete_condition[] = "c.flore_bdnff_num = ".$this->getBdd()->proteger($num_nom);
|
177 |
$this->requete_condition[] = "t1.value = c.num_nom";
|
180 |
$this->requete_condition[] = "t1.value = c.num_nom";
|
178 |
$this->requete_condition[] = "t1.property = 'num_nom'";
|
181 |
$this->requete_condition[] = "t1.property = 'num_nom'";
|
179 |
$this->requete_condition[] = "t1.resource = p.tag";
|
182 |
$this->requete_condition[] = "t1.resource = p.tag";
|
180 |
$this->requete_champ = 't1.resource AS tag, t1.value AS num_nom, p.body AS texte';
|
183 |
$this->requete_champ = 't1.resource AS tag, t1.value AS num_nom, p.body AS texte';
|
181 |
if (isset($type)) $this->requete_condition[] = "t1.resource LIKE ".$this->getBdd()->proteger(ucfirst($type.'%'));
|
184 |
if (isset($type)) $this->requete_condition[] = "t1.resource LIKE ".$this->getBdd()->proteger(ucfirst($type.'%'));
|
182 |
}
|
185 |
}
|
183 |
|
186 |
|
184 |
|
187 |
|
185 |
public function ajouterRechercheFloue($nom_champ, $id) {
|
188 |
public function ajouterRechercheFloue($nom_champ, $id) {
|
186 |
if ($this->recherche == 'floue') {
|
189 |
if ($this->recherche == 'floue') {
|
187 |
$id = $this->getBdd()->proteger($id);
|
190 |
$id = $this->getBdd()->proteger($id);
|
188 |
$this->requete_condition[array_search("$nom_champ LIKE $id",
|
191 |
$this->requete_condition[array_search("$nom_champ LIKE $id",
|
189 |
$this->requete_condition)] =
|
192 |
$this->requete_condition)] =
|
190 |
"($nom_champ LIKE $id)".
|
193 |
"($nom_champ LIKE $id)".
|
191 |
" OR ( SOUNDEX($nom_champ) = SOUNDEX($id))".
|
194 |
" OR ( SOUNDEX($nom_champ) = SOUNDEX($id))".
|
192 |
" OR SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($id))))";
|
195 |
" OR SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($id))))";
|
193 |
}
|
196 |
}
|
194 |
}
|
197 |
}
|
195 |
|
198 |
|
196 |
//---------------------------------------TRAITER PARAMETRES-------------------------------------------------------------
|
199 |
//---------------------------------------TRAITER PARAMETRES-------------------------------------------------------------
|
197 |
|
200 |
|
198 |
public function traiterParametres($parametres) {
|
201 |
public function traiterParametres($parametres) {
|
199 |
if (isset($parametres) && !empty($parametres)) {
|
202 |
if (isset($parametres) && !empty($parametres)) {
|
200 |
$this->table_param = $parametres;
|
203 |
$this->table_param = $parametres;
|
201 |
if (isset($parametres['recherche']) && $parametres['recherche'] != '') {
|
204 |
if (isset($parametres['recherche']) && $parametres['recherche'] != '') {
|
202 |
$this->recherche = $parametres['recherche'];
|
205 |
$this->recherche = $parametres['recherche'];
|
203 |
}
|
206 |
}
|
204 |
foreach ($parametres as $param => $val) {
|
207 |
foreach ($parametres as $param => $val) {
|
205 |
switch ($param) {
|
208 |
switch ($param) {
|
206 |
case 'retour.format' : $this->retour_format = $val; break;
|
209 |
case 'retour.format' : $this->retour_format = $val; break;
|
207 |
case 'masque.titre' : $this->ajouterLeFiltreMasque('titre', $val); break;
|
210 |
case 'masque.titre' : $this->ajouterLeFiltreMasque('titre', $val); break;
|
208 |
case 'masque.famille' : $this->ajouterLeFiltreMasque('famille', $val); break;
|
211 |
case 'masque.famille' : $this->ajouterLeFiltreMasque('famille', $val); break;
|
209 |
case 'masque.ns' : $this->ajouterLeFiltreMasque('nom_sci', $val); break;
|
212 |
case 'masque.ns' : $this->ajouterLeFiltreMasque('nom_sci', $val); break;
|
210 |
case 'masque.type' : $this->ajouterLeFiltreMasque('type', $val); break;
|
213 |
case 'masque.type' : $this->ajouterLeFiltreMasque('type', $val); break;
|
211 |
case 'masque.txt' : $this->ajouterLeFiltreMasque('texte', $val); break;
|
214 |
case 'masque.txt' : $this->ajouterLeFiltreMasque('texte', $val); break;
|
212 |
case 'masque.page' : $this->ajouterLeFiltreMasque('page',$val); break;
|
215 |
case 'masque.page' : $this->ajouterLeFiltreMasque('page',$val); break;
|
213 |
case 'masque.tome' : $this->ajouterLeFiltreMasque('tome',$val); break;
|
216 |
case 'masque.tome' : $this->ajouterLeFiltreMasque('tome',$val); break;
|
214 |
case 'navigation.depart': $this->limite_requete['depart'] = $val; break;
|
217 |
case 'navigation.depart': $this->limite_requete['depart'] = $val; break;
|
215 |
case 'navigation.limite': $this->limite_requete['limite'] = $val; break;
|
218 |
case 'navigation.limite': $this->limite_requete['limite'] = $val; break;
|
216 |
case 'recherche' : break;
|
219 |
case 'recherche' : break;
|
217 |
case 'txt.format' : break;
|
220 |
case 'txt.format' : break;
|
218 |
default :
|
221 |
default :
|
219 |
$e = "Erreur dans les paramètres de recherche de votre requête : </br> Le parametre $param n\'existe pas.";
|
222 |
$e = "Erreur dans les paramètres de recherche de votre requête : </br> Le parametre $param n\'existe pas.";
|
220 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE,$e);
|
223 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE,$e);
|
221 |
break;
|
224 |
break;
|
222 |
}
|
225 |
}
|
223 |
}
|
226 |
}
|
224 |
}
|
227 |
}
|
225 |
}
|
228 |
}
|
226 |
|
229 |
|
227 |
|
230 |
|
228 |
public function ajouterLeFiltreMasque($masque, $valeur) {
|
231 |
public function ajouterLeFiltreMasque($masque, $valeur) {
|
229 |
if ($this->recherche == 'etendue') {
|
232 |
if ($this->recherche == 'etendue') {
|
230 |
$valeur = '%'.str_replace(' ','%', $valeur).'%';
|
233 |
$valeur = '%'.str_replace(' ','%', $valeur).'%';
|
231 |
}
|
234 |
}
|
232 |
$valeur = $this->getBdd()->proteger($valeur);
|
235 |
$valeur = $this->getBdd()->proteger($valeur);
|
233 |
$this->masque[] = "$masque=$valeur";
|
236 |
$this->masque[] = "$masque=$valeur";
|
234 |
switch ($masque) {
|
237 |
switch ($masque) {
|
235 |
case 'famille' :
|
238 |
case 'famille' :
|
236 |
break;
|
239 |
break;
|
237 |
case 'nom_sci' :
|
240 |
case 'nom_sci' :
|
238 |
$this->requete_condition[] = "t1.value = c.num_nom AND nom_sci LIKE $valeur)";
|
241 |
$this->requete_condition[] = "t1.value = c.num_nom AND nom_sci LIKE $valeur)";
|
239 |
$this->ajouterRechercheFloue('nom_sci', $valeur);
|
242 |
$this->ajouterRechercheFloue('nom_sci', $valeur);
|
240 |
$this->table[] = Config::get("bdd_table").'_v0_1 c';
|
243 |
$this->table[] = Config::get("bdd_table").'_v0_1 c';
|
241 |
break;
|
244 |
break;
|
242 |
case 'type' :
|
245 |
case 'type' :
|
243 |
$type = ($this->getBdd()->proteger($valeur) == '"cle"') ? 'Cle%' : 'Dsc%';
|
246 |
$type = ($this->getBdd()->proteger($valeur) == '"cle"') ? 'Cle%' : 'Dsc%';
|
244 |
$this->requete_condition[] = 't1.resource LIKE '.$this->getBdd()->proteger($type);
|
247 |
$this->requete_condition[] = 't1.resource LIKE '.$this->getBdd()->proteger($type);
|
245 |
break;
|
248 |
break;
|
246 |
case 'texte' :
|
249 |
case 'texte' :
|
247 |
$this->requete_condition[] = "p.body LIKE $valeur";
|
250 |
$this->requete_condition[] = "p.body LIKE $valeur";
|
248 |
$this->ajouterRechercheFloue('p.body', $valeur);
|
251 |
$this->ajouterRechercheFloue('p.body', $valeur);
|
249 |
break;
|
252 |
break;
|
250 |
case 'titre' :
|
253 |
case 'titre' :
|
251 |
$this->requete_condition[] = "t2.value LIKE $valeur";
|
254 |
$this->requete_condition[] = "t2.value LIKE $valeur";
|
252 |
$this->ajouterRechercheFloue('t2.value', $valeur);
|
255 |
$this->ajouterRechercheFloue('t2.value', $valeur);
|
253 |
break;
|
256 |
break;
|
254 |
case 'page' :
|
257 |
case 'page' :
|
255 |
$this->requete_condition[] = "t1.value = c.num_nom AND c.page = $valeur";
|
258 |
$this->requete_condition[] = "t1.value = c.num_nom AND c.page = $valeur";
|
256 |
$this->table[] = Config::get("bdd_table").'_v0_1 c';
|
259 |
$this->table[] = Config::get("bdd_table").'_v0_1 c';
|
257 |
break;
|
260 |
break;
|
258 |
case 'tome' :
|
261 |
case 'tome' :
|
259 |
$this->requete_condition[] = "t1.value = c.num_nom AND c.tome = $valeur";
|
262 |
$this->requete_condition[] = "t1.value = c.num_nom AND c.tome = $valeur";
|
260 |
$this->table[] = Config::get("bdd_table").'_v0_1 c';
|
263 |
$this->table[] = Config::get("bdd_table").'_v0_1 c';
|
261 |
break;
|
264 |
break;
|
262 |
default :
|
265 |
default :
|
263 |
break;
|
266 |
break;
|
264 |
}
|
267 |
}
|
265 |
}
|
268 |
}
|
266 |
|
269 |
|
267 |
|
270 |
|
268 |
//-----------------------------FONCTIONS DASSEMBLAGE DE LA REQUETE-----------------------------------------------------
|
271 |
//-----------------------------FONCTIONS DASSEMBLAGE DE LA REQUETE-----------------------------------------------------
|
269 |
|
272 |
|
270 |
public function assemblerLaRequete() {
|
273 |
public function assemblerLaRequete() {
|
271 |
$requete = ' SELECT '.$this->requete_champ.
|
274 |
$requete = ' SELECT '.$this->requete_champ.
|
272 |
' FROM '.implode(', ', $this->table)
|
275 |
' FROM '.implode(', ', $this->table)
|
273 |
.$this->retourneRequeteCondition()
|
276 |
.$this->retourneRequeteCondition()
|
274 |
.$this->requete_group_by
|
277 |
.$this->requete_group_by
|
275 |
.$this->formerRequeteLimite();
|
278 |
.$this->formerRequeteLimite();
|
276 |
return $requete;
|
279 |
return $requete;
|
277 |
}
|
280 |
}
|
278 |
|
281 |
|
279 |
|
282 |
|
280 |
public function retourneRequeteCondition() {
|
283 |
public function retourneRequeteCondition() {
|
281 |
$condition = '';
|
284 |
$condition = '';
|
282 |
if ($this->requete_condition !== null) {
|
285 |
if ($this->requete_condition !== null) {
|
283 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
286 |
$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
|
284 |
}
|
287 |
}
|
285 |
return $condition;
|
288 |
return $condition;
|
286 |
}
|
289 |
}
|
287 |
|
290 |
|
288 |
public function formerRequeteLimite() {
|
291 |
public function formerRequeteLimite() {
|
289 |
if (in_array($this->format_reponse , array('textes/id', 'textes/id/relations'))) {
|
292 |
if (in_array($this->format_reponse , array('textes/id', 'textes/id/relations'))) {
|
290 |
$this->requete_limite = '';
|
293 |
$this->requete_limite = '';
|
291 |
} elseif (($depart = $this->limite_requete['depart']) > ($this->total_resultat = $this->recupererTotalResultat())) {
|
294 |
} elseif (($depart = $this->limite_requete['depart']) > ($this->total_resultat = $this->recupererTotalResultat())) {
|
292 |
$this->limite_requete['depart'] =
|
295 |
$this->limite_requete['depart'] =
|
293 |
(($this->total_resultat - $this->limite_requete['limite']) < 0) ? 0 : ($this->total_resultat - $this->limite_requete['limite']);
|
296 |
(($this->total_resultat - $this->limite_requete['limite']) < 0) ? 0 : ($this->total_resultat - $this->limite_requete['limite']);
|
294 |
$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
|
297 |
$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
|
295 |
} else {
|
298 |
} else {
|
296 |
$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
|
299 |
$this->requete_limite = ' LIMIT '.$this->limite_requete['depart'].', '.$this->limite_requete['limite'];
|
297 |
}
|
300 |
}
|
298 |
return $this->requete_limite;
|
301 |
return $this->requete_limite;
|
299 |
}
|
302 |
}
|
300 |
|
303 |
|
301 |
|
304 |
|
302 |
/**
|
305 |
/**
|
303 |
* Recupere le nombre total de résultat d'une requete lancée.
|
306 |
* Recupere le nombre total de résultat d'une requete lancée.
|
304 |
* Est utilisée lors de l'affichage du total dans le résultat retourné et pr déterminer les limites et départ
|
307 |
* Est utilisée lors de l'affichage du total dans le résultat retourné et pr déterminer les limites et départ
|
305 |
* @return nombre total de résultat
|
308 |
* @return nombre total de résultat
|
306 |
*/
|
309 |
*/
|
307 |
public function recupererTotalResultat() {
|
310 |
public function recupererTotalResultat() {
|
308 |
$total = null;
|
311 |
$total = null;
|
309 |
$requete = 'SELECT count(*) as nombre FROM '
|
312 |
$requete = 'SELECT count(*) as nombre FROM '
|
310 |
.implode(', ', $this->table).$this->retourneRequeteCondition()
|
313 |
.implode(', ', $this->table).$this->retourneRequeteCondition()
|
311 |
.$this->requete_group_by;
|
314 |
.$this->requete_group_by;
|
312 |
$res = $this->getBdd()->recuperer($requete);
|
315 |
$res = $this->getBdd()->recuperer($requete);
|
313 |
if ($res) {
|
316 |
if ($res) {
|
314 |
$total = $res['nombre'];
|
317 |
$total = $res['nombre'];
|
315 |
} else {
|
318 |
} else {
|
316 |
$e = 'Données introuvables dans la base ou erreur dans la requête SQL';
|
319 |
$e = 'Données introuvables dans la base ou erreur dans la requête SQL';
|
317 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
|
320 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
|
318 |
}
|
321 |
}
|
319 |
return $total;
|
322 |
return $total;
|
320 |
}
|
323 |
}
|
321 |
|
324 |
|
322 |
|
325 |
|
323 |
|
326 |
|
324 |
//-------------------FONCTIONS POUR LE FORMATAGE EN JSON----------------------------------------------------------------
|
327 |
//-------------------FONCTIONS POUR LE FORMATAGE EN JSON----------------------------------------------------------------
|
325 |
|
328 |
|
326 |
public function retournerResultatFormate($resultat) {
|
329 |
public function retournerResultatFormate($resultat) {
|
327 |
$reponse = '';
|
330 |
$reponse = '';
|
328 |
switch ($this->format_reponse) {
|
331 |
switch ($this->format_reponse) {
|
329 |
case 'textes' : $reponse = $this->formaterTextes($resultat); break;
|
332 |
case 'textes' : $reponse = $this->formaterTextes($resultat); break;
|
330 |
case 'textes/relations' : $reponse = $this->formaterTextesRelations($resultat); break;
|
333 |
case 'textes/relations' : $reponse = $this->formaterTextesRelations($resultat); break;
|
331 |
case 'textes/id' : $reponse = $this->formaterTextesId($resultat[0]); break;
|
334 |
case 'textes/id' : $reponse = $this->formaterTextesId($resultat[0]); break;
|
332 |
case 'textes/id/champ' : $reponse = $this->formaterTextesIdChamp($resultat[0]); break;
|
335 |
case 'textes/id/champ' : $reponse = $this->formaterTextesIdChamp($resultat[0]); break;
|
333 |
default : break;
|
336 |
default : break;
|
334 |
}
|
337 |
}
|
335 |
return $reponse;
|
338 |
return $reponse;
|
336 |
}
|
339 |
}
|
337 |
|
340 |
|
338 |
|
341 |
|
339 |
public function formaterTextes($resultat) {
|
342 |
public function formaterTextes($resultat) {
|
340 |
$this->ajouterEnteteResultat($resultat);
|
343 |
$this->ajouterEnteteResultat($resultat);
|
341 |
$reponse['entete'] = $this->table_retour;
|
344 |
$reponse['entete'] = $this->table_retour;
|
342 |
$this->table_retour = array();
|
345 |
$this->table_retour = array();
|
343 |
foreach ($resultat as $description) {
|
346 |
foreach ($resultat as $description) {
|
344 |
$tag = $description['tag'];
|
347 |
$tag = $description['tag'];
|
345 |
$this->afficherDonnees('titre', $description['titre']);
|
348 |
$this->afficherDonnees('titre', $description['titre']);
|
346 |
$type = (preg_match('/^Cle.*$/', $tag)) ? '1' : '2' ;
|
349 |
$type = (preg_match('/^Cle.*$/', $tag)) ? '1' : '2' ;
|
347 |
$this->afficherDonnees('type', $type);
|
350 |
$this->afficherDonnees('type', $type);
|
348 |
$this->table_retour['texte'] = $description['texte'];
|
351 |
$this->table_retour['texte'] = $description['texte'];
|
349 |
$reponse['resultat'][$tag] = $this->table_retour;
|
352 |
$reponse['resultat'][$tag] = $this->table_retour;
|
350 |
$this->table_retour = array();
|
353 |
$this->table_retour = array();
|
351 |
$reponse['resultat'][$tag]['href'] = $this->ajouterHref('textes', $tag);
|
354 |
$reponse['resultat'][$tag]['href'] = $this->ajouterHref('textes', $tag);
|
352 |
}
|
355 |
}
|
353 |
return $reponse;
|
356 |
return $reponse;
|
354 |
}
|
357 |
}
|
355 |
|
358 |
|
356 |
public function formaterTextesRelations($resultat) {
|
359 |
public function formaterTextesRelations($resultat) {
|
357 |
foreach ($resultat as $description) {
|
360 |
foreach ($resultat as $description) {
|
358 |
$tag = $description['tag'];
|
361 |
$tag = $description['tag'];
|
359 |
$type = (preg_match('/^Cle.*$/', $tag)) ? '1' : '2' ;
|
362 |
$type = (preg_match('/^Cle.*$/', $tag)) ? '1' : '2' ;
|
360 |
$this->afficherDonnees('type', $type);
|
363 |
$this->afficherDonnees('type', $type);
|
361 |
$this->table_retour['texte'] = $description['texte'];
|
364 |
$this->table_retour['texte'] = $description['texte'];
|
362 |
$reponse[$tag] = $this->table_retour;
|
365 |
$reponse[$tag] = $this->table_retour;
|
363 |
$this->table_retour = array();
|
366 |
$this->table_retour = array();
|
364 |
$reponse[$tag]['href'] = $this->ajouterHref('textes', $tag);
|
367 |
$reponse[$tag]['href'] = $this->ajouterHref('textes', $tag);
|
365 |
}
|
368 |
}
|
366 |
return $reponse;
|
369 |
return $reponse;
|
367 |
}
|
370 |
}
|
368 |
|
371 |
|
369 |
public function ajouterEnteteResultat($resultat) {
|
372 |
public function ajouterEnteteResultat($resultat) {
|
370 |
if ($this->masque) {
|
373 |
if ($this->masque) {
|
371 |
$this->table_retour['masque'] = implode('&', $this->masque);
|
374 |
$this->table_retour['masque'] = implode('&', $this->masque);
|
372 |
}
|
375 |
}
|
373 |
$this->table_retour['depart'] = $this->limite_requete['depart'];
|
376 |
$this->table_retour['depart'] = $this->limite_requete['depart'];
|
374 |
$this->table_retour['limite'] = $this->limite_requete['limite'];
|
377 |
$this->table_retour['limite'] = $this->limite_requete['limite'];
|
375 |
$this->table_retour['total'] = $this->total_resultat;
|
378 |
$this->table_retour['total'] = $this->total_resultat;
|
376 |
//formuler les urls
|
379 |
//formuler les urls
|
377 |
$url = $this->formulerUrl($this->total_resultat, '/'.$this->service);
|
380 |
$url = $this->formulerUrl($this->total_resultat, '/'.$this->service);
|
378 |
if ($url['precedent'] != '') { $this->table_retour['href.precedent'] = $url['precedent']; }
|
381 |
if ($url['precedent'] != '') { $this->table_retour['href.precedent'] = $url['precedent']; }
|
379 |
if ($url['suivant'] != '') { $this->table_retour['href.suivant'] = $url['suivant']; }
|
382 |
if ($url['suivant'] != '') { $this->table_retour['href.suivant'] = $url['suivant']; }
|
380 |
}
|
383 |
}
|
381 |
|
384 |
|
382 |
|
385 |
|
383 |
public function formaterTextesId($reponse) {
|
386 |
public function formaterTextesId($reponse) {
|
384 |
|
387 |
|
385 |
$this->afficherDonnees('titre', $reponse['titre']);
|
388 |
$this->afficherDonnees('titre', $reponse['titre']);
|
386 |
$type = (preg_match('/^Cle.*$/', $reponse['tag'])) ? '2' : '1' ;
|
389 |
$type = (preg_match('/^Cle.*$/', $reponse['tag'])) ? '2' : '1' ;
|
387 |
$this->afficherDonnees('type', $type);
|
390 |
$this->afficherDonnees('type', $type);
|
388 |
$this->table_retour['texte'] = $reponse['texte'];
|
391 |
$this->table_retour['texte'] = $reponse['texte'];
|
389 |
//$this->afficherDonnees('id', $reponse['num_nom']);
|
392 |
//$this->afficherDonnees('id', $reponse['num_nom']);
|
390 |
|
393 |
|
391 |
return $this->table_retour;
|
394 |
return $this->table_retour;
|
392 |
}
|
395 |
}
|
393 |
|
396 |
|
394 |
|
397 |
|
395 |
public function formaterTextesIdChamp($resultat) {
|
398 |
public function formaterTextesIdChamp($resultat) {
|
396 |
//on recupère tous les resultats possibles
|
399 |
//on recupère tous les resultats possibles
|
397 |
$reponse_id = $this->formaterTextesId($resultat);
|
400 |
$reponse_id = $this->formaterTextesId($resultat);
|
398 |
$this->table_retour = array();
|
401 |
$this->table_retour = array();
|
399 |
//on recupère les résultats demandés à partir du tableau de résultat complet
|
402 |
//on recupère les résultats demandés à partir du tableau de résultat complet
|
400 |
$this->table_retour['id'] = $resultat['tag'];
|
403 |
$this->table_retour['id'] = $resultat['tag'];
|
401 |
$champs = explode(' ', $this->table_ressources[1]);
|
404 |
$champs = explode(' ', $this->table_ressources[1]);
|
402 |
foreach ($champs as $champ) {
|
405 |
foreach ($champs as $champ) {
|
403 |
if ($this->verifierValiditeChamp($champ, $reponse_id)) {
|
406 |
if ($this->verifierValiditeChamp($champ, $reponse_id)) {
|
404 |
if (preg_match('/^[^.]+\.\*$/', $champ)) {
|
407 |
if (preg_match('/^[^.]+\.\*$/', $champ)) {
|
405 |
$this->afficherPointEtoile($champ, $reponse_id);
|
408 |
$this->afficherPointEtoile($champ, $reponse_id);
|
406 |
} else {
|
409 |
} else {
|
407 |
$this->table_retour[$champ] = $reponse_id[$champ];
|
410 |
$this->table_retour[$champ] = $reponse_id[$champ];
|
408 |
}
|
411 |
}
|
409 |
}
|
412 |
}
|
410 |
}
|
413 |
}
|
411 |
return $this->table_retour;
|
414 |
return $this->table_retour;
|
412 |
}
|
415 |
}
|
413 |
|
416 |
|
414 |
|
417 |
|
415 |
public function afficherPointEtoile($champ, $reponse_id) {
|
418 |
public function afficherPointEtoile($champ, $reponse_id) {
|
416 |
preg_match('/^([^.]+\.)\*$/', $champ, $match);
|
419 |
preg_match('/^([^.]+\.)\*$/', $champ, $match);
|
417 |
foreach ($reponse_id as $chp => $valeur) {
|
420 |
foreach ($reponse_id as $chp => $valeur) {
|
418 |
if (strrpos($chp, $match[1]) !== false) {
|
421 |
if (strrpos($chp, $match[1]) !== false) {
|
419 |
$this->table_retour[$chp] = $valeur;
|
422 |
$this->table_retour[$chp] = $valeur;
|
420 |
}
|
423 |
}
|
421 |
}
|
424 |
}
|
422 |
}
|
425 |
}
|
423 |
|
426 |
|
424 |
|
427 |
|
425 |
public function verifierValiditeChamp($champ, $reponse_id) {
|
428 |
public function verifierValiditeChamp($champ, $reponse_id) {
|
426 |
$validite = false;
|
429 |
$validite = false;
|
427 |
preg_match('/^([^.]+)(:?\.([^.]+))?$/', $champ, $match);
|
430 |
preg_match('/^([^.]+)(:?\.([^.]+))?$/', $champ, $match);
|
428 |
if (array_key_exists($match[1], $reponse_id)) {
|
431 |
if (array_key_exists($match[1], $reponse_id)) {
|
429 |
$validite = true;
|
432 |
$validite = true;
|
430 |
if (isset($match[2]) && !empty($match[2])) {
|
433 |
if (isset($match[2]) && !empty($match[2])) {
|
431 |
if ($match[1] == 'type') {
|
434 |
if ($match[1] == 'type') {
|
432 |
$suffixes = array('.code', '.href', '.*');
|
435 |
$suffixes = array('.code', '.href', '.*');
|
433 |
$validite = (in_array($match[2], $suffixes)) ? true : false;
|
436 |
$validite = (in_array($match[2], $suffixes)) ? true : false;
|
434 |
} else {
|
437 |
} else {
|
435 |
$validite = false;
|
438 |
$validite = false;
|
436 |
}
|
439 |
}
|
437 |
}
|
440 |
}
|
438 |
}
|
441 |
}
|
439 |
if (!$validite) {
|
442 |
if (!$validite) {
|
440 |
$champs = implode('</li><li>', array_keys($reponse_id));
|
443 |
$champs = implode('</li><li>', array_keys($reponse_id));
|
441 |
$e = 'Erreur dans votre requête : </br> Le champ "'.$champ.'" n\'existe pas. Les champs disponibles
|
444 |
$e = 'Erreur dans votre requête : </br> Le champ "'.$champ.'" n\'existe pas. Les champs disponibles
|
442 |
sont : <li>'.$champs.'</li>';
|
445 |
sont : <li>'.$champs.'</li>';
|
443 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
446 |
$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
|
444 |
}
|
447 |
}
|
445 |
return $validite;
|
448 |
return $validite;
|
446 |
}
|
449 |
}
|
447 |
|
450 |
|
448 |
|
451 |
|
449 |
//------------------------------------------------Fonction d'affichage ------------------------------------------------
|
452 |
//------------------------------------------------Fonction d'affichage ------------------------------------------------
|
450 |
|
453 |
|
451 |
public function afficherDonnees($champ, $valeur) {
|
454 |
public function afficherDonnees($champ, $valeur) {
|
452 |
if ($this->retour_format == 'min') {
|
455 |
if ($this->retour_format == 'min') {
|
453 |
$champ = ($champ == 'type') ? $champ.'.code' : $champ;
|
456 |
$champ = ($champ == 'type') ? $champ.'.code' : $champ;
|
454 |
$this->table_retour[$champ] = $valeur;
|
457 |
$this->table_retour[$champ] = $valeur;
|
455 |
} else {
|
458 |
} else {
|
456 |
$this->afficherDonneesMax($champ, $valeur);
|
459 |
$this->afficherDonneesMax($champ, $valeur);
|
457 |
}
|
460 |
}
|
458 |
}
|
461 |
}
|
459 |
|
462 |
|
460 |
|
463 |
|
461 |
public function afficherDonneesMax($champ, $valeur) {
|
464 |
public function afficherDonneesMax($champ, $valeur) {
|
462 |
if ($champ == 'id') {
|
465 |
if ($champ == 'id') {
|
463 |
$this->table_retour[$champ] = "coste.".$valeur;
|
466 |
$this->table_retour[$champ] = "coste.".$valeur;
|
464 |
$this->table_retour['nom_sci'] = $this->recupererNomSci($valeur);
|
467 |
$this->table_retour['nom_sci'] = $this->recupererNomSci($valeur);
|
465 |
$this->table_retour['id.href'] = $this->ajouterHref('noms', $valeur);
|
468 |
$this->table_retour['id.href'] = $this->ajouterHref('noms', $valeur);
|
466 |
} elseif (in_array($champ, array('type'))) {
|
469 |
} elseif (in_array($champ, array('type'))) {
|
467 |
$this->table_retour[$champ.'.code'] = $valeur;
|
470 |
$this->table_retour[$champ.'.code'] = $valeur;
|
468 |
$this->table_retour[$champ] = $this->recupererSignificationCode($valeur);
|
471 |
$this->table_retour[$champ] = $this->recupererSignificationCode($valeur);
|
469 |
$this->table_retour[$champ.'.href'] = $this->ajouterHrefAutreProjet('ontologies', 'texteType:', $valeur, 'eflore');
|
472 |
$this->table_retour[$champ.'.href'] = $this->ajouterHrefAutreProjet('ontologies', 'texteType:', $valeur, 'eflore');
|
470 |
} else {
|
473 |
} else {
|
471 |
$this->table_retour[$champ] = $valeur;
|
474 |
$this->table_retour[$champ] = $valeur;
|
472 |
}
|
475 |
}
|
473 |
}
|
476 |
}
|
474 |
|
477 |
|
475 |
|
478 |
|
476 |
public function recupererSignificationCode($code) {
|
479 |
public function recupererSignificationCode($code) {
|
477 |
$url = $this->ajouterHrefAutreProjet('ontologies', 'texteType:', $code.'/nom', 'eflore');
|
480 |
$url = $this->ajouterHrefAutreProjet('ontologies', 'texteType:', $code.'/nom', 'eflore');
|
478 |
$res = $this->consulterHref($url);
|
481 |
$res = $this->consulterHref($url);
|
479 |
return $res->nom;
|
482 |
return $res->nom;
|
480 |
}
|
483 |
}
|
481 |
|
484 |
|
482 |
|
485 |
|
483 |
public function recupererNomSci($id) {
|
486 |
public function recupererNomSci($id) {
|
484 |
$req = 'SELECT nom_sci FROM coste_v0_1 WHERE num_nom = '.$id;
|
487 |
$req = 'SELECT nom_sci FROM coste_v0_1 WHERE num_nom = '.$id;
|
485 |
if ($this->html == 'htm') {
|
488 |
if ($this->html == 'htm') {
|
486 |
$req = str_replace('nom_sci', 'nom_sci_html as nom_sci', $req);
|
489 |
$req = str_replace('nom_sci', 'nom_sci_html as nom_sci', $req);
|
487 |
}
|
490 |
}
|
488 |
$res = $this->getBdd()->recuperer($req);
|
491 |
$res = $this->getBdd()->recuperer($req);
|
489 |
return $res['nom_sci'];
|
492 |
return $res['nom_sci'];
|
490 |
}
|
493 |
}
|
491 |
|
494 |
|
492 |
}
|
495 |
}
|
493 |
|
496 |
|
494 |
?>
|
497 |
?>
|