From 6f34e38c246ec82e37e0376ed8705c2692d9de1e Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Fri, 9 Dec 2022 12:26:17 +0100 Subject: [PATCH] Add a new token `filenames`, that outputs the names of the uploaded files as list (#255) --- classes/tl_form.php | 3 +++ config/config.php | 4 ++-- languages/en/tokens.xlf | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/classes/tl_form.php b/classes/tl_form.php index d188b13d..fead2598 100644 --- a/classes/tl_form.php +++ b/classes/tl_form.php @@ -102,9 +102,12 @@ public function generateTokens(array $arrData, array $arrForm, array $arrFiles, $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL']; // Upload fields + $arrFileNames = array(); foreach ($arrFiles as $fieldName => $file) { $arrTokens['form_' . $fieldName] = Form::getFileUploadPathForToken($file); + $arrFileNames[] = $file['name']; } + $arrTokens['filenames'] = implode($delimiter, $arrFileNames); return $arrTokens; } diff --git a/config/config.php b/config/config.php index 0373e192..a848bacc 100644 --- a/config/config.php +++ b/config/config.php @@ -104,8 +104,8 @@ 'core_form' => array( 'recipients' => array('admin_email', 'form_*', 'formconfig_*'), 'email_subject' => array('form_*', 'formconfig_*', 'admin_email'), - 'email_text' => array('form_*', 'formconfig_*', 'formlabel_*', 'raw_data', 'raw_data_filled', 'admin_email'), - 'email_html' => array('form_*', 'formconfig_*', 'formlabel_*', 'raw_data', 'raw_data_filled', 'admin_email'), + 'email_text' => array('form_*', 'formconfig_*', 'formlabel_*', 'raw_data', 'raw_data_filled', 'admin_email', 'filenames'), + 'email_html' => array('form_*', 'formconfig_*', 'formlabel_*', 'raw_data', 'raw_data_filled', 'admin_email', 'filenames'), 'file_name' => array('form_*', 'formconfig_*', 'admin_email'), 'file_content' => array('form_*', 'formconfig_*', 'formlabel_*', 'raw_data', 'raw_data_filled', 'admin_email'), 'email_sender_name' => array('admin_email', 'form_*', 'formconfig_*'), diff --git a/languages/en/tokens.xlf b/languages/en/tokens.xlf index 975343a5..359cd9d9 100644 --- a/languages/en/tokens.xlf +++ b/languages/en/tokens.xlf @@ -10,6 +10,10 @@ All the form fields. All the form fields. + + All the form configurations. + All the form configurations. + All the form field labels. All the form field labels. @@ -22,6 +26,10 @@ All filled in form fields and their raw values. All filled in form fields and their raw values. + + All the uploaded files names. + All the uploaded files names. + E-mail address of administrator of the current page. E-mail address of administrator of the current page.