diff --git a/Classes/Controller/MailController.php b/Classes/Controller/MailController.php index 75454dc0a45b1cb371d3b059d2eb7d428d79661f..35a8fd94daa72974c168d821096dc3fc1a1306b7 100644 --- a/Classes/Controller/MailController.php +++ b/Classes/Controller/MailController.php @@ -38,17 +38,21 @@ class MailController extends ActionController { * */ public function indexAction() { - $this->view->assign('extensions', array_keys(MailTemplateService::$registerArray)); + $this->view->assign('extensions', MailTemplateService::$registerArray); } /** - * @return void + * + * */ - public function showAction() { - print_r($_REQUEST); + public function showTemplatesAction() { + $extensionKey = $this->request->getArgument('ext_key'); + + + $files = glob('/path/to/dir/*.xml'); + $this->view->assign('templates', MailTemplateService::$registerArray[$extensionKey]); + - $this->view->assign('extensions', array_keys(MailTemplateService::$registerArray)); - $this->view->assign('templates', array_keys(MailTemplateService::$registerArray)); } } diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php index 7c063be4627ca40e6138dbf1c66509720457c445..08a3e0b4cad2e9874113f532e7a3d9b5c09a1b54 100644 --- a/Classes/Service/MailTemplateService.php +++ b/Classes/Service/MailTemplateService.php @@ -2,35 +2,39 @@ namespace SGalinski\SgMail\Service; -/*************************************************************** - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ + /*************************************************************** + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; /** * MailTemplateService */ class MailTemplateService { + /** + * @var array + */ public static $registerArray = []; /** @@ -39,6 +43,13 @@ class MailTemplateService { * @return string */ public static function registerTemplate($extensionKey, $template) { + $path = ExtensionManagementUtility::extPath('sg_mail'); + + if (!file_exists($path . '/Configuration/Templates/' . $template . '.html')) { + // @TODO Throw exception + return; + } + if (!array_key_exists($extensionKey, MailTemplateService::$registerArray)) { MailTemplateService::$registerArray[$extensionKey] = [$template]; } elseif (!in_array(MailTemplateService::$registerArray[$extensionKey], $template)) { diff --git a/Configuration/Templates/test.html b/Configuration/Templates/test.html new file mode 100644 index 0000000000000000000000000000000000000000..1a849f42ed91d69d64590a7a395be54d5cc6f3a4 --- /dev/null +++ b/Configuration/Templates/test.html @@ -0,0 +1 @@ +<h1>###heading###</h1> diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html index 1f982eef1bf4a755c4e00067d710ea0b88fec834..737ecc9ea44d297c6160b1d4042a1382ac21038d 100644 --- a/Resources/Private/Layouts/Default.html +++ b/Resources/Private/Layouts/Default.html @@ -4,13 +4,7 @@ <div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation"> <div class="module-docheader-bar-column-left"> <div class="btn-toolbar" role="toolbar"> - <f:be.menus.actionMenu> - <f:for each="{extensions}" as="extension"> - <f:be.menus.actionMenuItem label="{extension}" - controller="Mail" - action="show" /> - </f:for> - </f:be.menus.actionMenu> + </div> </div> <div class="module-docheader-bar-column-right"> diff --git a/Resources/Private/Templates/Mail/Index.html b/Resources/Private/Templates/Mail/Index.html index d6f8748bd413a31b8f8f4cc7eb7d0ac1d03f2a4e..997e75e56afe9e11eb1944700046a94a87f6f31a 100644 --- a/Resources/Private/Templates/Mail/Index.html +++ b/Resources/Private/Templates/Mail/Index.html @@ -4,4 +4,14 @@ </f:section> <f:section name="main"> <f:flashMessages renderMode="div" /> + + <h3>Registered Extensions</h3> + <ul class="list-group"> + <f:for each="{extensions}" as="extension" key="key"> + <li class="list-group-item"> + <f:link.action controller="Mail" action="showTemplates" arguments="{ext_key:'{key}'}">{key}</f:link.action> + <span class="badge"><f:count>{extension}</f:count></span> + </li> + </f:for> + </ul> </f:section> diff --git a/Resources/Private/Templates/Mail/Show.html b/Resources/Private/Templates/Mail/ShowTemplates.html similarity index 90% rename from Resources/Private/Templates/Mail/Show.html rename to Resources/Private/Templates/Mail/ShowTemplates.html index 176ebf2dbd272400bf3038ce6efc1a7617a4ff90..d3d1e1baf3a9568454cf372afc4e9c54d6b7903a 100644 --- a/Resources/Private/Templates/Mail/Show.html +++ b/Resources/Private/Templates/Mail/ShowTemplates.html @@ -6,6 +6,6 @@ <f:flashMessages renderMode="div" /> <f:for each="{templates}" as="template"> - <h3>{template}</h3> + {template}<br /> </f:for> </f:section> diff --git a/ext_tables.php b/ext_tables.php index 49168c4811246f8cf4fc6a0e209169273ce37288..12d6eefd3e8d8d701277f7e90e2d4dcb1fe8ec88 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -10,7 +10,7 @@ if (!defined('TYPO3_MODE')) { 'Mail', '', [ - 'Mail' => 'index', 'show', + 'Mail' => 'index, showTemplates', ], [ 'access' => 'admin,user,group',