Commit 7b981445 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Necessary register array refactoring for dropdown to work correctly

parent c9c78ccc
......@@ -56,28 +56,34 @@ class MailController extends ActionController {
if ($this->request->hasArgument('selectedTemplate') && !$this->request->hasArgument('selectedLanguage')) {
$registerArray = MailTemplateService::getRegisterArray();
$selectedTemplate = $registerArray[$this->request->getArgument('selectedTemplate')];
$selectedExtensionArg = $this->request->getArgument('selectedExtension');
$selectedTemplateArg = $this->request->getArgument('selectedTemplate');
$selectedTemplate = $registerArray[$selectedExtensionArg][$selectedTemplateArg];
$this->view->assign('selectedTemplate', $selectedTemplate);
$this->view->assign('selectedTemplateKey', $this->request->getArgument('selectedTemplate'));
$this->view->assign('selectedTemplateKey', intval($selectedTemplateArg));
$this->view->assign('selectedExtensionKey', $selectedExtensionArg);
} elseif (!$this->request->hasArgument('selectedLanguage')) {
reset(MailTemplateService::getRegisterArray());
$firstEntry = key(MailTemplateService::getRegisterArray());
$this->view->assign('selectedTemplate', MailTemplateService::getRegisterArray()[$firstEntry]);
$this->view->assign('selectedTemplateKey', $firstEntry);
$this->view->assign('selectedTemplate', MailTemplateService::getRegisterArray()[$firstEntry][0]);
$this->view->assign('selectedTemplateKey', intval($firstEntry));
$this->view->assign('selectedExtensionKey', $firstEntry);
}
if ($this->request->hasArgument('selectedLanguage')
&& $this->request->hasArgument('selectedTemplate')
&& $this->request->hasArgument('selectedTemplateKey')
&& $this->request->hasArgument('selectedExtensionKey')
) {
$this->view->assign('selectedLanguage', $this->request->getArgument('selectedLanguage'));
$this->view->assign('selectedTemplate', $this->request->getArgument('selectedTemplate'));
$this->view->assign('selectedTemplateKey', $this->request->getArgument('selectedTemplateKey'));
$this->view->assign('selectedExtensionKey', intval($this->request->getArgument('selectedExtensionKey')));
} else {
$this->view->assign('selectedLanguage', 'en');
......
......@@ -25,10 +25,6 @@ namespace SGalinski\SgMail\Service;
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Lang\Domain\Model\Language;
use TYPO3\CMS\Lang\Domain\Repository\LanguageRepository;
/**
* MailTemplateService
......@@ -49,11 +45,12 @@ class MailTemplateService {
*/
public static function registerTemplate($extension, $templateName, $templatePath, $description, array $marker) {
MailTemplateService::$registerArray[$templateName] = [
MailTemplateService::$registerArray[$extension][] = [
'templatePath' => $templatePath,
'description' => $description,
'marker' => $marker,
'extension' => $extension
'extension' => $extension,
'templateName' => $templateName
];
}
......
......@@ -7,23 +7,28 @@
<div class="module-docheader-bar-column-left">
<div class="btn-toolbar" role="toolbar">
<f:be.menus.actionMenu>
<f:for each="{templates}" as="template" key="templateKey">
<sgm:be.menus.actionMenuOptionGroup label="{template.extension}">
<sgm:extendedIf condition="{selectedTemplateKey} == {templateKey}">
<f:for each="{templates}" as="template" key="extensionKey">
<sgm:be.menus.actionMenuOptionGroup label="{extensionKey}">
<f:for each="{template}" as="currentTemplate" key="templateKey">
<sgm:extendedIf condition="{selectedTemplateKey} == {templateKey}"
and="{selectedExtensionKey} == {extensionKey}">
<f:then>
<sgm:be.menus.actionMenuItem label="{templateKey}"
<sgm:be.menus.actionMenuItem label="{currentTemplate.templateName}"
controller="Mail"
action="index"
arguments="{selectedTemplate: templateKey}"
arguments="{selectedTemplate: templateKey, selectedExtension: extensionKey}"
additionalAttributes="{selected: 'selected'}" />
</f:then>
<f:else>
<sgm:be.menus.actionMenuItem label="{templateKey}"
<sgm:be.menus.actionMenuItem label="{currentTemplate.templateName}"
controller="Mail"
action="index"
arguments="{selectedTemplate: templateKey}"/>
arguments="{selectedTemplate: templateKey, selectedExtension: extensionKey}" />
</f:else>
</sgm:extendedIf>
</f:for>
</sgm:be.menus.actionMenuOptionGroup>
</f:for>
</f:be.menus.actionMenu>
......
......@@ -2,7 +2,6 @@
<f:layout name="Default" />
<f:section name="iconButtons">
&nbsp;
</f:section>
<f:section name="main">
<f:flashMessages renderMode="div" />
......@@ -32,14 +31,14 @@
<sgm:be.menus.actionMenuItem label="{language}"
controller="Mail"
action="index"
arguments="{selectedLanguage: language, selectedTemplate: selectedTemplate, selectedTemplateKey: selectedTemplateKey}"
arguments="{selectedLanguage: language, selectedTemplate: selectedTemplate, selectedExtensionKey: selectedExtensionKey, selectedTemplateKey: selectedTemplateKey}"
additionalAttributes="{selected: 'selected'}" />
</f:then>
<f:else>
<sgm:be.menus.actionMenuItem label="{language}"
controller="Mail"
action="index"
arguments="{selectedLanguage: language, selectedTemplate: selectedTemplate, selectedTemplateKey: selectedTemplateKey}" />
arguments="{selectedLanguage: language, selectedTemplate: selectedTemplate, selectedExtensionKey: selectedExtensionKey, selectedTemplateKey: selectedTemplateKey}" />
</f:else>
</sgm:extendedIf>
</f:for>
......
......@@ -30,48 +30,46 @@ if (!defined('TYPO3_MODE')) {
/** @noinspection PhpUndefinedVariableInspection */
$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sg_mail');
$templateFiles = [
$extPath . 'Resources/Private/Templates/some-email.html',
$extPath . 'Resources/Private/Templates/de.some-email.html'
];
$templatePath = $extPath . 'Resources/Private/Templates/';
$marker = [
'header_content' => [
'content' => 'HEADING',
'description' => 'This is the heading of the Email'
[
'marker' => 'kundennummer',
'value' => '01234567890',
'description' => 'This is the Customer no'
],
'main_content' => [
'content' => 'Lorem Ipsum',
'description' => 'The Content of the Mail'
[
'marker' => 'iban',
'value' => 'DE XXXXXXXXXX',
'description' => 'This is the Bank Information'
]
];
$description = 'This is just a Test Email';
\SGalinski\SgMail\Service\MailTemplateService::registerTemplate(
'sg_mail', 'system test email', $templateFiles, $description, $marker
'sg_mail', 'system test email', $templatePath, $description, $marker
);
$templateFiles = [
$extPath . 'Resources/Private/Templates/some-email.html',
$extPath . 'Resources/Private/Templates/de.some-email.html'
];
$templatePath = $extPath . 'Resources/Private/';
$marker = [
'header_content' => [
'content' => 'HEADING',
'description' => 'This is the heading of the Email'
[
'marker' => 'kundennummer',
'value' => '6666666666666',
'description' => 'This is the Customer no'
],
'main_content' => [
'content' => 'Lorem Ipsum',
'description' => 'The Content of the Mail'
[
'marker' => 'iban',
'value' => 'DE XXXXXXXXXX',
'description' => 'This is the Bank Information'
]
];
$description = 'This is just a Test Email';
$description = 'This is just a another Test Email';
\SGalinski\SgMail\Service\MailTemplateService::registerTemplate(
'sg_mail', 'test email2', $templateFiles, $description, $marker
'sg_mail', 'system another test email', $templatePath, $description, $marker
);
if (TYPO3_MODE === 'BE') {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment