Skip to content
Snippets Groups Projects
Commit d8c5fc35 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Translations keys can now be used for template description and subjects

parent ad2de583
No related branches found
No related tags found
No related merge requests found
......@@ -143,16 +143,44 @@ class MailController extends ActionController {
}
}
$this->view->assign(
'subjectLeft', $templateLeft !== NULL ? $templateLeft->getSubject() :
$registerArray[$selectedExtension][$selectedTemplate]['subjects'][$selectedLanguageLeft]
);
$subject = $registerArray[$selectedExtension][$selectedTemplate]['subject'];
if (is_array($subject)) {
$this->view->assign(
'subjectLeft', $templateLeft !== NULL ? $templateLeft->getSubject() :
$registerArray[$selectedExtension][$selectedTemplate]['subject'][$selectedLanguageLeft]
);
$this->view->assign(
'subjectRight', $templateRight !== NULL ? $templateRight->getSubject() :
$registerArray[$selectedExtension][$selectedTemplate]['subjects'][$selectedLanguageRight]
);
$this->view->assign(
'subjectRight', $templateRight !== NULL ? $templateRight->getSubject() :
$registerArray[$selectedExtension][$selectedTemplate]['subject'][$selectedLanguageRight]
);
} else {
# @todo select languages to get specific independent translation
$this->view->assign(
'subjectLeft', $templateLeft !== NULL ? $templateLeft->getSubject() :
LocalizationUtility::translate(
$subject, $selectedExtension
)
);
$this->view->assign(
'subjectRight', $templateRight !== NULL ? $templateRight->getSubject() :
LocalizationUtility::translate(
$subject, $selectedExtension
)
);
}
$templateDescription = $registerArray[$selectedExtension][$selectedTemplate]['description'];
if (is_array($templateDescription)) {
$templateDescription = $templateDescription[$selectedLanguageLeft];
} else {
$templateDescription = LocalizationUtility::translate(
$templateDescription, $selectedExtension
);
}
$this->view->assign('templateDescription', $templateDescription);
$this->view->assign('selectedTemplate', $selectedTemplateArray);
$this->view->assign('selectedTemplateKey', $selectedTemplate);
$this->view->assign('selectedExtensionKey', $selectedExtension);
......
......@@ -197,15 +197,18 @@ class MailTemplateService {
/**
* register a template with sg_mail
*
* description and subject can now be an array i.e. with elements such as 'en' => 'english description'
* or an translation string used in locallang.xml
*
* @param string $extension
* @param string $templateName
* @param string $templatePath
* @param string $description
* @param mixed $description
* @param array $markers
* @param array $subjects
* @param mixed $subject
*/
public static function registerTemplate(
$extension, $templateName, $templatePath, $description, array $markers, array $subjects
$extension, $templateName, $templatePath, $description, array $markers, $subject
) {
MailTemplateService::$registerArray[$extension][$templateName] = [
'templatePath' => $templatePath,
......@@ -213,7 +216,7 @@ class MailTemplateService {
'marker' => $markers,
'extension' => $extension,
'templateName' => $templateName,
'subjects' => $subjects
'subject' => $subject
];
}
......@@ -307,7 +310,16 @@ class MailTemplateService {
$subject = $template->getSubject();
} else {
$emailView->setTemplateSource($defaultTemplateContent);
$subject = self::$registerArray[$this->extensionKey][$this->templateName]['subjects'][$this->language];
$subject = self::$registerArray[$this->extensionKey][$this->templateName]['subject'];
if (is_array($subject)) {
$subject = self::$registerArray[$this->extensionKey][$this->templateName]['subject'][$this->language];
} else {
$subject = LocalizationUtility::translate(
self::$registerArray[$this->extensionKey][$this->templateName]['subject'],
$this->extensionKey
);
}
}
$this->mailMessage->setSubject($subject);
......
......@@ -8,7 +8,7 @@
<f:section name="main">
<f:flashMessages renderMode="div" />
<div class="col-md-12">
<p>{selectedTemplate.description}</p>
<p>{templateDescription}</p>
</div>
<div class="col-md-12">
<table class="table table-hover">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment