amélioration ergo

This commit is contained in:
Christophe 2022-03-30 17:45:20 +02:00
parent 62f02552f8
commit 5f14275fb3
4 changed files with 28 additions and 14 deletions

View file

@ -1,10 +1,12 @@
#CACHE{0} #CACHE{0}
[(#AUTORISER{voir,#ENV{objet}}|sinon_interdire_acces)]
<div class="conf-inner"> <div class="conf-inner">
<h2 class="text-center">Configuration des #ENV{objet}</h2> <h2 class="text-center">Configuration des [ (#ENV{objet}|gamuform_nom_objet)]</h2>
<div class="tableau"> <div class="tableau">
[(#SET{lien,<a class="modalbox btn--osdve" href="[(#URL_PAGE{editer_gamuform}|parametre_url{objet,#ENV{objet}}|parametre_url{redirect,#SELF})]"><i class="osdve-plus-circle"></i>&nbsp;Nouveau</a>})] [(#AUTORISER{creer,#ENV{objet}}|oui)
[(#SET{lien,<a class="modalbox btn--osdve" href="[(#URL_PAGE{editer_gamuform}|parametre_url{objet,#ENV{objet}}|parametre_url{redirect,#SELF})]"><i class="osdve-plus-circle"></i>&nbsp;Nouveau</a>})]
]
#SET{url,spip.php?page=json_gamuform.json&objet=} #SET{url,spip.php?page=json_gamuform.json&objet=}
#SET{url,#GET{url}|concat{#ENV{objet}}} #SET{url,#GET{url}|concat{#ENV{objet}}}
<INCLURE{fond=inclure/gamutable, <INCLURE{fond=inclure/gamutable,

View file

@ -17,13 +17,21 @@ function gamuform_objet_autoriser(string $objet):bool {
if ( if (
!empty($GLOBALS['gamuform_objets']) !empty($GLOBALS['gamuform_objets'])
and !empty($objet) and !empty($objet)
and in_array($objet, $GLOBALS['gamuform_objets']) and in_array($objet, array_keys($GLOBALS['gamuform_objets']))
) { ) {
return true; return true;
} }
return false; return false;
} }
function gamuform_nom_objet($objet):string {
$nom = '';
if (gamuform_objet_autoriser($objet)) {
$nom = $GLOBALS['gamuform_objets'][$objet];
}
return $nom;
}
function gamuform_recup_champ($objet) { function gamuform_recup_champ($objet) {
$c = []; $c = [];
@ -31,7 +39,7 @@ function gamuform_recup_champ($objet) {
$T = $GLOBALS['gamuform_'.$objet]; $T = $GLOBALS['gamuform_'.$objet];
if (!empty($T)) { if (!empty($T)) {
foreach ($T as $s) { foreach ($T as $s) {
$c[] = $s['options']['nom']; $c[$s['options']['nom']] = $s['options']['libelle'];
} }
} }
} }
@ -43,7 +51,7 @@ function gamuform_recup_valeurs($objet, $id_objet = 0):array {
if (gamuform_objet_autoriser($objet)) { if (gamuform_objet_autoriser($objet)) {
$table = table_objet_sql($objet); $table = table_objet_sql($objet);
$id = id_table_objet($objet); $id = id_table_objet($objet);
$s = gamuform_recup_champ($objet); $s = array_keys(gamuform_recup_champ($objet));
$s[] = $id; $s[] = $id;
if (intval($id_objet)) { if (intval($id_objet)) {
@ -63,5 +71,6 @@ function gamuform_recup_valeurs($objet, $id_objet = 0):array {
} }
} }
return $r; return $r;
} }

View file

@ -14,15 +14,16 @@ if (!defined('_ECRIRE_INC_VERSION')) {
} }
$GLOBALS['gamuform_objets'] = [ 'auteur']; $GLOBALS['gamuform_objets'] = [ 'auteur' => 'Auteurs'];
$GLOBALS['gamuform_auteur'] = [ $GLOBALS['gamuform_auteur'] = [
[ [
'saisie' => 'input', 'saisie' => 'input',
'options' => array( 'options' => array(
'nom' => 'nom', 'nom' => 'nom',
'label' => 'Votre Nom', 'libelle' => 'Nom',
'label' => 'Votre Nom',
'obligatoire' => 'oui', 'obligatoire' => 'oui',
//'fonction' => 'ma_super_fonction' //'fonction' => 'ma_super_fonction'
//'modifier' => 'ma_super_fonction_pour_modifier' //'modifier' => 'ma_super_fonction_pour_modifier'
@ -32,6 +33,7 @@ $GLOBALS['gamuform_auteur'] = [
'saisie' => 'input', 'saisie' => 'input',
'options' => array( 'options' => array(
'nom' => 'bio', 'nom' => 'bio',
'libelle' => 'Biographie',
'label' => 'Votre BIO', 'label' => 'Votre BIO',
'obligatoire' => 'oui', 'obligatoire' => 'oui',
//'fonction' => 'ma_super_fonction' //'fonction' => 'ma_super_fonction'
@ -40,8 +42,9 @@ $GLOBALS['gamuform_auteur'] = [
[ [
'saisie' => 'input', 'saisie' => 'input',
'options' => array( 'options' => array(
'nom' => 'nom_site', 'nom' => 'nom_site',
'label' => 'Votre site perso', 'libelle' => 'Site Internet',
'label' => 'Votre site perso',
) )
] ]
]; ];

View file

@ -6,7 +6,7 @@
"id": "id", "id": "id",
"edit": "", "edit": "",
<BOUCLE_header(DATA){source table,#GET{header}}{','}> <BOUCLE_header(DATA){source table,#GET{header}}{','}>
"#VALEUR" : "#VALEUR" [(#CLE|json_encode)] : [(#VALEUR|json_encode)]
</BOUCLE_header> </BOUCLE_header>
}, },
"crayons":{ "crayons":{
@ -34,14 +34,14 @@
"id": #GET{ligne/id}, "id": #GET{ligne/id},
"edit": [(#GET{edit}|json_encode)], "edit": [(#GET{edit}|json_encode)],
<BOUCLE_headerB(DATA){source table,#GET{header}}{','}> <BOUCLE_headerB(DATA){source table,#GET{header}}{','}>
"#VALEUR" : [(#GET{ligne/#VALEUR}|json_encode)] [(#CLE|json_encode)] : [(#GET{ligne/#CLE}|json_encode)]
</BOUCLE_headerB> </BOUCLE_headerB>
}, },
"search": { "search": {
"id": #GET{ligne/id}, "id": #GET{ligne/id},
"edit": "", "edit": "",
<BOUCLE_headerC(DATA){source table,#GET{header}}{','}> <BOUCLE_headerC(DATA){source table,#GET{header}}{','}>
"#VALEUR" : [(#GET{ligne/#VALEUR}|textebrut|json_encode)] [(#CLE|json_encode)] : [(#GET{ligne/#CLE}|textebrut|json_encode)]
</BOUCLE_headerC> </BOUCLE_headerC>
} }
} }