Skip to content

Commit

Permalink
Add a new token filenames, that outputs the names of the uploaded f…
Browse files Browse the repository at this point in the history
…iles as list (#255)
  • Loading branch information
cliffparnitzky authored Dec 9, 2022
1 parent 83a7d33 commit 6f34e38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions classes/tl_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_*'),
Expand Down
8 changes: 8 additions & 0 deletions languages/en/tokens.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<source>All the form fields.</source>
<target>All the form fields.</target>
</trans-unit>
<trans-unit id="NOTIFICATION_CENTER_TOKEN.core_form.formconfig_*">
<source>All the form configurations.</source>
<target>All the form configurations.</target>
</trans-unit>
<trans-unit id="NOTIFICATION_CENTER_TOKEN.core_form.formlabel_*">
<source>All the form field labels.</source>
<target>All the form field labels.</target>
Expand All @@ -22,6 +26,10 @@
<source>All filled in form fields and their raw values.</source>
<target>All filled in form fields and their raw values.</target>
</trans-unit>
<trans-unit id="NOTIFICATION_CENTER_TOKEN.core_form.filenames">
<source>All the uploaded files names.</source>
<target>All the uploaded files names.</target>
</trans-unit>
<trans-unit id="NOTIFICATION_CENTER_TOKEN.member_personaldata.admin_email">
<source>E-mail address of administrator of the current page.</source>
<target>E-mail address of administrator of the current page.</target>
Expand Down

0 comments on commit 6f34e38

Please sign in to comment.