diff --git a/htdocs/core/ajax/mailtemplate.php b/htdocs/core/ajax/mailtemplate.php index 85b30f14bf6..5ac260b03bb 100644 --- a/htdocs/core/ajax/mailtemplate.php +++ b/htdocs/core/ajax/mailtemplate.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 Frédéric France +/* Copyright (C) 2024-2025 Laurent Destailleur + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -91,11 +91,24 @@ if (GETPOSTISSET('template')) { '__LAST_NEWS__' => $langs->trans('LastNews'), '__LIST_PRODUCTS___' => $langs->trans('ListProducts'), '__SUBJECT__' => GETPOST('subject'), - '__MYCOMPANY_SOCIAL_NETWORKS__' => 'TODO Generate list of enabled social network', + // vars for company '__MYCOMPANY_ADDRESS__' => $mysoc->getFullAddress(0, '
', 1, $langs), '__MYCOMPANY_EMAIL__' => $mysoc->email, + '__MYCOMPANY_PHONE_PRO__' => $mysoc->phone_pro, + '__MYCOMPANY_PHONE_MOBILE__' => $mysoc->phone_mobile, + '__MYCOMPANY_FAX__' => $mysoc->fax, + '__MYCOMPANY_EMAIL__' => $mysoc->email, ); + $listsocialnetworks = ''; + // TODO Add a column imgsrcdata into llx_c_socialnetworks to store the src data for image of the social network in black on a white background. + /* + foreach($mysoc->socialnetworks as $snkey => $snval) { + $listsocialnetworks .= $snkey; + } + */ + $specificSubstitutionArray['__MYCOMPANY_SOCIAL_NETWORKS__'] = $listsocialnetworks; + if (!empty($mysoc->logo) && dol_is_file($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { $specificSubstitutionArray['__LOGO_URL__'] = $urlwithroot.'/viewimage.php?modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); } else { @@ -116,7 +129,6 @@ if (GETPOSTISSET('template')) { } - // Must replace // __SUBJECT__, __CONTENTOFMAILHOLDER__, __USERSIGNATURE__, __NEWS_LIST__, __PRODUCTS_LIST__ foreach ($specificSubstitutionArray as $key => $val) { @@ -124,7 +136,11 @@ if (GETPOSTISSET('template')) { } // Parse all strings __(...)__ to replace with the translated value $langs->trans("...") - // TODO + $langs->load("other"); + $content = preg_replace_callback('/__\((.+)\)__/', function ($matches) { + global $langs; + return $langs->trans($matches[1]); + }, $content); $selectedPostsStr = GETPOST('selectedPosts', 'alpha'); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 65509e6b203..6289e924ccd 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1500,10 +1500,11 @@ class FormMail extends Form */ public function getEmailLayoutSelector($htmlContent = 'message', $showlinktolayout = 'email') { - global $websitepage, $langs; + global $conf, $db, $websitepage, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/emaillayout.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; $out = '