diff --git a/Classes/Controller/QueueController.php b/Classes/Controller/QueueController.php index 5530a510b33cea9d5628665b040c5452165a1f37..0268598e7110f2aac9a326dde992cd05b7126f77 100644 --- a/Classes/Controller/QueueController.php +++ b/Classes/Controller/QueueController.php @@ -72,9 +72,6 @@ class QueueController extends ActionController { * @param int $uid */ public function sendMailAction($uid) { - /** @var Mail $mail */ - $mail = $this->mailRepository->findByUid($uid)->getFirst(); - $mailService = new MailTemplateService(); $mailService->sendMailFromQueue($uid); diff --git a/Classes/Service/MailTemplateService.php b/Classes/Service/MailTemplateService.php index f55efafb2c20b5188d7abfa41d25a73ce99cb3d7..a171820588d460d216a1e6e08ddc32e6b69d9658 100644 --- a/Classes/Service/MailTemplateService.php +++ b/Classes/Service/MailTemplateService.php @@ -44,30 +44,8 @@ use TYPO3\CMS\Fluid\View\StandaloneView; * MailTemplateService */ class MailTemplateService { - - /** - * @var string - */ const MARKER_TYPE_STRING = 'String'; - - /** - * @var string - */ - const MARKER_TYPE_DATE = 'Date'; - - /** - * @var string - */ - const MARKER_TYPE_INTEGER = 'Integer'; - - /** - * @var string - */ const MARKER_TYPE_ARRAY = 'Array'; - - /** - * @var string - */ const MARKER_TYPE_OBJECT = 'Object'; /** @@ -237,6 +215,26 @@ class MailTemplateService { ]; } + /** + * call in extlocalconf of an extension if you have a custom register class + * + * @param RegisterInterface + * + * @return bool + */ + public static function registerByFile($fileNameWithNamespace) { + $registerObject = GeneralUtility::makeInstance($fileNameWithNamespace); + // check instance of interface + if (!($registerObject instanceof RegisterInterface)) { + return FALSE; + } + + // object ruft registerTemplate auf, beinhaltet alles aus extlocalconf + $registerObject->init(); + $registerObject->registerTemplate(); + return TRUE; + } + /** * Return default markers for sg_mail * @@ -387,10 +385,10 @@ class MailTemplateService { $this->mailMessage->send(); $dateTime = new DateTime(); $this->addMailToMailQueue( - $this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, $dateTime->getTimestamp(), TRUE + $this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority, + $dateTime->getTimestamp(), TRUE ); - } else { $this->addMailToMailQueue($this->extensionKey, $this->templateName, $subject, $emailBody, $this->priority); } @@ -409,7 +407,9 @@ class MailTemplateService { * @param int $priority * @param bool $sent */ - private function addMailToMailQueue($extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE) { + private function addMailToMailQueue( + $extensionKey, $templateName, $subject, $emailBody, $priority, $sendingTime = 0, $sent = FALSE + ) { $mail = $this->objectManager->get(Mail::class); $mail->setExtensionKey($extensionKey); $mail->setTemplateName($templateName); @@ -487,7 +487,7 @@ class MailTemplateService { */ public function setCcAddresses($ccAddresses) { $this->ccAddresses = $ccAddresses; - $this->mailMessage->setCc(explode(',',$this->ccAddresses)); + $this->mailMessage->setCc(explode(',', $this->ccAddresses)); return $this; } @@ -607,4 +607,25 @@ class MailTemplateService { public function setFromName($fromName) { $this->fromName = $fromName; } + + /** + * Provides translation for the marker data type + * + * @param string $markerType + */ + public static function getReadableMarkerType($markerType) { + switch ($markerType) { + case self::MARKER_TYPE_STRING : + LocalizationUtility::translate('backend.marker.type.string', 'sg_mail'); + break; + case self::MARKER_TYPE_ARRAY : + LocalizationUtility::translate('backend.marker.type.array', 'sg_mail'); + break; + case self::MARKER_TYPE_OBJECT : + LocalizationUtility::translate('backend.marker.type.object', 'sg_mail'); + break; + default: + LocalizationUtility::translate('backend.marker.type.mixed', 'sg_mail'); + } + } } diff --git a/Classes/Service/RegisterInterface.php b/Classes/Service/RegisterInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..1efb57f91e53479034f11c8d58b2ccd76d7dbcb2 --- /dev/null +++ b/Classes/Service/RegisterInterface.php @@ -0,0 +1,52 @@ +<?php + +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! + ***************************************************************/ + +/** + * Interface RegisterInterface + * describes behaviour of objects that want to register a template with sg_mail + * + * @package SGalinski\SgMail\Service + */ +interface RegisterInterface { + + /** + * initialize certain values + * + * @return mixed + */ + public function init(); + + /** + * call MailTemplateService registerTemplate with according values + * + * @return mixed + */ + public function registerTemplate(); +} + +?> \ No newline at end of file diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 15f1d1ac4673e90524699b11c6d0c968dd0dea21..a057ae3d38647d2a1f302964d7c53eae2a8a135c 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -9,120 +9,129 @@ <authorEmail>torsten@sgalinski.de</authorEmail> </header> <body> - <trans-unit id="backend.bcc"> - <source>Bcc (Comma separated if multiple):</source> - </trans-unit> - <trans-unit id="backend.button_reset"> - <source>Reset Template</source> - </trans-unit> - <trans-unit id="backend.button_reset_all"> - <source>Reset all</source> - </trans-unit> - <trans-unit id="backend.cc"> - <source>cc (Comma separated if multiple):</source> - </trans-unit> - <trans-unit id="backend.content"> - <source>Text</source> - </trans-unit> - <trans-unit id="backend.delete_template"> - <source>Do you really want to reset this Template ?</source> - </trans-unit> - <trans-unit id="backend.description"> - <source>Description</source> - </trans-unit> - <trans-unit id="backend.email"> - <source>Email</source> - </trans-unit> - <trans-unit id="backend.failure_mail"> - <source>There was an error when sending the Preview Email. Please check your Configuration</source> - </trans-unit> - <trans-unit id="backend.fromAddress"> - <source>From</source> - </trans-unit> - <trans-unit id="backend.fromMail"> - <source>From E-Mail Address:</source> - </trans-unit> - <trans-unit id="backend.fromName"> - <source>From Name:</source> - </trans-unit> - <trans-unit id="backend.mail_queue"> - <source>Mail Queue</source> - </trans-unit> - <trans-unit id="backend.marker"> - <source>Marker</source> - </trans-unit> - <trans-unit id="backend.no_extension"> - <source>No Extension was registered</source> - </trans-unit> - <trans-unit id="backend.not_sent"> - <source>Not Sent</source> - </trans-unit> - <trans-unit id="backend.priority"> - <source>Priority</source> - </trans-unit> - <trans-unit id="backend.replyTo"> - <source>Reply to:</source> - </trans-unit> - <trans-unit id="backend.save"> - <source>Save</source> - </trans-unit> - <trans-unit id="backend.select_language"> - <source>Language (Reloads the page):</source> - </trans-unit> - <trans-unit id="backend.send_mail_again"> - <source>Send this E-Mail again ?</source> - </trans-unit> - <trans-unit id="backend.send_mail_manually"> - <source>Send this E-Mail now ?</source> - </trans-unit> - <trans-unit id="backend.send_test"> - <source>Send Preview Mail</source> - </trans-unit> - <trans-unit id="backend.sending_time"> - <source>Sending Time</source> - </trans-unit> - <trans-unit id="backend.sent"> - <source>Sent</source> - </trans-unit> - <trans-unit id="backend.subject"> - <source>Subject:</source> - </trans-unit> - <trans-unit id="backend.success"> - <source>Successfully saved !</source> - </trans-unit> - <trans-unit id="backend.success_mail"> - <source>Preview Email sent</source> - </trans-unit> - <trans-unit id="backend.template_editor"> - <source>Template Editor</source> - </trans-unit> - <trans-unit id="backend.template_path"> - <source>Template Path:</source> - </trans-unit> - <trans-unit id="backend.template_reset"> - <source>Template was resetted succesfully</source> - </trans-unit> - <trans-unit id="backend.toAddress"> - <source>To</source> - </trans-unit> - <trans-unit id="backend.type"> - <source>Type</source> - </trans-unit> - <trans-unit id="backend.value"> - <source>Value</source> - </trans-unit> - <trans-unit id="mlang_labels_tabdescr"> - <source>Mail Templates</source> - </trans-unit> - <trans-unit id="mlang_labels_tablabel"> - <source>Mail Templates</source> - </trans-unit> - <trans-unit id="mlang_tabs_tab"> - <source>Mail Templates</source> - </trans-unit> - <trans-unit id="registeredExtension.action.message"> - <source>Extension</source> - </trans-unit> + <trans-unit id="backend.bcc"> + <source>Bcc (Comma separated if multiple):</source> + </trans-unit> + <trans-unit id="backend.button_reset"> + <source>Reset Template</source> + </trans-unit> + <trans-unit id="backend.button_reset_all"> + <source>Reset all</source> + </trans-unit> + <trans-unit id="backend.cc"> + <source>cc (Comma separated if multiple):</source> + </trans-unit> + <trans-unit id="backend.content"> + <source>Text</source> + </trans-unit> + <trans-unit id="backend.delete_template"> + <source>Do you really want to reset this Template ?</source> + </trans-unit> + <trans-unit id="backend.description"> + <source>Description</source> + </trans-unit> + <trans-unit id="backend.email"> + <source>Email</source> + </trans-unit> + <trans-unit id="backend.failure_mail"> + <source>There was an error when sending the Preview Email. Please check your Configuration</source> + </trans-unit> + <trans-unit id="backend.fromAddress"> + <source>From</source> + </trans-unit> + <trans-unit id="backend.fromMail"> + <source>From E-Mail Address:</source> + </trans-unit> + <trans-unit id="backend.fromName"> + <source>From Name:</source> + </trans-unit> + <trans-unit id="backend.mail_queue"> + <source>Mail Queue</source> + </trans-unit> + <trans-unit id="backend.marker"> + <source>Marker</source> + </trans-unit> + <trans-unit id="backend.no_extension"> + <source>No Extension was registered</source> + </trans-unit> + <trans-unit id="backend.not_sent"> + <source>Not Sent</source> + </trans-unit> + <trans-unit id="backend.priority"> + <source>Priority</source> + </trans-unit> + <trans-unit id="backend.replyTo"> + <source>Reply to:</source> + </trans-unit> + <trans-unit id="backend.save"> + <source>Save</source> + </trans-unit> + <trans-unit id="backend.select_language"> + <source>Language (Reloads the page):</source> + </trans-unit> + <trans-unit id="backend.send_mail_again"> + <source>Send this E-Mail again ?</source> + </trans-unit> + <trans-unit id="backend.send_mail_manually"> + <source>Send this E-Mail now ?</source> + </trans-unit> + <trans-unit id="backend.send_test"> + <source>Send Preview Mail</source> + </trans-unit> + <trans-unit id="backend.sending_time"> + <source>Sending Time</source> + </trans-unit> + <trans-unit id="backend.sent"> + <source>Sent</source> + </trans-unit> + <trans-unit id="backend.subject"> + <source>Subject:</source> + </trans-unit> + <trans-unit id="backend.success"> + <source>Successfully saved !</source> + </trans-unit> + <trans-unit id="backend.marker.type.string"> + <source>String</source> + </trans-unit> + <trans-unit id="backend.marker.type.array"> + <source>Array</source> + </trans-unit> + <trans-unit id="backend.marker.type.object"> + <source>Object</source> + </trans-unit> + <trans-unit id="backend.success_mail"> + <source>Preview Email sent</source> + </trans-unit> + <trans-unit id="backend.template_editor"> + <source>Template Editor</source> + </trans-unit> + <trans-unit id="backend.template_path"> + <source>Template Path:</source> + </trans-unit> + <trans-unit id="backend.template_reset"> + <source>Template was resetted succesfully</source> + </trans-unit> + <trans-unit id="backend.toAddress"> + <source>To</source> + </trans-unit> + <trans-unit id="backend.type"> + <source>Type</source> + </trans-unit> + <trans-unit id="backend.value"> + <source>Value</source> + </trans-unit> + <trans-unit id="mlang_labels_tabdescr"> + <source>Mail Templates</source> + </trans-unit> + <trans-unit id="mlang_labels_tablabel"> + <source>Mail Templates</source> + </trans-unit> + <trans-unit id="mlang_tabs_tab"> + <source>Mail Templates</source> + </trans-unit> + <trans-unit id="registeredExtension.action.message"> + <source>Extension</source> + </trans-unit> </body> </file> </xliff> \ No newline at end of file