diff --git a/Classes/Controller/ConfigurationController.php b/Classes/Controller/ConfigurationController.php new file mode 100644 index 0000000000000000000000000000000000000000..abeee03cddd87a1e204c739fa90223055c870fb4 --- /dev/null +++ b/Classes/Controller/ConfigurationController.php @@ -0,0 +1,248 @@ +<?php + +namespace SGalinski\SgMail\Controller; + +/*************************************************************** + * 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 SGalinski\SgMail\Service\BackendService; +use SGalinski\SgMail\Service\MailTemplateService; +use SGalinski\SgMail\Service\TypoScriptSettingsService; +use SGalinski\SgMail\Session\PhpSession; +use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent; +use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; +use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; +use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException; +use TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException; +use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Extbase\Utility\LocalizationUtility; + +/** + * Controller for the configuration mode of the backend module + */ +class ConfigurationController extends ActionController { + const DEFAULT_EXTENSION_KEY = 'sg_mail'; + + /** + * DocHeaderComponent + * + * @var DocHeaderComponent + */ + protected $docHeaderComponent; + + /** + * @var \SGalinski\SgMail\Session\PhpSession + */ + protected $session; + + /** + * + * @param string $selectedTemplate + * @param string $selectedExtension + * @param array $filters + * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException + */ + public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []) { + if ($this->request->hasArgument('message')) { + $this->addFlashMessage($this->request->getArgument('message'), '', FlashMessage::ERROR); + } + + $pageUid = (int) GeneralUtility::_GP('id'); + + $registerArray = BackendService::getNonBlacklistedTemplates($pageUid); + if ($selectedTemplate === NULL || $selectedTemplate === '') { + if (!empty($registerArray)) { + $selectedExtension = \key($registerArray); + } + if (!empty($registerArray)) { + $selectedTemplate = \key($registerArray[$selectedExtension]); + } + } + + // make docheader + $this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class); + $pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1)); + if ($pageInfo === FALSE) { + $pageInfo = ['uid' => $pageUid]; + } + $this->docHeaderComponent->setMetaInformation($pageInfo); + BackendService::makeButtons($this->docHeaderComponent, $this->request); + + $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); + $this->view->assign('selectedTemplateFilter', $filters['filterTemplate']); + $this->view->assign('selectedExtensionFilter', $filters['filterExtension']); + $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); + $this->view->assign('selectedTemplateKey', $selectedTemplate); + $this->view->assign('selectedExtensionKey', $selectedExtension); + $this->view->assign('mode', 'editor'); + } + + /** + * Create the template or display errors that occured + * + * @throws StopActionException + * @throws UnsupportedRequestTypeException + * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException + * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException + */ + public function createAction() { + if (!$this->request->hasArgument('configuration')) { + $this->redirect( + 'index', 'Configuration', NULL, + ['message' => LocalizationUtility::translate('backend.create_error', 'sg_mail')] + ); + } + + /** @var array $configuration */ + $configuration = $this->request->getArgument('configuration'); + + $templateName = $configuration['templateName']; + $csv = str_replace("\r", '', $configuration['csv']); + $subject = $configuration['subject']; + $description = $configuration['description']; + + $markersCsv = \explode("\n", $csv); + $markers = []; + + foreach ($markersCsv as $markerCsv) { + $rowArray = str_getcsv($markerCsv, ';'); + if (!$rowArray[0]) { + continue; + } + $markers[] = [ + 'identifier' => $rowArray[0], + 'value' => $rowArray[1], + 'description' => $rowArray[2] + ]; + } + + $this->writeRegisterFile($templateName, self::DEFAULT_EXTENSION_KEY, $markers, $subject, $description); + MailTemplateService::registerExtensions(); + + $this->clearCaches(); + + // store selected template & extension key in the session + if (!($this->session instanceof PhpSession)) { + $this->session = $this->objectManager->get(PhpSession::class); + $this->session->setSessionKey('sg_mail_controller_session'); + } else { + $this->session->setSessionKey('sg_mail_controller_session'); + } + $this->session->setDataByKey('selectedTemplate', $templateName); + $this->session->setDataByKey('selectedExtension', self::DEFAULT_EXTENSION_KEY); + + $this->redirect( + 'index', 'Mail', NULL, + ['message' => LocalizationUtility::translate('backend.create_message', 'sg_mail')] + ); + } + + /** + * Write the mail registration file + * + * @TODO move this to the register service class when security update is merged. refactor in FormEditorController xclass as well + * + * @param string $templateKey + * @param string $extensionKey + * @param array $markers + * @param string $subject + * @param string $description + */ + private function writeRegisterFile($templateKey, $extensionKey, $markers, $subject, $description) { + // get the location where registrations should be stored + $configurationLocation = $this->getRegistrationPath(); + + $registerFolder = GeneralUtility::getFileAbsFileName( + $configurationLocation + ); + // create folder + GeneralUtility::mkdir($registerFolder); + + $registerFile = GeneralUtility::getFileAbsFileName( + $registerFolder . '/' . $templateKey . '.php' + ); + + // build the register array + $newRegisterArray = [ + 'extension_key' => $extensionKey, + 'template_key' => $templateKey, + 'description' => $description, + 'subject' => $subject, + 'markers' => [] + ]; + + // add the markers for this template + foreach ($markers as $marker) { + $markerName = $marker['identifier']; + $newRegisterArray['markers'][] = [ + 'marker' => $markerName, + 'type' => MailTemplateService::MARKER_TYPE_STRING, + 'value' => $marker['value'], + 'description' => $marker['description'] + ]; + } + + file_put_contents($registerFile, '<?php return ' . var_export($newRegisterArray, TRUE) . ';'); + } + + /** + * Returns the path to the configured location where automatic mail template registrations should be + * + * @TODO move this to the register service class when security update is merged. refactor in FormEditorController xclass as well + * + * @return string + */ + private function getRegistrationPath(): string { + // get typoscript settings from sg mail + /** @var TypoScriptSettingsService $typoScriptSettingsService */ + $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); + $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); + + // get the location where automatic registrations should be stored + return 'EXT:' . $tsSettings['mail']['configurationLocation'] . '/' . MailTemplateService::CONFIG_PATH; + } + + /** + * Clear the sgmail register cache + * + * @TODO move this to the register service class when security update is merged. refactor in FormEditorController xclass as well + * + * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException + */ + private function clearCaches() { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $cacheManager = $objectManager->get(CacheManager::class); + + /** @var FrontendInterface $cache */ + $cache = $cacheManager->getCache(MailTemplateService::CACHE_NAME); + /** @var FrontendInterface $cache */ + $cache->flush(); + } +} diff --git a/Classes/Controller/MailController.php b/Classes/Controller/MailController.php index baf953cba10ed4a7fe1e7556cb676d2d7fc98457..c8adb40d373a89d984c30bb346423bdd84e6fb91 100644 --- a/Classes/Controller/MailController.php +++ b/Classes/Controller/MailController.php @@ -82,6 +82,10 @@ class MailController extends ActionController { * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException */ public function indexAction(array $parameters = []) { + if ($this->request->hasArgument('message')) { + $this->addFlashMessage($this->request->getArgument('message'), '', FlashMessage::INFO); + } + $pid = (int) GeneralUtility::_GP('id'); if (!($this->session instanceof PhpSession)) { diff --git a/Classes/Controller/QueueController.php b/Classes/Controller/QueueController.php index 2e27c0a84eafc1c23fd4e35606b71c63145ad73f..34a6a462b22502155c1413b5c92004d8dd3cbb40 100644 --- a/Classes/Controller/QueueController.php +++ b/Classes/Controller/QueueController.php @@ -153,8 +153,8 @@ class QueueController extends ActionController { $pageInfo = ['uid' => $pageUid]; } $this->docHeaderComponent->setMetaInformation($pageInfo); - $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); BackendService::makeButtons($this->docHeaderComponent, $this->request); + $this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent()); $this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)); } diff --git a/Classes/XClass/Form/FormEditorController.php b/Classes/XClass/Form/FormEditorController.php index 769a6196845fa9cfcd7d905c19d9b7a072faa3d8..6ba14632d3e57bed62def76e41ae39fa49937002 100644 --- a/Classes/XClass/Form/FormEditorController.php +++ b/Classes/XClass/Form/FormEditorController.php @@ -84,9 +84,9 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll foreach ($finishers as $finisher) { - // if one finisher prevents automatic registration, exit this function + // if the current finisher prevents automatic registration, exit this iteration if (!$finisher['options']['automaticRegistration']) { - return; + continue; } if (!\in_array($finisher['identifier'], self::MAIL_FINISHER, TRUE)) { diff --git a/Classes/XClass/Form/FormManagerController.php b/Classes/XClass/Form/FormManagerController.php new file mode 100644 index 0000000000000000000000000000000000000000..83c5856ca7dc9784a998940f7eaa839c1bf09061 --- /dev/null +++ b/Classes/XClass/Form/FormManagerController.php @@ -0,0 +1,95 @@ +<?php + +namespace SGalinski\SgMail\XClass\Form; + +/*************************************************************** + * 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 2 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! + ***************************************************************/ + +/** @noinspection LongInheritanceChainInspection */ + +use SGalinski\SgMail\Service\MailTemplateService; +use SGalinski\SgMail\Service\TypoScriptSettingsService; +use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Object\ObjectManager; + +/** + * Displays the form editor. Enables hooking into the save process of the form to handle automatic sg mail registration + */ +class FormManagerController extends \TYPO3\CMS\Form\Controller\FormManagerController { + + /** + * Delete the SgMail Registration file for the deleted form and clear the cache afterwards + * + * @param string $formPersistenceIdentifier persistence identifier to delete + * @internal + * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException + */ + public function deleteAction(string $formPersistenceIdentifier) { + // build the path to the register file + $filePath = \str_replace( + '.form.yaml', '.php', \substr($formPersistenceIdentifier, \strrpos($formPersistenceIdentifier, '/') + 1) + ); + + $fileName = GeneralUtility::getFileAbsFileName($this->getRegistrationPath() . '/' . $filePath); + // delete the file if found + if (\file_exists($fileName)) { + \unlink($fileName); + $this->clearCaches(); + } + + // needs to be done last because of the internal redirect + parent::deleteAction($formPersistenceIdentifier); + } + + /** + * Returns the path to the configured location where automatic mail template registrations should be + * + * @return string + */ + private function getRegistrationPath(): string { + // get typoscript settings from sg mail + /** @var TypoScriptSettingsService $typoScriptSettingsService */ + $typoScriptSettingsService = $this->objectManager->get(TypoScriptSettingsService::class); + $tsSettings = $typoScriptSettingsService->getSettings(0, 'tx_sgmail'); + + // get the location where automatic registrations should be stored + return 'EXT:' . $tsSettings['mail']['configurationLocation'] . '/' . MailTemplateService::CONFIG_PATH; + } + + /** + * Clear the sgmail register cache + * + * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException + */ + private function clearCaches() { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $cacheManager = $objectManager->get(CacheManager::class); + + /** @var FrontendInterface $cache */ + $cache = $cacheManager->getCache(MailTemplateService::CACHE_NAME); + /** @var FrontendInterface $cache */ + $cache->flush(); + } +} diff --git a/Configuration/Yaml/Forms/FinisherSetupBE.yaml b/Configuration/Yaml/Forms/FinisherSetupBE.yaml index 129d2501d08916c24bfc71dc55157bf146f6c7ed..e03d9d3101cdb58038a923cf35fe7bc0a260bad6 100644 --- a/Configuration/Yaml/Forms/FinisherSetupBE.yaml +++ b/Configuration/Yaml/Forms/FinisherSetupBE.yaml @@ -13,7 +13,7 @@ TYPO3: options: extension: 'sg_mail' template: '' - automaticRegistration: '' + automaticRegistration: true ignoreMailQueue: true mailTo: '' userName: '' @@ -29,7 +29,7 @@ TYPO3: options: extension: 'sg_mail' template: '' - automaticRegistration: '' + automaticRegistration: true ignoreMailQueue: true mailTo: '' mailFrom: '' diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 395be24df14002bcdf09dd16b4572161ace3dfa9..fde8d2779d58c0409aaa521800bc6f669f9b94c3 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -29,6 +29,10 @@ <source><![CDATA[Show mails from blacklisted templates]]></source> <target><![CDATA[Mails basierend auf gesperrten Templates anzeigen]]></target> </trans-unit> + <trans-unit id="backend.button_create" approved="yes"> + <source><![CDATA[Register new template]]></source> + <target><![CDATA[Neues Template registrieren]]></target> + </trans-unit> <trans-unit id="backend.button_download_csv" approved="yes"> <source><![CDATA[Export CSV]]></source> <target><![CDATA[CSV exportieren]]></target> @@ -53,6 +57,50 @@ <source><![CDATA[Text]]></source> <target><![CDATA[Text]]></target> </trans-unit> + <trans-unit id="backend.create.csv" approved="yes"> + <source><![CDATA[Marker (csv format)]]></source> + <target><![CDATA[Marker (csv Format)]]></target> + </trans-unit> + <trans-unit id="backend.create.description" approved="yes"> + <source><![CDATA[Description]]></source> + <target><![CDATA[Beschreibung]]></target> + </trans-unit> + <trans-unit id="backend.create.info" approved="yes"> + <source><![CDATA[Please insert the template marker in the following format: markerName; exampleValue; description <br /><br />Whitespaces in marker names are ignored. <br />If you have multiple markers, seperate them with a new line: markerName1; exampleValue1; description1<br />markerName2; exampleValue2; description2 <br /><br />Example: first_name; Max; The first name of the client <br />last_name; Mustermann; The last name of the client]]></source> + <target><![CDATA[Bitte geben Sie die Template Marker im folgenden Format ein: markerName; beispiel; beschreibung <br /><br />Leerzeichen in Markernamen werden ignoriert. <br /><br />Mehrere Marker werden mit der Eingabetaste getrennt: markerName1; beispiel1; beschreibung1<br />markerName2; beispiel2; beschreibung2 <br /><br />Beispiel: first_name; Max; Der Vorname des Kunden<br /> last_name; Mustermann; Der Nachname des Kunden]]></target> + </trans-unit> + <trans-unit id="backend.create.info_header" approved="yes"> + <source><![CDATA[Usage Information]]></source> + <target><![CDATA[Hinweise zur Benutzung]]></target> + </trans-unit> + <trans-unit id="backend.create.markers" approved="yes"> + <source><![CDATA[Template marker]]></source> + <target><![CDATA[Template Marker]]></target> + </trans-unit> + <trans-unit id="backend.create.save" approved="yes"> + <source><![CDATA[Save]]></source> + <target><![CDATA[Speichern]]></target> + </trans-unit> + <trans-unit id="backend.create.subject" approved="yes"> + <source><![CDATA[Subject]]></source> + <target><![CDATA[Betreff]]></target> + </trans-unit> + <trans-unit id="backend.create.templateName" approved="yes"> + <source><![CDATA[Template name]]></source> + <target><![CDATA[Template Name]]></target> + </trans-unit> + <trans-unit id="backend.create_error" approved="yes"> + <source><![CDATA[Something went wrong.. Please try again!]]></source> + <target><![CDATA[Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.]]></target> + </trans-unit> + <trans-unit id="backend.create_message" approved="yes"> + <source><![CDATA[Mail template was successfully registered. You can now edit the content below.]]></source> + <target><![CDATA[Die Registrierung war erfolgreich. Sie können nun den Inhalt der Mails im Editor (siehe unten) bearbeiten.]]></target> + </trans-unit> + <trans-unit id="backend.default_extension_name" approved="yes"> + <source><![CDATA[Own templates]]></source> + <target><![CDATA[Eigene Templates]]></target> + </trans-unit> <trans-unit id="backend.delete_template" approved="yes"> <source><![CDATA[Do you really want to reset this template?]]></source> <target><![CDATA[Möchten Sie wirklich den Ursprungszustand wiederherstellen?]]></target> @@ -407,4 +455,4 @@ Die Templates declined und approved der Extension sg_comments sind für alle Dom </trans-unit> </body> </file> -</xliff> \ No newline at end of file +</xliff> diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 6a93ad88d4cab5aab3e218abd2527527d01e437f..f361e4058f6eda7caf727bc7c16edb498d425172 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -24,6 +24,9 @@ <trans-unit id="backend.blacklisted"> <source><![CDATA[Show mails from blacklisted templates]]></source> </trans-unit> + <trans-unit id="backend.button_create"> + <source><![CDATA[Register new template]]></source> + </trans-unit> <trans-unit id="backend.button_download_csv"> <source><![CDATA[Export CSV]]></source> </trans-unit> @@ -49,6 +52,48 @@ <source><![CDATA[Some template configurations have been registered in an old way and won`t work in future versions. Please register your configurations in the according ext_local_conf.php.]]></source> </trans-unit> + <trans-unit id="backend.configuration"> + <source><![CDATA[Configuration editor]]></source> + </trans-unit> + <trans-unit id="backend.content"> + <source><![CDATA[Text]]></source> + </trans-unit> + <trans-unit id="backend.create.csv"> + <source><![CDATA[Marker (csv format)]]></source> + </trans-unit> + <trans-unit id="backend.create.description"> + <source><![CDATA[Description]]></source> + </trans-unit> + <trans-unit id="backend.create.info"> + <source><![CDATA[Please insert the template marker in the following format: markerName; exampleValue; description <br /><br />Whitespaces in marker names are ignored. <br />If you have multiple markers, seperate them with a new line: markerName1; exampleValue1; description1<br />markerName2; exampleValue2; description2 <br /><br />Example: first_name; Max; The first name of the client <br />last_name; Mustermann; The last name of the client]]></source> + </trans-unit> + <trans-unit id="backend.create.info_header"> + <source><![CDATA[Usage Information]]></source> + </trans-unit> + <trans-unit id="backend.create.markers"> + <source><![CDATA[Template marker]]></source> + </trans-unit> + <trans-unit id="backend.create.save"> + <source><![CDATA[Save]]></source> + </trans-unit> + <trans-unit id="backend.create.subject"> + <source><![CDATA[Subject]]></source> + </trans-unit> + <trans-unit id="backend.create.templateName"> + <source><![CDATA[Template name]]></source> + </trans-unit> + <trans-unit id="backend.create_error"> + <source><![CDATA[Something went wrong.. Please try again!]]></source> + </trans-unit> + <trans-unit id="backend.create_message"> + <source><![CDATA[Mail template was successfully registered. You can now edit the content below.]]></source> + </trans-unit> + <trans-unit id="backend.default_extension_name"> + <source><![CDATA[Own templates]]></source> + </trans-unit> + <trans-unit id="backend.delete_template"> + <source><![CDATA[Do you really want to reset this template?]]></source> + </trans-unit> <trans-unit id="backend.description"> <source><![CDATA[Description]]></source> </trans-unit> @@ -301,4 +346,4 @@ The templates declined and approved of the sg_comments extension are blacklisted </trans-unit> </body> </file> -</xliff> \ No newline at end of file +</xliff> diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html index 124ce7a70c43bbe445cae0937409f887912c2d82..acb531dcb55fc8bd282df16db5bee5da9d4d07a9 100644 --- a/Resources/Private/Layouts/Default.html +++ b/Resources/Private/Layouts/Default.html @@ -85,7 +85,7 @@ </f:if> <f:else> <f:if condition="{mode} == 'editor'"> - <sgm:be.menus.actionMenuOptionGroup label="{extensionKey}"> + <sgm:be.menus.actionMenuOptionGroup label="{f:if(condition: '{extensionKey} == \'sg_mail\'', then: '{f:translate(key: \'backend.default_extension_name\')}', else: '{extensionKey}')}"> <f:for each="{template}" as="currentTemplate" key="templateKey"> <sgm:extendedIf condition="{selectedTemplateKey} == {templateKey}" and="{selectedExtensionKey} == {extensionKey}"> @@ -111,6 +111,7 @@ </f:be.menus.actionMenu> </f:if> </div> + <f:render section="iconButtons" /> <div class="module-docheader-bar-column-right"> <f:render partial="ButtonBar" arguments="{buttons:docHeader.buttons.right}" /> </div> diff --git a/Resources/Private/Layouts/NoMenu.html b/Resources/Private/Layouts/NoMenu.html new file mode 100644 index 0000000000000000000000000000000000000000..e8506d26186bc2ff187dfba6b3af0cb1bcf7a256 --- /dev/null +++ b/Resources/Private/Layouts/NoMenu.html @@ -0,0 +1,26 @@ +{namespace sgm=SGalinski\SgMail\ViewHelpers} +<f:be.container enableClickMenu="FALSE" loadExtJs="FALSE" includeCssFiles="{0: '{f:uri.resource(path: \'StyleSheets/backend.css\')}'}" + includeRequireJsModules="{ + 0: 'TYPO3/CMS/Backend/AjaxDataHandler', + 1: '{f:if(condition: \'{typo3Version} < 8000000 \', then: \'TYPO3/CMS/Backend/ClickMenu\', else: \'TYPO3/CMS/Backend/ContextMenu\')}', + 2: 'TYPO3/CMS/Backend/Tooltip', + 3: 'TYPO3/CMS/Backend/DateTimePicker'}"> + <sgm:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/Backend.js')}" /> + <sgm:inlineLanguageLabels labels="backend.delete_template, backend.send_mail_manually, backend.send_mail_again" /> + <div class="module" data-module-id="" data-module-name=""> + <div class="module-docheader t3js-module-docheader"> + <div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation"> + + <div class="module-docheader-bar-column-right"> + <span class="typo3-docheader-pagePath"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw></span> + <f:format.raw>{docHeader.metaInformation.recordInformation}</f:format.raw> + </div> + </div> + </div> + </div> + <div id="typo3-docbody"> + <div id="typo3-inner-docbody"> + <f:render section="content" /> + </div> + </div> +</f:be.container> diff --git a/Resources/Private/Layouts/Queue.html b/Resources/Private/Layouts/Queue.html index 8601afa9becb193526025a5c380f867ddd3063a6..7c6117e5d91714d45269b396c21bfd7cc85c2546 100644 --- a/Resources/Private/Layouts/Queue.html +++ b/Resources/Private/Layouts/Queue.html @@ -20,14 +20,14 @@ <sgm:be.menus.actionMenuItem label="{f:translate(key:'backend.mail_queue')}" controller="Queue" action="index" - additionalAttributes="{selected: 'selected'}" - arguments="{parameters: {selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}}" /> + arguments="{selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}" + additionalAttributes="{selected: 'selected'}" /> </f:then> <f:else> <sgm:be.menus.actionMenuItem label="{f:translate(key:'backend.mail_queue')}" controller="Queue" action="index" - arguments="{parameters: {selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}}" /> + arguments="{selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}" /> </f:else> </f:if> <f:if condition="{mode} == 'editor'"> @@ -35,14 +35,14 @@ <sgm:be.menus.actionMenuItem label="{f:translate(key:'backend.template_editor')}" controller="Mail" action="index" - arguments="{parameters: {selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}}" + arguments="{selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}" additionalAttributes="{selected: 'selected'}" /> </f:then> <f:else> <sgm:be.menus.actionMenuItem label="{f:translate(key:'backend.template_editor')}" controller="Mail" action="index" - arguments="{parameters: {selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}}" /> + arguments="{selectedTemplate: selectedTemplateKey, selectedExtension: selectedExtensionKey}" /> </f:else> </f:if> </f:be.menus.actionMenu> diff --git a/Resources/Private/Templates/Configuration/Index.html b/Resources/Private/Templates/Configuration/Index.html new file mode 100644 index 0000000000000000000000000000000000000000..9a4dc9456f31fefc081beb978a473e4555fba6eb --- /dev/null +++ b/Resources/Private/Templates/Configuration/Index.html @@ -0,0 +1,49 @@ +{namespace sgm=SGalinski\SgMail\ViewHelpers} +<f:layout name="NoMenu" /> + +<f:section name="iconButtons"> +</f:section> + +<f:section name="content"> + <f:flashMessages /> + <br> + + <div class="row"> + <div class="col-xs-12 col-md-10 col-md-offset-1"> + <div class="panel panel-info"> + <div class="panel-heading"> + <f:translate key="backend.create.info_header" /> + </div> + <div class="panel-body"> + <f:format.html> + <f:translate key="backend.create.info" /> + </f:format.html> + </div> + </div> + </div> + </div> + + <f:form action="create" controller="Configuration" method="post" objectName="configuration" object="{configuration}"> + <div class="row"> + <div class="col-xs-12 col-md-10 col-md-offset-1"> + <div class="form-group"> + <label for="templateName"><f:translate key="backend.create.templateName" /></label> + <f:form.textfield class="form-control" property="templateName" id="templateName" required="TRUE" /> + </div> + <div class="form-group"> + <label for="csv"><f:translate key="backend.create.csv" /></label> + <f:form.textarea rows="5" class="form-control" property="csv" id="csv" /> + </div> + <div class="form-group"> + <label for="subject"><f:translate key="backend.create.subject" /></label> + <f:form.textfield class="form-control" property="subject" id="subject" /> + </div> + <div class="form-group"> + <label for="description"><f:translate key="backend.create.description" /></label> + <f:form.textarea rows="5" class="form-control" property="description" id="description" /> + </div> + <f:form.submit class="btn-primary btn form-group col-xs-12 col-md-2 col-md-offset-10" value="{f:translate(key:'backend.create.save')}" /> + </div> + </div> + </f:form> +</f:section> diff --git a/Resources/Private/Templates/Mail/Index.html b/Resources/Private/Templates/Mail/Index.html index 4443a71724af1480841fee236f83d599e1868039..8b2a7de2fe7bf84347fd5099719fe14be31447dc 100644 --- a/Resources/Private/Templates/Mail/Index.html +++ b/Resources/Private/Templates/Mail/Index.html @@ -1,18 +1,24 @@ {namespace sgm=SGalinski\SgMail\ViewHelpers} +{namespace core=TYPO3\CMS\Core\ViewHelpers} <f:layout name="Default" /> <f:section name="iconButtons"> + + <f:link.action class="btn btn-default btn-sm" controller="Configuration" action="index" arguments="{template: selectedTemplateKey, extensionKey: selectedTemplate.extension}"> + <core:icon identifier="actions-document-new" /> + </f:link.action> </f:section> + <f:section name="content"> <f:flashMessages /> <f:if condition="{selectedTemplate}"> <f:then> - <div class="row form-group col-md-12"> - <div class="editor-description col-md-9"> + <div class="row form-group col-md-12 "> + <div class="editor-description col-md-6"> <p>{templateDescription}</p> </div> - <div class=" col-md-3"> + <div class="col-md-3 col-md-offset-3"> <f:link.action class="reset-btn reset-all-btn btn-danger btn col-md-12" action="reset" arguments="{template: selectedTemplateKey, extensionKey: selectedTemplate.extension}">{f:translate(key:'backend.button_reset_all')}</f:link.action> </div> </div> @@ -67,12 +73,16 @@ </f:for> </f:then> <f:else> - <f:translate key="{marker.value}">{marker.value}</f:translate> + <f:if condition="{marker.value}"> + <f:translate key="{marker.value}">{marker.value}</f:translate> + </f:if> </f:else> </f:if> </td> <td> - <f:translate key="{marker.description}">{marker.description}</f:translate> + <f:if condition="{marker.description}"> + <f:translate key="{marker.description}">{marker.description}</f:translate> + </f:if> </td> </tr> </f:for> diff --git a/composer.json b/composer.json index 2b213fb942ba78f71710e7b47a21976bad997d3a..4c97b7bd20c7846a94a4b46b1a6f9dced1bc746f 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "license": [ "GPL-2.0-or-later" ], - "version": "4.6.3", + "version": "4.6.4", "repositories": [ { "type": "composer", diff --git a/ext_emconf.php b/ext_emconf.php index d680c97b2060278deab35ea632b0281db627f511..bcb904a1b759564d9af6c77cf13d84714e197fc4 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ $EM_CONF['sg_mail'] = array ( 'title' => 'Mail Templates', 'description' => 'Mail Templates', 'category' => 'module', - 'version' => '4.6.3', + 'version' => '4.6.4', 'state' => 'stable', 'uploadfolder' => false, 'createDirs' => '', diff --git a/ext_localconf.php b/ext_localconf.php index 11ea6b988ce62888e60886d048697727c04b6ff9..703efd9044b69064a9b0b47f21db3869a1b0eea6 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -52,6 +52,11 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Form\Controller\FormEdi 'className' => \SGalinski\SgMail\XClass\Form\FormEditorController::class, ]; +$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Form\Controller\FormManagerController::class] = [ + 'className' => \SGalinski\SgMail\XClass\Form\FormManagerController::class, +]; + + // Cache registration $cacheName = \SGalinski\SgMail\Service\RegisterService::CACHE_NAME; if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$cacheName])) { diff --git a/ext_tables.php b/ext_tables.php index 13e821a25fd190684f0ae60d8b2e227f13d6c06f..a3137964cf470912779e3f4c07d6d93defac1642 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -12,6 +12,7 @@ if (!defined('TYPO3_MODE')) { [ 'Mail' => 'index, sendTestMail, empty, reset', 'Queue' => 'index, sendMail, export', + 'Configuration' => 'index, create', ], [ 'access' => 'user,group',