Initial commit

This commit is contained in:
Björn Fromme
2018-04-18 17:24:00 +02:00
commit da4db35be3
875 changed files with 80368 additions and 0 deletions
@@ -0,0 +1,93 @@
<?php
namespace EP\EpTheme\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
*
* 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 EP\EpTheme\Service\EmailService;
use EP\EpTheme\Domain\Model\Dto\ContactForm;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
class AjaxFormController extends ActionController
{
/**
* @var EmailService
*/
protected $emailService;
/**
* @param EmailService $service
*/
public function injectEmailService(EmailService $service)
{
$this->emailService = $service;
}
/**
* @param ContactForm $contactForm
* @return string
*/
public function processFormAction(ContactForm $contactForm)
{
$response['status'] = 'ok';
$this->emailService->send(
$this->settings['contactFormToEmail'],
$this->settings['contactFormToName'],
'Kontaktformular E&P Reisen',
'Email/ContactForm',
[ 'contactForm' => $contactForm ]
);
return json_encode($response);
}
/**
* @return string
*/
protected function errorAction() {
$formErrors = [];
if ($this->arguments->getValidationResults()->hasErrors()) {
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $key => $errors)
{
list($formName, $fieldName) = explode('.', $key);
$errorsRaw = [];
foreach ($errors as $error)
{
$translationKey = sprintf('tx_eptheme.message.%s.%s', $key, $error->getCode());
$errorsRaw[] = LocalizationUtility::translate($translationKey, 'ep_theme');
}
$formErrors[$fieldName] = implode(', ', $errorsRaw);
}
}
$response['status'] = 'validation';
$response['errors'] = $formErrors;
return json_encode($response);
}
}
@@ -0,0 +1,76 @@
<?php
namespace EP\EpTheme\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
*
* 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 EP\EpTheme\Domain\Model\Dto\ContactForm;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class FormController extends ActionController
{
/**
* @param ContactForm $contactForm
*/
public function simpleFormAction(ContactForm $contactForm = null)
{
if ($contactForm === null) {
$pageUrl = $this->getCurrentPageUrl();
$contactForm = new ContactForm($pageUrl, ContactForm::FORM_TYPE_SIMPLE);
}
$this->view->assign('contactForm', $contactForm);
}
/**
* @param ContactForm $contactForm
*/
public function fullFormAction(ContactForm $contactForm = null)
{
if ($contactForm === null) {
$pageUrl = $this->getCurrentPageUrl();
$contactForm = new ContactForm($pageUrl, ContactForm::FORM_TYPE_FULL);
}
$this->view->assign('contactForm', $contactForm);
}
/**
* @return string
*/
private function getCurrentPageUrl()
{
if (GeneralUtility::_GET('ref')) {
$pageUid = GeneralUtility::_GET('ref');
} else {
$pageUid = $GLOBALS['TSFE']->id;
}
return $this->uriBuilder
->reset()
->setCreateAbsoluteUri(true)
->setTargetPageUid($pageUid)
->build()
;
}
}