From d17390090385b733a1be210a940cf9f227f90ae6 Mon Sep 17 00:00:00 2001 From: tofulm Date: Wed, 30 Mar 2022 16:15:45 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20du=20gamutable=20g=C3=A9n=C3=A9rique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/voir_gamutable.html | 17 ++++++++++++ gamuform_fonctions.php | 28 ++++++++++++++++++++ inclure/editer_gamuform.html | 2 +- json_gamuform.json.html | 50 ++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 content/voir_gamutable.html create mode 100644 json_gamuform.json.html diff --git a/content/voir_gamutable.html b/content/voir_gamutable.html new file mode 100644 index 0000000..cfc1d48 --- /dev/null +++ b/content/voir_gamutable.html @@ -0,0 +1,17 @@ +#CACHE{0} + +
+

Configuration de #ENV{objet}

+
+ [(#SET{lien, Nouveau})] + + #SET{url,spip.php?page=json_gamuform.json&objet=} + #SET{url,#GET{url}|concat{#ENV{objet}}} + +
+ +
diff --git a/gamuform_fonctions.php b/gamuform_fonctions.php index 540e92d..d19406b 100644 --- a/gamuform_fonctions.php +++ b/gamuform_fonctions.php @@ -37,3 +37,31 @@ function gamuform_recup_champ($objet) { } return $c; } + +function gamuform_recup_valeurs($objet, $id_objet = 0):array { + $r = []; + if (gamuform_objet_autoriser($objet)) { + $table = table_objet_sql($objet); + $id = id_table_objet($objet); + $s = gamuform_recup_champ($objet); + + $s[] = $id; + if (intval($id_objet)) { + $valeurs = sql_fetsel($s, $table, "$id=".intval($id_objet)); + $valeurs['id'] = $valeurs[$id]; + if (!empty($valeurs)) { + $r[0] = $valeurs; + } + } else { + $T = sql_allfetsel($s, $table, 1); + if (!empty($T)) { + foreach ($T as $t) { + $t['id'] = $t[$id]; + $r[] = $t; + } + } + } + } + + return $r; +} diff --git a/inclure/editer_gamuform.html b/inclure/editer_gamuform.html index 774d3b3..f1ffee0 100644 --- a/inclure/editer_gamuform.html +++ b/inclure/editer_gamuform.html @@ -3,6 +3,6 @@
- [(#FORMULAIRE_EDITER_GAMUFORM{#ENV{id}, #ENV{objet}, #ENV{redirect}})] + [(#FORMULAIRE_EDITER_GAMUFORM{#ENV{id_objet}, #ENV{objet}, #ENV{redirect}})]
diff --git a/json_gamuform.json.html b/json_gamuform.json.html new file mode 100644 index 0000000..4f9581f --- /dev/null +++ b/json_gamuform.json.html @@ -0,0 +1,50 @@ +#HTTP_HEADER{Content-Type: application/json; charset=#CHARSET} + +#SET{header,#ENV{objet}|gamuform_recup_champ} +[{ +"header":{ +"id": "id", +"edit": "", + +"#VALEUR" : "#VALEUR" + +}, +"crayons":{ +}, +"filtreCol" : { +}, +"classes" : { + "id": "w80p", + "edit": "w80p" +} +} + +, + + #SET{ligne,#VALEUR} + [(#SET{edit, + + })] +{ +"html": { + "id": #GET{ligne/id}, + "edit": [(#GET{edit}|json_encode)], + + "#VALEUR" : [(#GET{ligne/#VALEUR}|json_encode)] + +}, +"search": { + "id": #GET{ligne/id}, + "edit": "", + + "#VALEUR" : [(#GET{ligne/#VALEUR}|textebrut|json_encode)] + +} +} + +] +