From 5999ca57f201b78c513cb8e7f147ecaaea78510d Mon Sep 17 00:00:00 2001 From: tofulm Date: Thu, 22 Sep 2022 17:20:50 +0200 Subject: [PATCH] on passe via un fonction dist et non un global pour la description des saisies --- formulaires/gamucontact.php | 11 +++++--- gamucontact_options.php | 44 -------------------------------- inc/gamucontact.php | 50 +++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 inc/gamucontact.php diff --git a/formulaires/gamucontact.php b/formulaires/gamucontact.php index 89dc36b..4901680 100644 --- a/formulaires/gamucontact.php +++ b/formulaires/gamucontact.php @@ -4,13 +4,16 @@ if (!defined('_ECRIRE_INC_VERSION')) { } function formulaires_gamucontact_saisies_dist($id_auteur = 0, $redirect = '') { - $saisies = $GLOBALS['gamucontact']; + $f = charger_fonction('gamucontact', 'inc'); + $saisies = $f(); + return $saisies; } function formulaires_gamucontact_charger_dist($id_auteur = 0, $redirect = '') { $valeurs = []; $valeurs['_nospam_encrypt'] = true; + return $valeurs; } @@ -61,7 +64,8 @@ function formulaires_gamucontact_verifier_dist($id_auteur = 0, $redirect = '') { return $erreurs; } - $saisies = $GLOBALS['gamucontact']; + $f = charger_fonction('gamucontact', 'inc'); + $saisies = $f(); //champs obligatoire foreach ($saisies as $s) { if ($s['options']['obligatoire'] === 'oui') { @@ -76,9 +80,10 @@ function formulaires_gamucontact_verifier_dist($id_auteur = 0, $redirect = '') { function formulaires_gamucontact_traiter_dist($id_auteur = 0, $redirect = '') { include_spip('classes/facteur'); + $f = charger_fonction('gamucontact', 'inc'); + $saisies = $f(); $retour = []; - $saisies = $GLOBALS['gamucontact']; $set = []; if (!empty($saisies)) { foreach ($saisies as $saisie) { diff --git a/gamucontact_options.php b/gamucontact_options.php index 09b00c8..b75f211 100644 --- a/gamucontact_options.php +++ b/gamucontact_options.php @@ -15,47 +15,3 @@ if (!defined('_ECRIRE_INC_VERSION')) { $GLOBALS['formulaires_no_spam'][] = 'gamucontact'; - -$GLOBALS['gamucontact'] = [ - [ - 'saisie' => 'input', - 'options' => array( - 'nom' => 'nom', - 'label' => '<:gamucontact:votre_nom:>', - 'obligatoire' => 'oui', - 'class' => 'w100', - //'fonction' => 'ma_super_fonction' - ) - ], - [ - 'saisie' => 'input', - 'options' => array( - 'nom' => 'email_contact', - 'label' => '<:gamucontact:votre_email:>', - 'class' => 'w100', - 'obligatoire' => 'oui', - ) - ], - [ - 'saisie' => 'input', - 'options' => array( - 'nom' => 'objet', - 'label' => '<:gamucontact:objet:>', - 'obligatoire' => 'oui', - 'class' => 'w100' - //'fonction' => 'ma_super_fonction' - ) - ], - [ - 'saisie' => 'textarea', - 'options' => array( - 'nom' => 'texte', - 'label' => '<:gamucontact:message:>', - 'obligatoire' => 'oui', - 'class' => 'w100', - 'rows' => 4 - //'fonction' => 'ma_super_fonction' - ) - ], -]; - diff --git a/inc/gamucontact.php b/inc/gamucontact.php new file mode 100644 index 0000000..352d30f --- /dev/null +++ b/inc/gamucontact.php @@ -0,0 +1,50 @@ + 'input', + 'options' => array( + 'nom' => 'nom', + 'label' => '<:gamucontact:votre_nom:>', + 'obligatoire' => 'oui', + 'class' => 'w100', + //'fonction' => 'ma_super_fonction' + ) + ], + [ + 'saisie' => 'input', + 'options' => array( + 'nom' => 'email_contact', + 'label' => '<:gamucontact:votre_email:>', + 'class' => 'w100', + 'obligatoire' => 'oui', + ) + ], + [ + 'saisie' => 'input', + 'options' => array( + 'nom' => 'objet', + 'label' => '<:gamucontact:objet:>', + 'obligatoire' => 'oui', + 'class' => 'w100' + //'fonction' => 'ma_super_fonction' + ) + ], + [ + 'saisie' => 'textarea', + 'options' => array( + 'nom' => 'texte', + 'label' => '<:gamucontact:message:>', + 'obligatoire' => 'oui', + 'class' => 'w100', + 'rows' => 4 + //'fonction' => 'ma_super_fonction' + ) + ], + ]; +}