Skip to content

Commit

Permalink
Mail: Make language variable placeholder interpolation more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Sep 6, 2023
1 parent d0f2f72 commit 522d570
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Services/Mail/classes/class.ilMailFormGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,11 @@ public function showForm()

$placeholders = new ilManualPlaceholderInputGUI('m_message');
$placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
$placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
try {
$placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
} catch (Throwable $e) {
$placeholders->setAdviseText($this->lng->txt('placeholders_advise'));
}
foreach ($context->getPlaceholders() as $key => $value) {
$placeholders->addPlaceholder($value['placeholder'], $value['label']);
}
Expand Down
12 changes: 10 additions & 2 deletions Services/Mail/classes/class.ilMailTemplateGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,11 @@ public function getAjaxPlaceholdersById() : void

$placeholders = new ilManualPlaceholderInputGUI('m_message');
$placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
$placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
try {
$placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
} catch (Throwable $e) {
$placeholders->setAdviseText($this->lng->txt('placeholders_advise'));
}

$context = ilMailTemplateContextService::getTemplateContextById($contextId);
foreach ($context->getPlaceholders() as $key => $value) {
Expand Down Expand Up @@ -522,7 +526,11 @@ protected function getTemplateForm(ilMailTemplate $template = null) : ilProperty
$placeholders = new ilManualPlaceholderInputGUI('m_message');
$placeholders->setDisabled(!$this->isEditingAllowed());
$placeholders->setInstructionText($this->lng->txt('mail_nacc_use_placeholder'));
$placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
try {
$placeholders->setAdviseText(sprintf($this->lng->txt('placeholders_advise'), '<br />'));
} catch (Throwable $e) {
$placeholders->setAdviseText($this->lng->txt('placeholders_advise'));
}
$placeholders->supportsRerenderSignal(
'context',
$this->ctrl->getLinkTarget($this, 'getAjaxPlaceholdersById', '', true, false)
Expand Down

0 comments on commit 522d570

Please sign in to comment.