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['date_heure'] = date("Y-m-d H:i:s");
|
||||||
|
$set['statut'] = 'publie';
|
||||||
|
$set['titre'] = _T('gamucontact:formulaire_contact');
|
||||||
|
|
||||||
if (count($set) > 0) {
|
if (count($set) > 0) {
|
||||||
$set = pipeline(
|
$set = pipeline(
|
||||||
'pre_edition',
|
'pre_edition',
|
||||||
|
@ -134,21 +137,41 @@ function formulaires_gamucontact_traiter_dist($id_auteur = 0, $redirect = '') {
|
||||||
|
|
||||||
$test_mail = true;
|
$test_mail = true;
|
||||||
if (count($destinataires)) {
|
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');
|
include_spip('classes/facteur');
|
||||||
$texte = Facteur::html2text($html);
|
|
||||||
|
|
||||||
$corps = array(
|
// récupérer les infos de langue des destinataires
|
||||||
'html' => $html,
|
$dest_langues = sql_allfetsel('id_auteur,lang,email', 'spip_auteurs', sql_in('email', $destinataires), 'email');
|
||||||
'texte' => $texte,
|
// 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')));
|
||||||
|
}
|
||||||
|
|
||||||
$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
|
// trier les destinataires par langue et envoyer un mail par langue
|
||||||
$test_mail = $envoyer_mail($destinataires, _request('objet'), $corps, '', 'X-Originating-IP: '.$GLOBALS['ip']);
|
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($Tdest_langue, _request('objet'), $corps, '', 'X-Originating-IP: '.$GLOBALS['ip']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval($id_message) and $test_mail) {
|
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) {
|
if ($redirect) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ $GLOBALS['gamucontact'] = [
|
||||||
'saisie' => 'input',
|
'saisie' => 'input',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'nom' => 'nom',
|
'nom' => 'nom',
|
||||||
'label' => 'Votre Nom',
|
'label' => '<:gamucontact:votre_nom:>',
|
||||||
'obligatoire' => 'oui',
|
'obligatoire' => 'oui',
|
||||||
//'fonction' => 'ma_super_fonction'
|
//'fonction' => 'ma_super_fonction'
|
||||||
)
|
)
|
||||||
|
@ -30,7 +30,7 @@ $GLOBALS['gamucontact'] = [
|
||||||
'saisie' => 'input',
|
'saisie' => 'input',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'nom' => 'email_contact',
|
'nom' => 'email_contact',
|
||||||
'label' => 'Votre Email',
|
'label' => '<:gamucontact:votre_email:>',
|
||||||
'obligatoire' => 'oui',
|
'obligatoire' => 'oui',
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -38,7 +38,7 @@ $GLOBALS['gamucontact'] = [
|
||||||
'saisie' => 'input',
|
'saisie' => 'input',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'nom' => 'objet',
|
'nom' => 'objet',
|
||||||
'label' => 'Objet',
|
'label' => '<:gamucontact:objet:>',
|
||||||
'obligatoire' => 'oui',
|
'obligatoire' => 'oui',
|
||||||
'class' => 'w100'
|
'class' => 'w100'
|
||||||
//'fonction' => 'ma_super_fonction'
|
//'fonction' => 'ma_super_fonction'
|
||||||
|
@ -48,7 +48,7 @@ $GLOBALS['gamucontact'] = [
|
||||||
'saisie' => 'textarea',
|
'saisie' => 'textarea',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'nom' => 'texte',
|
'nom' => 'texte',
|
||||||
'label' => 'Message',
|
'label' => '<:gamucontact:message:>',
|
||||||
'obligatoire' => 'oui',
|
'obligatoire' => 'oui',
|
||||||
'class' => 'w100',
|
'class' => 'w100',
|
||||||
'rows' => 4
|
'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',
|
||||||
|
);
|
|
@ -8,7 +8,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||||
|
|
||||||
// G
|
// G
|
||||||
'gamucontact_titre' => 'Gamu Contact',
|
'gamucontact_titre' => 'GamuContact',
|
||||||
|
|
||||||
// C
|
// C
|
||||||
'cfg_exemple' => 'Exemple',
|
'cfg_exemple' => 'Exemple',
|
||||||
|
@ -17,7 +17,26 @@ $GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||||
|
|
||||||
// EE
|
// EE
|
||||||
'envoyer' => "Envoyer",
|
'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
|
// T
|
||||||
'titre_page_configurer_gamucontact' => 'Gamu Contact',
|
'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)" >]
|
[<img src="(#LOGO_SITE_SPIP|image_reduire{200}|extraire_attribut{src}|url_absolue)" >]
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<h1>Formulaire de contact</h1>
|
lang: #ENV{lang}<br>
|
||||||
<BOUCLE_message(MESSAGES){id_message}{tout}>
|
|
||||||
|
<h1><:gamucontact:formulaire_contact:></h1>
|
||||||
|
<BOUCLE_message(MESSAGES){id_message}{statut?}{tout}>
|
||||||
<div class="message">
|
<div class="message">
|
||||||
[<strong>Nom : </strong> (#NOM)<br>]
|
[<strong><:gamucontact:nom:> : </strong> (#NOM)<br>]
|
||||||
[<strong>Email : </strong> (#EMAIL_CONTACT)<br>]
|
[<strong><:gamucontact:email:> : </strong> (#EMAIL_CONTACT)<br>]
|
||||||
[<strong>Téléphone : </strong> (#TELEPHONE)]
|
[<strong><:gamucontact:telephone:> : </strong> (#TELEPHONE)]
|
||||||
[<hr><strong>objet : </strong>(#OBJET)<br>]
|
<hr>
|
||||||
[<strong>message : </strong>(#TEXTE)<br>]
|
[<strong><:gamucontact:objet:> : </strong>(#OBJET)<br><br>]
|
||||||
|
[<strong><:gamucontact:message:> : </strong>(#TEXTE)<br>]
|
||||||
</div>
|
</div>
|
||||||
</BOUCLE_message>
|
</BOUCLE_message>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue