Skip to content

Commit

Permalink
Admin module: Handle missing email template and module (#1107)
Browse files Browse the repository at this point in the history
Add missing alt attribute for img.
  • Loading branch information
blackcoder87 authored Nov 16, 2024
1 parent 58e9b2e commit 9e6af26
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
12 changes: 10 additions & 2 deletions application/modules/admin/controllers/admin/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,15 @@ public function treatAction()
->to(['action' => 'treat', 'key' => $this->getRequest()->getParam('key'), 'type' => $this->getRequest()->getParam('type'), 'locale' => $this->getRequest()->getParam('locale')]);
}

$this->getView()->set('moduleMapper', $moduleMapper)
->set('emailContent', $emailsMapper->getEmail($this->getRequest()->getParam('key'), $this->getRequest()->getParam('type'), $locale));
$emailContent = $emailsMapper->getEmail($this->getRequest()->getParam('key'), $this->getRequest()->getParam('type'), $locale);

if (!$emailContent) {
$this->redirect()
->withMessage('emailTemplateNotFound', 'danger')
->to(['action' => 'index']);
}

$this->getView()->set('modules', $moduleMapper->getModulesByKey($this->getRequest()->getParam('key'), $this->getTranslator()->getLocale()))
->set('emailContent', $emailContent);
}
}
1 change: 1 addition & 0 deletions application/modules/admin/translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@
'emailDesc' => 'Beschreibung',
'emailLocale' => 'Sprache',
'emailText' => 'Text',
'emailTemplateNotFound' => 'E-Mail-Vorlage nicht gefunden.',

'menuMail' => 'Mail Einstellungen',
'smtpModeEnabledDescription' => 'Versende E-Mails über einen SMTP-Server.',
Expand Down
1 change: 1 addition & 0 deletions application/modules/admin/translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@
'emailDesc' => 'Description',
'emailLocale' => 'Language',
'emailText' => 'Text',
'emailTemplateNotFound' => 'E-Mail template not found.',

'menuMail' => 'Mail settings',
'smtpModeEnabledDescription' => 'Sending emails through a SMTP server.',
Expand Down
4 changes: 2 additions & 2 deletions application/modules/admin/views/admin/emails/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<?php continue; ?>
<?php endif; ?>

<img src="<?=$this->getStaticUrl('img/lang/' . $key . '.png') ?>">
<img src="<?=$this->getStaticUrl('img/lang/' . $key . '.png') ?>" alt="<?=$key ?>">
<?php endforeach; ?>
</th>
<?php endif; ?>
Expand All @@ -34,7 +34,7 @@
<?php $emails = $emailsMapper->getEmailsByKey($modules->getModuleKey(), $this->getTranslator()->getLocale()); ?>
<tr>
<td <?=($this->get('multilingual')) ? 'colspan=2' : '' ?>>
<b><?=$module->getName() ?></b>
<b><?=$module ? $module->getName() : $this->escape($modules->getModuleKey()) ?></b>
</td>
</tr>
<?php foreach ($emails as $email): ?>
Expand Down
6 changes: 3 additions & 3 deletions application/modules/admin/views/admin/emails/treat.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$email = $this->get('emailContent');
$moduleMapper = $this->get('moduleMapper');
$module = $moduleMapper->getModulesByKey($this->getRequest()->getParam('key'), $this->getTranslator()->getLocale());
$module = $this->get('module');
$moduleName = ($module) ? $module->getName() : $this->escape($this->getRequest()->getParam('key'));
?>

<h1><?=$this->getTrans('edit') ?></h1>
Expand All @@ -12,7 +12,7 @@
<?=$this->getTrans('emailModule') ?>
</label>
<div class="col-xl-10">
<?=$module->getName() ?>
<?=$moduleName ?>
</div>
</div>
<div class="row mb-3">
Expand Down

0 comments on commit 9e6af26

Please sign in to comment.