Merge branch 'develop' into feature/stimulus

This commit is contained in:
Björn Fromme
2021-09-10 10:41:38 +02:00
12 changed files with 69 additions and 114 deletions
@@ -109,7 +109,7 @@ class AjaxSearchController extends ActionController
$referringPageUri = $this $referringPageUri = $this
->uriBuilder ->uriBuilder
->reset() ->reset()
->setTargetPageUid($this->settings['defaultSearchPageUid']) ->setTargetPageUid((int)$this->settings['defaultSearchPageUid'])
->uriFor( ->uriFor(
'searchresult', 'searchresult',
['filterSettings' => $filterSettings], ['filterSettings' => $filterSettings],
@@ -358,7 +358,7 @@ class DateService implements SingletonInterface
$hotelUid = $row['hotelUid']; $hotelUid = $row['hotelUid'];
$hotelUri = $this->uriBuilder $hotelUri = $this->uriBuilder
->reset() ->reset()
->setTargetPageUid($row['hotelDetailPageUid']) ->setTargetPageUid((int)$row['hotelDetailPageUid'])
->buildFrontendUri(); ->buildFrontendUri();
if (!array_key_exists($hotelUid, $priceTable[$categoryUid])) { if (!array_key_exists($hotelUid, $priceTable[$categoryUid])) {
@@ -26,34 +26,25 @@ namespace EP\EpProducts\Service;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use Symfony\Component\Mime\Address;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;
class EmailService implements SingletonInterface class EmailService implements SingletonInterface
{ {
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/** /**
* @var array * @var array
*/ */
protected $settings; protected $settings;
/** public function __construct(ConfigurationManagerInterface $manager)
* @param ConfigurationManagerInterface $manager
*/
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
{ {
$this->configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS( $settings = GeneralUtility::removeDotsFromTS(
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) $manager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
); );
$this->settings = $settings['plugin']['tx_eptheme']; $this->settings = $settings['plugin']['tx_eptheme'];
} }
@@ -67,40 +58,17 @@ class EmailService implements SingletonInterface
{ {
$resolvedOptions = $this->resolveOptions($options); $resolvedOptions = $this->resolveOptions($options);
/** @var MailMessage $message */ /** @var FluidEmail $email */
$message = GeneralUtility::makeInstance(MailMessage::class); $email = GeneralUtility::makeInstance(FluidEmail::class);
$message $email
->setTo([$resolvedOptions['toEmail'] => $resolvedOptions['toName']]) ->to(new Address($resolvedOptions['toEmail'], $resolvedOptions['toName']))
->setFrom([$resolvedOptions['fromEmail'] => $resolvedOptions['fromName']]) ->from(new Address($resolvedOptions['fromEmail'], $resolvedOptions['fromName']))
->setSubject($resolvedOptions['subject']) ->subject($resolvedOptions['subject'])
->setTemplate($resolvedOptions['templateName'])
->assignMultiple($variables)
; ;
$view = $this->getView($resolvedOptions['templateName']); GeneralUtility::makeInstance(Mailer::class)->send($email);
$view->assignMultiple($variables);
$message->setBody($view->render(), 'text/html');
return $message->send();
}
/**
* @param string $templateName
* @param string $format
* @return StandaloneView
*/
protected function getView($templateName, $format = 'html')
{
/** @var StandaloneView $view */
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setFormat($format);
$view->setTemplateRootPaths($this->settings['view']['templateRootPaths']);
$view->setLayoutRootPaths($this->settings['view']['layoutRootPaths']);
$view->setPartialRootPaths($this->settings['view']['partialRootPaths']);
$template = GeneralUtility::getFileAbsFileName('EXT:ep_theme/Resources/Private/Templates/Email/'.$templateName.'.'.$format);
$view->setTemplatePathAndFilename($template);
return $view;
} }
/** /**
@@ -73,7 +73,7 @@ class AjaxFormController extends ActionController
$this->settings['contactFormToEmail'], $this->settings['contactFormToEmail'],
$this->settings['contactFormToName'], $this->settings['contactFormToName'],
'Kontaktformular E&P Reisen', 'Kontaktformular E&P Reisen',
'Email/ContactForm', 'ContactForm',
[ 'contactForm' => $contactForm ] [ 'contactForm' => $contactForm ]
); );
@@ -69,7 +69,7 @@ class FormController extends ActionController
return $this->uriBuilder return $this->uriBuilder
->reset() ->reset()
->setCreateAbsoluteUri(true) ->setCreateAbsoluteUri(true)
->setTargetPageUid($pageUid) ->setTargetPageUid((int)$pageUid)
->build() ->build()
; ;
} }
@@ -26,33 +26,24 @@ namespace EP\EpTheme\Service;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use TYPO3\CMS\Core\Mail\MailMessage; use Symfony\Component\Mime\Address;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;
class EmailService implements SingletonInterface class EmailService implements SingletonInterface
{ {
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/** /**
* @var array * @var array
*/ */
protected $settings; protected $settings;
/** public function __construct(ConfigurationManagerInterface $manager)
* @param ConfigurationManagerInterface $manager
*/
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
{ {
$this->configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS( $settings = GeneralUtility::removeDotsFromTS(
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) $manager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
); );
$this->settings = $settings['plugin']['tx_eptheme']; $this->settings = $settings['plugin']['tx_eptheme'];
} }
@@ -63,72 +54,49 @@ class EmailService implements SingletonInterface
* @param string $subject * @param string $subject
* @param string $templateName * @param string $templateName
* @param array $variables * @param array $variables
* @return bool
*/ */
public function send($toEmail, $toName, $subject, $templateName, array $variables = []) public function send($toEmail, $toName, $subject, $templateName, array $variables = [])
{ {
/** @var Mailer $mailer */
$mailer = GeneralUtility::makeInstance(Mailer::class);
$fromEmail = $this->settings['settings']['contactFormToEmail']; $fromEmail = $this->settings['settings']['contactFormToEmail'];
$fromName = $this->settings['settings']['contactFormToName']; $fromName = $this->settings['settings']['contactFormToName'];
$enableAutoreply = $this->settings['settings']['enableContactFormAutoreply']; $enableAutoreply = (bool)$this->settings['settings']['enableContactFormAutoreply'];
$autoreplySubject = $this->settings['settings']['contactFormAutoreplySubject']; $autoreplySubject = $this->settings['settings']['contactFormAutoreplySubject'];
/** @var MailMessage $message */ /** @var FluidEmail $message */
$message = GeneralUtility::makeInstance(MailMessage::class); $message = GeneralUtility::makeInstance(FluidEmail::class);
$message $message
->setTo([$toEmail => $toName]) ->to(new Address($toEmail, $toName))
->setFrom([$fromEmail => $fromName]) ->from(new Address($fromEmail, $fromName))
->setSubject($subject) ->format('html')
->subject($subject)
->setTemplate($templateName)
->assignMultiple($variables)
; ;
$view = $this->getView($templateName); $mailer->send($message);
$view->assignMultiple($variables);
$message->setBody($view->render(), 'text/html');
$messageSent = $message->send();
$autoreplySent = false;
if ($enableAutoreply) { if ($enableAutoreply) {
$contactForm = $variables['contactForm']; $contactForm = $variables['contactForm'];
$toEmail = $contactForm->getEmail(); $toEmail = $contactForm->getEmail();
$toName = $contactForm->getName(); $toName = $contactForm->getName();
$templateName = 'Email/Autoreply'; $templateName = 'Autoreply';
/** @var MailMessage $message */ /** @var FluidEmail $message */
$message = GeneralUtility::makeInstance(MailMessage::class); $message = GeneralUtility::makeInstance(FluidEmail::class);
$message $message
->setTo([$toEmail => $toName]) ->to(new Address($toEmail, $toName))
->setFrom([$fromEmail => $fromName]) ->from(new Address($fromEmail, $fromName))
->setSubject($autoreplySubject) ->format('html')
->subject($autoreplySubject)
->setTemplate($templateName)
->assignMultiple($variables)
; ;
$view = $this->getView($templateName); $mailer->send($message);
$view->assignMultiple($variables);
$message->setBody($view->render(), 'text/html');
$autoreplySent = $message->send();
} }
return $messageSent && $autoreplySent; return true;
} }
/**
* @param string $templateName
* @param string $format
* @return StandaloneView
*/
protected function getView($templateName, $format = 'html')
{
/** @var StandaloneView $view */
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setFormat($format);
$view->getRequest()->setControllerExtensionName('ep_events');
$view->setTemplateRootPaths($this->settings['view']['templateRootPaths']);
$view->setLayoutRootPaths($this->settings['view']['layoutRootPaths']);
$view->setPartialRootPaths($this->settings['view']['partialRootPaths']);
$view->setTemplate($templateName);
return $view;
}
} }
@@ -2,7 +2,7 @@
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
<f:layout name="Email/Default"/> <f:layout name="Default"/>
<f:section name="Main"> <f:section name="Main">
<p>Sehr geehrte Damen und Herren,</p> <p>Sehr geehrte Damen und Herren,</p>
@@ -2,7 +2,7 @@
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
<f:layout name="Email/Default"/> <f:layout name="Default"/>
<f:section name="Main"> <f:section name="Main">
<h1>Anfrage E&amp;P Reisen vom <f:format.date date="now" format="d.m.y" /></h1> <h1>Anfrage E&amp;P Reisen vom <f:format.date date="now" format="d.m.y" /></h1>
@@ -2,7 +2,7 @@
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
<f:layout name="Email/Default"/> <f:layout name="Default"/>
<f:section name="Main"> <f:section name="Main">
<h1>Anfrage Gruppenhaus vom <f:format.date date="now" format="d.m.y" /></h1> <h1>Anfrage Gruppenhaus vom <f:format.date date="now" format="d.m.y" /></h1>
@@ -23,6 +23,8 @@ $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['default'] = 'EXT:ep_theme/Configu
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['ep-reisen'] = 'EXT:ep_theme/Configuration/RTE/Default.yaml'; $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['ep-reisen'] = 'EXT:ep_theme/Configuration/RTE/Default.yaml';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['ep'] = ['EP\\EpTheme\\ViewHelpers']; $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['ep'] = ['EP\\EpTheme\\ViewHelpers'];
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['layoutRootPaths'][700] = 'EXT:ep_theme/Resources/Private/Layouts/Email/';
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['templateRootPaths'][700] = 'EXT:ep_theme/Resources/Private/Templates/Email/';
$metaTagManagerRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class); $metaTagManagerRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class);
$metaTagManagerRegistry->registerManager( $metaTagManagerRegistry->registerManager(
@@ -35,6 +35,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Site\SiteFinder;
@@ -107,9 +108,24 @@ class TrackingMiddleware implements MiddlewareInterface
$targetPage = $redirect['target_page_uid']; $targetPage = $redirect['target_page_uid'];
$responseCode = $redirect['response_code']; $responseCode = $redirect['response_code'];
// Fallback for old t3:// links
if (1 === preg_match('/^t3:\/\/page\?uid=(\d+)$/', $targetPage, $matches)) {
$targetPage = $matches[1];
}
// Skip redirecting of non-numeric page uids like full urls
if (false === is_numeric($targetPage)) {
return null;
}
/** @var SiteFinder $siteFinder */ /** @var SiteFinder $siteFinder */
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class); $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
$site = $siteFinder->getSiteByPageId($targetPage); try {
$site = $siteFinder->getSiteByPageId((int)$targetPage);
}
catch (SiteNotFoundException $exception) {
return null;
}
$params = []; $params = [];