gamucontact gère la langue pour l'affichage du form de l'internaute et les messages de contact pour les mails destinataires. (c'est un POC pour la gestion des langues dans GamuMail :-) )
This commit is contained in:
parent
e9cbe8f027
commit
c5932fc690
5 changed files with 109 additions and 22 deletions
|
@ -84,6 +84,9 @@ function formulaires_gamucontact_traiter_dist($id_auteur = 0, $redirect = '') {
|
|||
}
|
||||
}
|
||||
$set['date_heure'] = date("Y-m-d H:i:s");
|
||||
$set['statut'] = 'publie';
|
||||
$set['titre'] = _T('gamucontact:formulaire_contact');
|
||||
|
||||
if (count($set) > 0) {
|
||||
$set = pipeline(
|
||||
'pre_edition',
|
||||
|
@ -134,21 +137,41 @@ function formulaires_gamucontact_traiter_dist($id_auteur = 0, $redirect = '') {
|
|||
|
||||
$test_mail = true;
|
||||
if (count($destinataires)) {
|
||||
$html = recuperer_fond('modeles/gamucontact_message', ['id_message' => $id_message]);
|
||||
$GLOBALS['forcer_lang'] = false;
|
||||
$langue_defaut = lire_config('langue_site');
|
||||
include_spip('classes/facteur');
|
||||
$texte = Facteur::html2text($html);
|
||||
|
||||
// récupérer les infos de langue des destinataires
|
||||
$dest_langues = sql_allfetsel('id_auteur,lang,email', 'spip_auteurs', sql_in('email', $destinataires), 'email');
|
||||
// array avec les langues des destinataires
|
||||
if (is_array($dest_langues) and count($dest_langues)) {
|
||||
$langues = array_filter(array_unique(array_column($dest_langues, 'lang')));
|
||||
}
|
||||
|
||||
// trier les destinataires par langue et envoyer un mail par langue
|
||||
foreach ($langues as $langue) {
|
||||
$Tdest_langue = [];
|
||||
foreach ($dest_langues as $dest) {
|
||||
if ($dest['lang'] == '') {
|
||||
$dest['lang'] = $langue_defaut;
|
||||
}
|
||||
if ($dest['lang'] == $langue)
|
||||
$Tdest_langue[] = $dest['email'];
|
||||
}
|
||||
// envoi du mail dans cette langue
|
||||
$html = recuperer_fond('modeles/gamucontact_message', ['id_message' => $id_message, 'lang' => $langue]);
|
||||
$texte = Facteur::html2text($html);
|
||||
$corps = array(
|
||||
'html' => $html,
|
||||
'texte' => $texte,
|
||||
);
|
||||
|
||||
$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
|
||||
$test_mail = $envoyer_mail($destinataires, _request('objet'), $corps, '', 'X-Originating-IP: '.$GLOBALS['ip']);
|
||||
$test_mail = $envoyer_mail($Tdest_langue, _request('objet'), $corps, '', 'X-Originating-IP: '.$GLOBALS['ip']);
|
||||
}
|
||||
}
|
||||
|
||||
if (intval($id_message) and $test_mail) {
|
||||
$retour['message_ok'] = _T('gamucontact:formulaire_bien_envoyé');
|
||||
$retour['message_ok'] = _T('gamucontact:formulaire_bien_envoye');
|
||||
}
|
||||
|
||||
if ($redirect) {
|
||||
|
|
|
@ -21,7 +21,7 @@ $GLOBALS['gamucontact'] = [
|
|||
'saisie' => 'input',
|
||||
'options' => array(
|
||||
'nom' => 'nom',
|
||||
'label' => 'Votre Nom',
|
||||
'label' => '<:gamucontact:votre_nom:>',
|
||||
'obligatoire' => 'oui',
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ $GLOBALS['gamucontact'] = [
|
|||
'saisie' => 'input',
|
||||
'options' => array(
|
||||
'nom' => 'email_contact',
|
||||
'label' => 'Votre Email',
|
||||
'label' => '<:gamucontact:votre_email:>',
|
||||
'obligatoire' => 'oui',
|
||||
)
|
||||
],
|
||||
|
@ -38,7 +38,7 @@ $GLOBALS['gamucontact'] = [
|
|||
'saisie' => 'input',
|
||||
'options' => array(
|
||||
'nom' => 'objet',
|
||||
'label' => 'Objet',
|
||||
'label' => '<:gamucontact:objet:>',
|
||||
'obligatoire' => 'oui',
|
||||
'class' => 'w100'
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
|
@ -48,7 +48,7 @@ $GLOBALS['gamucontact'] = [
|
|||
'saisie' => 'textarea',
|
||||
'options' => array(
|
||||
'nom' => 'texte',
|
||||
'label' => 'Message',
|
||||
'label' => '<:gamucontact:message:>',
|
||||
'obligatoire' => 'oui',
|
||||
'class' => 'w100',
|
||||
'rows' => 4
|
||||
|
|
42
lang/gamucontact_en.php
Normal file
42
lang/gamucontact_en.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
// G
|
||||
'gamucontact_titre' => 'GamuContact',
|
||||
|
||||
// C
|
||||
'cfg_exemple' => 'Example',
|
||||
'cfg_exemple_explication' => 'Explication de cet exemple',
|
||||
'cfg_titre_parametrages' => 'Parameters',
|
||||
|
||||
// EE
|
||||
'envoyer' => "Send",
|
||||
'email' => 'Email',
|
||||
|
||||
// F
|
||||
'formulaire_bien_envoye' => 'Your message had been send.',
|
||||
'formulaire_contact' => 'Contact form',
|
||||
|
||||
// M
|
||||
'message' => 'Message',
|
||||
|
||||
// N
|
||||
'nom' => 'Name',
|
||||
|
||||
// O
|
||||
'objet' => 'Object',
|
||||
|
||||
// V
|
||||
'votre_nom' => 'Your name',
|
||||
'votre_email' => 'Your email',
|
||||
|
||||
// T
|
||||
'titre_page_configurer_gamucontact' => 'GamuContact',
|
||||
'telephone' => 'Phone number',
|
||||
);
|
|
@ -17,7 +17,26 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
|
|||
|
||||
// EE
|
||||
'envoyer' => "Envoyer",
|
||||
'email' => 'Email',
|
||||
|
||||
// F
|
||||
'formulaire_bien_envoye' => 'Votre message à bien été envoyé.',
|
||||
'formulaire_contact' => 'Formulaire de contact',
|
||||
|
||||
// M
|
||||
'message' => 'Message',
|
||||
|
||||
// N
|
||||
'nom' => 'Nom',
|
||||
|
||||
// O
|
||||
'objet' => 'Objet',
|
||||
|
||||
// V
|
||||
'votre_nom' => 'Votre nom',
|
||||
'votre_email' => 'Votre email',
|
||||
|
||||
// T
|
||||
'titre_page_configurer_gamucontact' => 'GamuContact',
|
||||
'telephone' => 'Téléphone',
|
||||
);
|
||||
|
|
|
@ -10,14 +10,17 @@
|
|||
[<img src="(#LOGO_SITE_SPIP|image_reduire{200}|extraire_attribut{src}|url_absolue)" >]
|
||||
<br>
|
||||
<br>
|
||||
<h1>Formulaire de contact</h1>
|
||||
<BOUCLE_message(MESSAGES){id_message}{tout}>
|
||||
lang: #ENV{lang}<br>
|
||||
|
||||
<h1><:gamucontact:formulaire_contact:></h1>
|
||||
<BOUCLE_message(MESSAGES){id_message}{statut?}{tout}>
|
||||
<div class="message">
|
||||
[<strong>Nom : </strong> (#NOM)<br>]
|
||||
[<strong>Email : </strong> (#EMAIL_CONTACT)<br>]
|
||||
[<strong>Téléphone : </strong> (#TELEPHONE)]
|
||||
[<hr><strong>objet : </strong>(#OBJET)<br>]
|
||||
[<strong>message : </strong>(#TEXTE)<br>]
|
||||
[<strong><:gamucontact:nom:> : </strong> (#NOM)<br>]
|
||||
[<strong><:gamucontact:email:> : </strong> (#EMAIL_CONTACT)<br>]
|
||||
[<strong><:gamucontact:telephone:> : </strong> (#TELEPHONE)]
|
||||
<hr>
|
||||
[<strong><:gamucontact:objet:> : </strong>(#OBJET)<br><br>]
|
||||
[<strong><:gamucontact:message:> : </strong>(#TEXTE)<br>]
|
||||
</div>
|
||||
</BOUCLE_message>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue