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,78 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Model\Activity;
use EP\EpEvents\Domain\Repository\ActivityRepository;
use EP\EpEvents\Domain\Repository\OfferRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class ActivityController extends ActionController
{
/**
* @var ActivityRepository
*/
protected $activityRepository;
/**
* @var OfferRepository
*/
protected $offerRepository;
/**
* @param ActivityRepository $activityRepository
* @param OfferRepository $offerRepository
*/
public function __construct(ActivityRepository $activityRepository, OfferRepository $offerRepository)
{
parent::__construct();
$this->activityRepository = $activityRepository;
$this->offerRepository = $offerRepository;
}
public function listAction()
{
$configuration = ['activityType' => $this->settings['activityType']];
$content = $this->configurationManager->getContentObject()->data;
$activities = $this->activityRepository->findByConfiguratorType($configuration['activityType']);
$this->view->assign('activities', $activities);
$this->view->assign('configuration', $configuration);
$this->view->assign('content', $content);
}
/**
* @param Activity $activity
*/
public function detailAction(Activity $activity)
{
$offers = $this->offerRepository->findByActivity($activity);
$this->view->assign('activity', $activity);
$this->view->assign('offers', $offers);
}
}
@@ -0,0 +1,111 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Model\Inquiry;
use EP\EpEvents\Service\EmailService;
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 Inquiry $inquiry
*
* @return string
*/
public function processInquiryFormAction(Inquiry $inquiry)
{
$response['status'] = 'ok';
$this->emailService->send(
$this->settings['inquiryToEmail'],
$this->settings['inquiryToName'],
'Anfrage E&P Events',
'Email/Inquiry',
[ 'inquiry' => $inquiry ]
);
return json_encode($response);
}
/**
* @param Inquiry $inquiry
*
* @return string
*/
public function processConfiguratorFormAction(Inquiry $inquiry)
{
$response['status'] = 'ok';
$this->emailService->send(
$this->settings['inquiryToEmail'],
$this->settings['inquiryToName'],
'Anfrage E&P Events',
'Email/Configurator',
[ 'inquiry' => $inquiry ]
);
return json_encode($response);
}
/**
* @return string
*/
protected function errorAction() {
$formErrors = [];
if ($this->arguments->getValidationResults()->hasErrors()) {
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $key => $errors)
{
$key = str_replace('.', '', $key);
$errorsRaw = [];
foreach ($errors as $error)
{
$translationKey = sprintf('tx_epevents.message.%s.%s', $key, $error->getCode());
$errorsRaw[] = LocalizationUtility::translate($translationKey, 'ep_events');
}
$formErrors[$key] = implode(', ', $errorsRaw);
}
}
$response['status'] = 'validation';
$response['errors'] = $formErrors;
return json_encode($response);
}
}
@@ -0,0 +1,56 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Repository\ContactRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class ContactController extends ActionController
{
/**
* @var ContactRepository
*/
protected $contactRepository;
/**
* @param ContactRepository $contactRepository
*/
public function injectContactRepository(ContactRepository $contactRepository)
{
$this->contactRepository = $contactRepository;
}
public function listAction()
{
$contacts = $this->contactRepository->findAll();
$content = $this->configurationManager->getContentObject()->data;
$this->view->assign('contacts', $contacts);
$this->view->assign('content', $content);
}
}
@@ -0,0 +1,103 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Model\Inquiry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class FormController extends ActionController
{
public function inquiryFormAction()
{
$inquiry = $this->getInquiryFromContext();
$this->view->assign('inquiry', $inquiry);
}
/**
* @param int $travelType
* @param int $locationType
*/
public function contactFormAction($travelType = 0, $locationType = 0)
{
$inquiry = Inquiry::fromArguments($travelType, $locationType);
$pageUrl = $this->getCurrentPageUrl();
$inquiry->setPageUrl($pageUrl);
$this->view->assign('inquiry', $inquiry);
}
public function configuratorAction()
{
$inquiry = $this->getInquiryFromContext();
$this->view->assign('inquiry', $inquiry);
}
/**
* @return Inquiry
*/
protected function getInquiryFromContext()
{
$content = $this->configurationManager->getContentObject()->data;
$defaults = $this->settings['configurator']['defaults'];
if (isset($content['offer'])) {
$offer = $content['offer'];
$inquiry = Inquiry::fromOffer($offer, $defaults);
} elseif (isset($content['travelType'])) {
/** @var \EP\EpEvents\Domain\Model\Traveltype $travelType */
$travelType = $content['travelType'];
$inquiryName = $this->settings['configurator']['options']['travelType'][$travelType->getConfiguratorType()];
$inquiry = Inquiry::fromTraveltype($travelType, $inquiryName, $defaults);
} elseif (isset($content['activityType'])) {
$inquiry = new Inquiry($defaults);
$inquiry->setActivityType($content['activityType']);
} else {
$inquiry = new Inquiry($defaults);
}
$pageUrl = $this->getCurrentPageUrl();
$inquiry->setPageUrl($pageUrl);
return $inquiry;
}
/**
* @return string
*/
protected function getCurrentPageUrl()
{
if (GeneralUtility::_GET('ref')) {
$pageUid = GeneralUtility::_GET('ref');
} else {
$pageUid = $GLOBALS['TSFE']->id;
}
return $this->uriBuilder
->reset()
->setCreateAbsoluteUri(true)
->setTargetPageUid($pageUid)
->build()
;
}
}
@@ -0,0 +1,81 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Model\Offer;
use EP\EpEvents\Domain\Repository\OfferRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class OfferController extends ActionController
{
/**
* @var OfferRepository
*/
protected $offerRepository;
/**
* @param OfferRepository $offerRepository
*/
public function __construct(OfferRepository $offerRepository)
{
parent::__construct();
$this->offerRepository = $offerRepository;
}
public function teaserAction()
{
$content = $this->configurationManager->getContentObject()->data;
$configuration = [
'travelType' => isset($this->settings['travelType']) ? $this->settings['travelType'] : $content['travelType'],
'locationType' => isset($this->settings['locationType']) ? $this->settings['locationType'] : $content['locationType'],
'locationDistance' => isset($this->settings['locationDistance']) ? $this->settings['locationDistance'] : $content['locationDistance'],
'hotelType' => isset($this->settings['hotelType']) ? $this->settings['hotelType'] : $content['hotelType'],
'activityType' => isset($this->settings['activityType']) ? $this->settings['activityType'] : $content['activityType'],
'offerUid' => isset($content['offerUid']) ? $content['offerUid'] : null,
];
$offers = $this->offerRepository->findByConfiguration($configuration);
$this->view->assign('offers', $offers);
$this->view->assign('configuration', $configuration);
$this->view->assign('content', $content);
}
/**
* @param Offer $offer
*/
public function detailAction(Offer $offer = null)
{
if ($offer === null) {
$pageUid = $GLOBALS['TSFE']->id;
$offer = $this->offerRepository->findByDetailPage($pageUid)->getFirst();
}
$search = GeneralUtility::_GET('search');
$this->view->assign('offer', $offer);
$this->view->assign('search', $search);
}
}
@@ -0,0 +1,108 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Model\Search;
use EP\EpEvents\Domain\Repository\OfferRepository;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class SearchController extends ActionController
{
/**
* @var OfferRepository
*/
protected $offerRepository;
/**
* @param OfferRepository $offerRepository
*/
public function __construct(OfferRepository $offerRepository)
{
parent::__construct();
$this->offerRepository = $offerRepository;
}
/**
* @param Search $search
*/
public function formAction(Search $search = null)
{
if ($search === null) {
$search = new Search(null, $GLOBALS['TSFE']->id);
}
$this->view->assign('search', $search);
}
public function initializeResultAction()
{
$query = GeneralUtility::_GET('search');
if ($query) {
$search = new Search($query);
$this->request->setArgument('search', $search);
}
}
/**
* @param Search $search
*/
public function resultAction(Search $search = null)
{
if ($search === null) {
$this->redirectToUri('/');
}
$result = null;
$searchValid = strlen($search->getQuery()) >= 3;
if ($searchValid) {
$this->logSearch($search);
$result = $this->offerRepository->search($search->getQuery());
}
$this->view->assign('searchValid', $searchValid);
$this->view->assign('result', $result);
$this->view->assign('search', $search);
}
/**
* @param Search $search
*/
private function logSearch(Search $search)
{
$ignoreIps = GeneralUtility::trimExplode(',', $this->settings['searchLogIgnoreIps'], true);
$remoteIp = GeneralUtility::getIndpEnv('REMOTE_ADDR');
if (in_array($remoteIp, $ignoreIps)) {
return;
}
/** @var $logger \TYPO3\CMS\Core\Log\Logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
$logger->info('Searchresult processed', [
'search' => $search->getQuery(),
'pageUid' => $search->getPageUid(),
]);
}
}
@@ -0,0 +1,56 @@
<?php
namespace EP\EpEvents\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2017 Björn Fromme <[email protected]>, dreipunktnull
* Cedric Ziel <[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\EpEvents\Domain\Repository\TestimonialRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class TestimonialController extends ActionController
{
/**
* @var TestimonialRepository
*/
protected $testimonialRepository;
/**
* @param TestimonialRepository $testimonialRepository
*/
public function injectTestimonialRepository(TestimonialRepository $testimonialRepository)
{
$this->testimonialRepository = $testimonialRepository;
}
public function listAction()
{
$testimonials = $this->testimonialRepository->findAll();
$content = $this->configurationManager->getContentObject()->data;
$this->view->assign('testimonials', $testimonials);
$this->view->assign('content', $content);
}
}