Upgrade to TYPO3 9.5 LTS

This commit is contained in:
Björn Fromme
2019-06-06 17:20:29 +02:00
parent adab7fb39a
commit 3c472eb973
989 changed files with 4924 additions and 3674 deletions
+1
View File
@@ -0,0 +1 @@
deny from all
@@ -0,0 +1,94 @@
<?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 $emailService
*/
public function __construct(EmailService $emailService)
{
parent::__construct();
$this->emailService = $emailService;
}
/**
* @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->validate()->hasErrors()) {
foreach ($this->arguments->validate()->getFlattenedErrors() as $key => $errors)
{
[ $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()
;
}
}
@@ -0,0 +1,150 @@
<?php
namespace EP\EpTheme\DataProcessing;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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\EpProducts\Service\ResellerDataService;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class ContextProcessor implements DataProcessorInterface
{
use DbConnectionTrait;
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
$data = $cObj->data;
$processedData['context'] = [];
$countryUid = (int) $data['tx_eptheme_context_country'];
if ($countryUid > 0) {
$processedData['context']['country'] = $this->getContextRecord($countryUid, 'tx_epproducts_domain_model_country');
}
$regionUid = (int) $data['tx_eptheme_context_region'];
if ($regionUid > 0) {
$processedData['context']['region'] = $this->getContextRecord($regionUid, 'tx_epproducts_domain_model_region');
}
$resellerData = $this->getResellerData();
if ($resellerData) {
$processedData['context']['paCode'] = $resellerData['paCode'];
} elseif ($paCode = $this->getPaCodeFromRequest()) {
$processedData['context']['paCode'] = $paCode;
} elseif ($cookieData = $this->getCookieData()) {
$processedData['context']['paCode'] = $cookieData;
}
return $processedData;
}
/**
* @return array|bool
* @throws \Doctrine\DBAL\DBALException
*/
private function getResellerData()
{
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var ResellerDataService $resellerService */
$resellerService = $objectManager->get(ResellerDataService::class);
return $resellerService->getResellerForCurrentDomain();
}
/**
* @return string
*/
private function getPaCodeFromRequest()
{
$currentUri = GeneralUtility::getIndpEnv('REQUEST_URI');
$query = parse_url($currentUri, \PHP_URL_QUERY);
if (!$query) {
return '';
}
parse_str($query, $items);
if (array_key_exists('pa', $items)) {
$paCode = $items['pa'];
$expiratonDate = new \DateTime('now');
$expiratonDate->add(new \DateInterval('P' . '30D'));
setcookie('ep_trk', $paCode, $expiratonDate->getTimestamp(), '/');
return $paCode;
}
return '';
}
/**
* @return string
*/
private function getCookieData()
{
if ($_COOKIE['ep_trk']) {
return $_COOKIE['ep_trk'];
}
return '';
}
/**
* @param int $uid
* @param string $table
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
private function getContextRecord($uid, $table)
{
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('*')
->from($table)
->where('uid = :uid')
->andWhere('deleted = 0')
->andWhere('hidden = 0')
->setParameter('uid', $uid)
;
return $query->execute()->fetch();
}
}
@@ -0,0 +1,61 @@
<?php
namespace EP\EpTheme\DataProcessing;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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 TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class FlexFormProcessor implements DataProcessorInterface
{
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
*
* @return array
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
$data = $cObj->data;
if (array_key_exists('pi_flexform', $data)) {
/** @var \TYPO3\CMS\Extbase\Service\FlexFormService $flexFormService */
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
$processedData['data']['flexForm'] = $flexFormService->convertFlexFormContentToArray($data['pi_flexform']);
}
return $processedData;
}
}
@@ -0,0 +1,114 @@
<?php
namespace EP\EpTheme\DataProcessing;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class SliderProcessor implements DataProcessorInterface
{
use DbConnectionTrait;
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
$page = $cObj->data;
$pageUid = $page['uid'];
if ((int) $page['tx_eptheme_slides'] === 0) {
$pageUid = $this->getParentPageWithSlides();
}
if ($pageUid === null) {
return $processedData;
}
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('uid', 'headline', 'subline', 'button', 'page_uid')
->from('tx_eptheme_domain_model_slide')
->where('page = :pageUid')
->andWhere('deleted = 0')
->andWhere('hidden = 0')
->orderBy('sorting')
->setParameter('pageUid', $pageUid)
;
$slides = $query->execute()->fetchAll();
if ($slides) {
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
foreach ($slides as $slide)
{
$processedData['slides'][$slide['uid']] = $slide;
$processedData['slides'][$slide['uid']]['image'] = $fileRepository->findByRelation(
'tx_eptheme_domain_model_slide',
'images',
$slide['uid']
);
}
}
return $processedData;
}
/**
* @return null|int
*/
protected function getParentPageWithSlides()
{
$rootlineUtility = new RootlineUtility($GLOBALS['TSFE']->id);
$rootline = $rootlineUtility->get();
foreach ($rootline as $parentPage)
{
if ((int) $parentPage['tx_eptheme_slides'] > 0) {
return (int) $parentPage['uid'];
}
}
return null;
}
}
@@ -0,0 +1,59 @@
<?php
namespace EP\EpTheme\DataProcessing;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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 TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
use TYPO3\CMS\Frontend\Resource\FileCollector;
class TeaserImageProcessor implements DataProcessorInterface
{
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
*
* @return array
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
$imageFileCollector = GeneralUtility::makeInstance(FileCollector::class);
$imageFileCollector->addFilesFromRelation('tt_content', 'assets', $cObj->data);
$processedData['teaserImage'] = reset($imageFileCollector->getFiles());
return $processedData;
}
}
@@ -0,0 +1,129 @@
<?php
namespace EP\EpTheme\DataProcessing;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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\EpProducts\Domain\Model\FilterSettings;
use EP\EpProducts\Domain\Repository\CityRepository;
use EP\EpProducts\Domain\Repository\ConceptRepository;
use EP\EpProducts\Domain\Repository\CountryRepository;
use EP\EpProducts\Domain\Repository\RegionRepository;
use EP\EpProducts\Service\HotelDataService;
use EP\EpProducts\Service\ProductDataService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class TeaserProcessor implements DataProcessorInterface
{
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
*
* @return array
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
if ((int) $processedData['data']['tx_eptheme_context_city'] > 0) {
/** @var \EP\EpProducts\Domain\Repository\CityRepository $repository */
$repository = $objectManager->get(CityRepository::class);
/** @var \EP\EpProducts\Domain\Model\City $city */
$city = $repository->findByIdentifier($processedData['data']['tx_eptheme_context_city']);
$processedData['city'] = $city;
}
if ((int) $processedData['data']['tx_eptheme_context_region'] > 0) {
/** @var \EP\EpProducts\Domain\Repository\RegionRepository $repository */
$repository = $objectManager->get(RegionRepository::class);
/** @var \EP\EpProducts\Domain\Model\Region $region */
$region = $repository->findByIdentifier($processedData['data']['tx_eptheme_context_region']);
$processedData['region'] = $region;
}
if ((int) $processedData['data']['tx_eptheme_context_country'] > 0) {
/** @var \EP\EpProducts\Domain\Repository\CountryRepository $repository */
$repository = $objectManager->get(CountryRepository::class);
/** @var \EP\EpProducts\Domain\Model\Country $country */
$country = $repository->findByIdentifier($processedData['data']['tx_eptheme_context_country']);
$processedData['country'] = $country;
}
if ((int) $processedData['data']['tx_eptheme_context_hotel'] > 0) {
/** @var \EP\EpProducts\Service\HotelDataService $service */
$service = $objectManager->get(HotelDataService::class);
/** @var array $hotel */
$hotel = $service->getTeaser($processedData['data']['tx_eptheme_context_hotel']);
$processedData['hotel'] = $hotel;
}
if ((int) $processedData['data']['tx_eptheme_context_concept'] > 0) {
/** @var \EP\EpProducts\Domain\Repository\ConceptRepository $repository */
$repository = $objectManager->get(ConceptRepository::class);
/** @var \EP\EpProducts\Domain\Model\Concept $concept */
$concept = $repository->findByIdentifier($processedData['data']['tx_eptheme_context_concept']);
$processedData['concept'] = $concept;
}
if ((int) $processedData['data']['tx_eptheme_context_product'] > 0) {
$productUid = (int) $processedData['data']['tx_eptheme_context_product'];
$hotelUid = (int) $processedData['data']['tx_eptheme_context_hotel'];
$filterSettings = new FilterSettings();
$filterSettings->setProductUid($productUid);
$filterSettings->setHotelUid($hotelUid);
$dateFromTimestamp = (int) $processedData['data']['tx_eptheme_context_date_from'];
if ($dateFromTimestamp > 0) {
$dateFrom = new \DateTime();
$dateFrom->setTimestamp($dateFromTimestamp);
$filterSettings->setDateFrom($dateFrom);
}
$dateToTimestamp = (int) $processedData['data']['tx_eptheme_context_date_to'];
if ($dateToTimestamp > 0) {
$dateTo = new \DateTime();
$dateTo->setTimestamp($dateToTimestamp);
$filterSettings->setDateTo($dateTo);
}
/** @var \EP\EpProducts\Service\ProductDataService $productDataService */
$productDataService = $objectManager->get(ProductDataService::class);
$processedData['teaser'] = $productDataService->getTeaser($filterSettings);
$processedData['teaser']['forceHotelUid'] = $hotelUid;
}
$processedData['referringPageUid'] = $GLOBALS['TSFE']->id;
return $processedData;
}
}
@@ -0,0 +1,284 @@
<?php
namespace EP\EpTheme\Domain\Model\Dto;
/***************************************************************
*
* 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!
***************************************************************/
class ContactForm
{
const FORM_TYPE_SIMPLE = 1;
const FORM_TYPE_FULL = 2;
/**
* @var int
*/
protected $formType = 1;
/**
* @var string
* @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
*/
protected $name;
/**
* @var string
*/
protected $company;
/**
* @var string
* @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
* @TYPO3\CMS\Extbase\Annotation\Validate("EmailAddress")
*/
protected $email;
/**
* @var string
* @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
*/
protected $phone;
/**
* @var string
*/
protected $period;
/**
* @var string
*/
protected $duration;
/**
* @var string
*/
protected $pax;
/**
* @var string
*/
protected $age;
/**
* @var string
*/
protected $children;
/**
* @var string
*/
protected $inquiry;
/**
* @var string
*/
protected $pageUrl;
/**
* @param string $pageUrl
* @param int $formType
*/
public function __construct($pageUrl = null, $formType = 1)
{
$this->pageUrl = $pageUrl;
$this->formType = $formType;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getCompany()
{
return $this->company;
}
/**
* @param string $company
*/
public function setCompany($company)
{
$this->company = $company;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @return string
*/
public function getPeriod()
{
return $this->period;
}
/**
* @param string $period
*/
public function setPeriod($period)
{
$this->period = $period;
}
/**
* @return string
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param string $duration
*/
public function setDuration($duration)
{
$this->duration = $duration;
}
/**
* @return string
*/
public function getPax()
{
return $this->pax;
}
/**
* @param string $pax
*/
public function setPax($pax)
{
$this->pax = $pax;
}
/**
* @return string
*/
public function getAge()
{
return $this->age;
}
/**
* @param string $age
*/
public function setAge($age)
{
$this->age = $age;
}
/**
* @return string
*/
public function getChildren()
{
return $this->children;
}
/**
* @param string $children
*/
public function setChildren($children)
{
$this->children = $children;
}
/**
* @return string
*/
public function getInquiry()
{
return $this->inquiry;
}
/**
* @param string $inquiry
*/
public function setInquiry($inquiry)
{
$this->inquiry = $inquiry;
}
/**
* @return string
*/
public function getPageUrl()
{
return $this->pageUrl;
}
/**
* @param string $pageUrl
*/
public function setPageUrl($pageUrl)
{
$this->pageUrl = $pageUrl;
}
}
@@ -0,0 +1,132 @@
<?php
namespace EP\EpTheme\Hook;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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 TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\PageLayoutView as CorePageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
class PageLayoutView implements PageLayoutViewDrawItemHookInterface
{
/**
* @param CorePageLayoutView $parentObject
* @param bool $drawItem
* @param string $headerContent
* @param string $itemContent
* @param array $row
*/
public function preProcess(CorePageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
{
switch ($row['CType'])
{
case 'teaser_country':
if ((int) $row['tx_eptheme_context_country'] > 0) {
$drawItem = false;
$country = BackendUtility::getRecord('tx_epproducts_domain_model_country', $row['tx_eptheme_context_country']);
$itemContent = '<strong>Teaser Land</strong><br />' . $country['name'];
}
break;
case 'teaser_region':
if ((int) $row['tx_eptheme_context_region'] > 0) {
$drawItem = false;
$region = BackendUtility::getRecord('tx_epproducts_domain_model_region', $row['tx_eptheme_context_region']);
$itemContent = '<strong>Teaser Gebiet</strong><br />' . $region['name'];
}
break;
case 'teaser_city':
if ((int) $row['tx_eptheme_context_city'] > 0) {
$drawItem = false;
$city = BackendUtility::getRecord('tx_epproducts_domain_model_city', $row['tx_eptheme_context_city']);
$itemContent = '<strong>Teaser Ort</strong><br />' . $city['name'];
}
break;
case 'teaser_hotel':
if ((int) $row['tx_eptheme_context_hotel'] > 0) {
$drawItem = false;
$hotel = BackendUtility::getRecord('tx_epproducts_domain_model_hotel', $row['tx_eptheme_context_hotel']);
$itemContent = '<strong>Teaser Hotel</strong><br />' . $hotel['name'];
}
break;
case 'teaser_concept':
if ((int) $row['tx_eptheme_context_concept'] > 0) {
$drawItem = false;
$concept = BackendUtility::getRecord('tx_epproducts_domain_model_concept', $row['tx_eptheme_context_concept']);
$itemContent = '<strong>Teaser Konzept</strong><br />' . $concept['name'];
}
break;
case 'teaser_product':
if ((int) $row['tx_eptheme_context_product'] > 0) {
$drawItem = false;
$product = BackendUtility::getRecord('tx_epproducts_domain_model_product', $row['tx_eptheme_context_product']);
$itemContent = '<strong>Teaser Product</strong><br />' . $product['name'];
if ((int) $row['tx_eptheme_context_hotel'] > 0) {
$hotel = BackendUtility::getRecord('tx_epproducts_domain_model_hotel',
$row['tx_eptheme_context_hotel']);
$itemContent .= ', ' . $hotel['name'];
}
}
break;
case 'gmap':
if ((int) $row['tx_eptheme_context_region'] > 0) {
$drawItem = false;
$region = BackendUtility::getRecord('tx_epproducts_domain_model_region', $row['tx_eptheme_context_region']);
$itemContent = '<strong>Google Map</strong><br />' . $region['name'];
} elseif ((int) $row['tx_eptheme_context_hotel'] > 0) {
$drawItem = false;
$hotel = BackendUtility::getRecord('tx_epproducts_domain_model_hotel', $row['tx_eptheme_context_hotel']);
$itemContent = '<strong>Google Map</strong><br />' . $hotel['name'];
}
break;
case 'disturber':
$drawItem = false;
switch ($row['layout'])
{
case 1:
$size = 'groß';
break;
case 2:
$size = 'Event klein';
break;
case 3:
$size = 'Event groß';
break;
default:
$size = 'klein';
}
$itemContent = '<strong>Störer ' . $size . '</strong>';
break;
case 'lineup':
$drawItem = false;
$itemContent = '<strong>Lineup</strong><br />' . $row['tx_eptheme_lineup'] . ' Einträge';
break;
default:
}
}
}
@@ -0,0 +1,62 @@
<?php
namespace EP\EpTheme\Hook;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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 TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
class Tcemain
{
/**
* @param array $fields
* @param string $table
* @param int $id
* @param DataHandler $dataHandler
*/
public function processDatamap_preProcessFieldArray(array &$fields, $table, $id, DataHandler $dataHandler)
{
// Get country code from associated country entity and store in page record
if ($table === 'pages') {
$countryUid = (int) $fields['tx_eptheme_context_country'];
if ($countryUid === 0) {
$fields['tx_eptheme_context_country_code'] = '';
} else {
$country = BackendUtility::getRecord('tx_epproducts_domain_model_country', $countryUid);
if ($country !== null) {
$fields['tx_eptheme_context_country_code'] = $country['code'];
}
}
}
// Force unused colPos for content elements appended to news records
if ($table === 'tt_content') {
if (isset($dataHandler->datamap['tx_news_domain_model_news'])) {
$fields['colPos'] = 1848;
}
}
}
}
@@ -0,0 +1,134 @@
<?php
namespace EP\EpTheme\Service;
/***************************************************************
*
* 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 TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;
class EmailService implements SingletonInterface
{
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @var array
*/
protected $settings;
/**
* @param ConfigurationManagerInterface $manager
*/
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
{
$this->configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS(
$this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
);
$this->settings = $settings['plugin']['tx_eptheme'];
}
/**
* @param string $toEmail
* @param string $toName
* @param string $subject
* @param string $templateName
* @param array $variables
* @return bool
*/
public function send($toEmail, $toName, $subject, $templateName, array $variables = [])
{
$fromEmail = $this->settings['settings']['contactFormToEmail'];
$fromName = $this->settings['settings']['contactFormToName'];
$enableAutoreply = $this->settings['settings']['enableContactFormAutoreply'];
$autoreplySubject = $this->settings['settings']['contactFormAutoreplySubject'];
/** @var MailMessage $message */
$message = GeneralUtility::makeInstance(MailMessage::class);
$message
->setTo([$toEmail => $toName])
->setFrom([$fromEmail => $fromName])
->setSubject($subject)
;
$view = $this->getView($templateName);
$view->assignMultiple($variables);
$message->setBody($view->render(), 'text/html');
$messageSent = $message->send();
$autoreplySent = false;
if ($enableAutoreply) {
$contactForm = $variables['contactForm'];
$toEmail = $contactForm->getEmail();
$toName = $contactForm->getName();
$templateName = 'Email/Autoreply';
/** @var MailMessage $message */
$message = GeneralUtility::makeInstance(MailMessage::class);
$message
->setTo([$toEmail => $toName])
->setFrom([$fromEmail => $fromName])
->setSubject($autoreplySubject)
;
$view = $this->getView($templateName);
$view->assignMultiple($variables);
$message->setBody($view->render(), 'text/html');
$autoreplySent = $message->send();
}
return $messageSent && $autoreplySent;
}
/**
* @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;
}
}
@@ -0,0 +1,49 @@
<?php
namespace EP\EpTheme\Userfuncs;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
class Tca
{
public function getDeeplinkForNews($PA, $fObj)
{
if (!is_numeric($PA['row']['uid'])) {
return 'Wird nach dem Speichern angezeigt.';
}
$uid = $PA['row']['uid'];
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$configuration = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
$pageUid = $configuration['plugin.']['tx_eptheme.']['settings.']['blogDetailPageUid'];
$parameters = [
'tx_news_pi1' => [
'news' => $uid,
]
];
return \tx_pagepath_api::getPagePath($pageUid, $parameters);
}
public function getDeeplinkForPage($PA, $fObj)
{
if (!is_numeric($PA['row']['uid'])) {
return 'Wird nach dem Speichern angezeigt.';
}
$pageUid = $PA['row']['uid'];
return \tx_pagepath_api::getPagePath($pageUid);
}
public function getDeeplinkForStaticSearchparams($PA, $fObj)
{
if (!is_numeric($PA['row']['uid'])) {
return 'Wird nach dem Speichern angezeigt.';
}
return 'https://www.ep-reisen.de/reiseauswahl/' . $PA['row']['path_segment'];
}
}
@@ -0,0 +1,70 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ArgumentPrefixViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('pluginName', 'string', 'Plugin name');
$this->registerArgument('extensionName', 'string', 'Extension name');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$request = $renderingContext->getControllerContext()->getRequest();
$pluginName = $arguments['pluginName'];
if ($pluginName === null) {
$pluginName = $request->getPluginName();
}
$extensionName = $arguments['extensionName'];
if ($extensionName === null) {
$extensionName = $request->getControllerExtensionName();
}
return strtolower(implode('_', ['tx', $extensionName, $pluginName]));
}
}
@@ -0,0 +1,181 @@
<?php
namespace EP\EpTheme\ViewHelpers\Calendar;
/***************************************************************
*
* 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 CalendR\Event\Collection\Basic;
use CalendR\Period\Day;
use CalendR\Period\Month;
use EP\EpProducts\Domain\Model\Contingent;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ContingentViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
const LEVEL_GREEN = 1;
const LEVEL_YELLOW = 2;
const LEVEL_RED = 3;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('month', Month::class, 'The month', true);
$this->registerArgument('day', Day::class, 'The day', true);
$this->registerArgument('events', Basic::class, 'The calendar events', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$month = $arguments['month'];
$day = $arguments['day'];
$events = $arguments['events'];
if (!$month->includes($day)) {
return '';
}
$now = new \DateTime('now');
if ($now > $day->getBegin()) {
$class = [ 'text-muted' ];
return static::getHtml($class, $day->format('d'));
}
$contingents = $events->find($day);
if (count($contingents) === 0) {
$percentage = 100;
$level = static::LEVEL_GREEN;
} else {
$contingent = reset($contingents);
$percentage = $contingent->getPercentageAvailable();
$status = $contingent->getStatus();
$level = static::getOccupancyLevel($percentage, $status);
}
$previousDay = $day->getPrevious();
$previousContingents = $events->find($previousDay);
if (count($previousContingents) === 0) {
$previousLevel = static::LEVEL_GREEN;
} else {
$previousContingent = reset($previousContingents);
$previousPercentage = $previousContingent->getPercentageAvailable();
$previousStatus = $previousContingent->getStatus();
$previousLevel = static::getOccupancyLevel($previousPercentage, $previousStatus);
}
if ($previousLevel !== $level) {
$class = static::getTransientLabelClasses($previousLevel, $level);
} else {
$class = static::getLabelClasses($percentage, $level);
}
return static::getHtml($class, $day->format('d'));
}
/**
* @param int $percentage
* @param int $level
*
* @return array
*/
protected static function getLabelClasses($percentage, $level)
{
$classes = static::getTransientLabelClasses($level);
$classes[] = 'available-' . $percentage;
return $classes;
}
/**
* @param int $levelFrom
* @param int|null $levelTo
*
* @return array
*/
protected static function getTransientLabelClasses($levelFrom, $levelTo = null)
{
$classes = [ 'label' ];
if ($levelFrom === static::LEVEL_RED) {
$class = 'label-danger';
} elseif ($levelFrom === static::LEVEL_YELLOW) {
$class = 'label-warning';
} else {
$class = 'label-success';
}
if ($levelTo === static::LEVEL_RED) {
$class .= '-danger';
} elseif ($levelTo === static::LEVEL_YELLOW) {
$class .= '-warning';
} elseif ($levelTo !== null) {
$class .= '-success';
}
$classes[] = $class;
return $classes;
}
/**
* @param int $percentage
* @param int $status
*
* @return int
*/
protected static function getOccupancyLevel($percentage, $status)
{
if ($percentage <= 20 || $status === Contingent::STATUS_BLOCKED) {
return static::LEVEL_RED;
}
if (($percentage > 20 && $percentage <= 80) || $status === Contingent::STATUS_ONREQUEST) {
return static::LEVEL_YELLOW;
}
return static::LEVEL_GREEN;
}
/**
* @param array $class
* @param string $label
* @return string
*/
protected static function getHtml(array $class, $label)
{
$cssClass = ' class="' . implode(' ', $class) . '"';
return sprintf('<span%s>%s</span>', $cssClass, $label);
}
}
@@ -0,0 +1,54 @@
<?php
namespace EP\EpTheme\ViewHelpers\Calendar;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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 TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;
class IncludesViewHelper extends AbstractConditionViewHelper
{
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('range', 'object', 'Range to check against', true);
$this->registerArgument('period', 'object', 'Period to check if it is included in range', true);
}
/**
* @param array $arguments
* @return bool
*/
protected static function evaluateCondition($arguments = null)
{
/** @var \CalendR\Period\Range $range */
$range = $arguments['range'];
/** @var \CalendR\Period\PeriodInterface $period */
$period = $arguments['period'];
return $range->includes($period);
}
}
@@ -0,0 +1,92 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Domain\Model\Hotel;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ComfortCategoryViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('hotel', Hotel::class, 'The hotel');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
/** @var Hotel $hotel */
$hotel = $arguments['hotel'];
$flag = '<span class="category-flag" data-toggle="tooltip" title="%s">%s</span>';
switch ($hotel->getCategory())
{
case Hotel::CATEGORY_STANDARD:
$icon = 'S';
$tooltip = 'Kategorie: Standard';
break;
case Hotel::CATEGORY_BASIC:
$icon = 'B';
$tooltip = 'Kategorie: Basic';
break;
case Hotel::CATEGORY_COMFORT:
$icon = 'C';
$tooltip = 'Kategorie: Komfort';
break;
case Hotel::CATEGORY_DELUXE:
$icon = 'D';
$tooltip = 'Kategorie: Deluxe';
break;
case Hotel::CATEGORY_SUPER_DELUXE:
$icon = 'SD';
$tooltip = 'Kategorie: Superdeluxe';
break;
default:
return '';
}
return sprintf($flag, $tooltip, $icon);
}
}
@@ -0,0 +1,90 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ContainerViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
/**
* @var array
*/
protected static $columnsWithoutContainers = [ 0, 1, 3 ];
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('content', 'string', 'The content');
$this->registerArgument('cssClasses', 'string', 'Additional css classes');
$this->registerArgument('data', 'Array', 'The data', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$content = $renderChildrenClosure();
if ($content === null) {
$content = $arguments['content'];
}
$classes = [];
if (\in_array($arguments['data']['colPos'], static::$columnsWithoutContainers, false)) {
$classes[] = 'container';
} else {
$classes[] = 'in-column';
}
if ($arguments['cssClasses'] !== null) {
$classes[] = $arguments['cssClasses'];
}
if (count($classes) > 0) {
return '<div class="' . implode(' ', $classes) . '">' . $content . '</div>';
}
return $content;
}
}
@@ -0,0 +1,71 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ContextClassesViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('context', 'Array', 'The context', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$classes = [];
if (isset($arguments['context']['country'])) {
$classes[] = mb_strtolower($arguments['context']['country']['name']);
}
if (isset($arguments['context']['region'])) {
$classes[] = mb_strtolower($arguments['context']['region']['name']);
}
$classesString = implode(' ', $classes);
$classesString = str_replace(['ä', 'ö', 'ü', 'ß'], ['ae', 'oe', 'ue', 'ss'], $classesString);
return $classesString;
}
}
@@ -0,0 +1,68 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Utility\DateUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class DateRangeViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('dateFrom', \DateTime::class, 'Date range start');
$this->registerArgument('dateTo', \DateTime::class, 'Date range end');
$this->registerArgument('includeLabel', 'Bool', 'Whether to include a label', false, true);
$this->registerArgument('format', 'String', 'The date format', false, 'd.m.Y');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
return DateUtility::formatDateRange(
$arguments['dateFrom'],
$arguments['dateTo'],
$arguments['includeLabel'],
$arguments['format']
);
}
}
@@ -0,0 +1,76 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Service\FilterSettingsEncoder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class FilterSettingsEncoderViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('argument', 'string', 'The argument string to encode');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$argument = $renderChildrenClosure();
if ($argument === null) {
$argument = $arguments['argument'];
}
if ($argument === null) {
return '';
}
/** @var \EP\EpProducts\Service\FilterSettingsEncoder $encoder */
$encoder = GeneralUtility::makeInstance(FilterSettingsEncoder::class);
return $encoder::encode($argument);
}
}
@@ -0,0 +1,75 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Domain\Model\Country;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class FlagiconSourceViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('countryCode', 'string', 'Country code to return a flag icon source for.');
$this->registerArgument('country', 'mixed', 'Country entity to return a flag icon source for.');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$code = null;
if (\is_object($arguments['country']) && $arguments['country'] instanceof Country) {
/** @var \EP\EpProducts\Domain\Model\Country $country */
$country = $arguments['country'];
$code = strtolower($country->getCode());
} elseif (!empty($arguments['countryCode'])) {
$code = strtolower($arguments['countryCode']);
}
if ($code !== null) {
return 'EXT:ep_theme/Resources/Public/images/' . $code . '.png';
}
return 'EXT:ep_theme/Resources/Public/images/gb.png';
}
}
@@ -0,0 +1,83 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Region;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class GmapsUrlViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
const URLBASE = 'http://maps.google.com/maps?q=%s,%s&t=%s&z=%d';
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('hotel', Hotel::class, 'The hotel');
$this->registerArgument('region', Region::class, 'The region');
$this->registerArgument('type', 'string', 'The map type', false, 'p');
$this->registerArgument('zoom', 'int', 'The zoom level', false, 10);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$hotel = $arguments['hotel'];
$region = $arguments['region'];
if ($hotel !== null && $hotel->getLatitude() && $hotel->getLongitude()) {
$source = $hotel;
} elseif ($hotel !== null && $hotel->getRegion()->getLatitude() && $hotel->getRegion()->getLongitude()) {
$source = $hotel->getRegion();
} elseif ($region !== null) {
$source = $region;
} else {
return 'http://www.google.de/maps';
}
return sprintf(static::URLBASE, $source->getLatitude(), $source->getLongitude(), $arguments['type'], $arguments['zoom']);
}
}
@@ -0,0 +1,72 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class HotelCategoriesViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('categories', 'array', 'The categories', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$categories = $arguments['categories'];
switch (count($categories)) {
case 1:
$label = reset($categories);
break;
default:
$categoryMinLabel = array_shift($categories);
$categoryMaxLabel = array_pop($categories);
$label = $categoryMinLabel . ' - ' . $categoryMaxLabel;
}
return $label;
}
}
@@ -0,0 +1,73 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Domain\Model\Hotel;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class HotelCategoryViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var array
*/
static protected $categoryLabels = [
Hotel::CATEGORY_STANDARD => 'Standard',
Hotel::CATEGORY_COMFORT => 'Comfort',
Hotel::CATEGORY_DELUXE => 'Deluxe',
Hotel::CATEGORY_SUPER_DELUXE => 'Super Deluxe',
];
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('category', 'int', 'The category id', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$category = $arguments['category'];
return static::$categoryLabels[$category];
}
}
@@ -0,0 +1,81 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class NightsOptionsViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('options', 'array', 'The options');
$this->registerArgument('daytrip', 'bool', 'Is daytrip or not', false, false);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
if ($arguments['daytrip']) {
return 'Tageweise buchbar';
}
$options = $arguments['options'];
if ($options === null) {
return '';
}
sort($options);
$optionsCount = count($options);
$lastOption = array_pop($options);
$output = '';
if ($optionsCount > 2) {
$output .= implode(', ' , $options) . ' oder ' . $lastOption;
} elseif ($optionsCount === 2) {
$output .= reset($options) . ' oder ' . $lastOption;
} else {
$output = $lastOption;
}
$output .= (int) $lastOption > 1 ? ' Nächte' : ' Nacht';
return $output;
}
}
@@ -0,0 +1,86 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\EpProducts\Domain\Model\Product;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class RatingViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('product', Product::class, 'The product', true);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$product = $renderChildrenClosure();
if ($product === null) {
$product = $arguments['product'];
}
$ratingAverage = $product->getRatingAverage();
$ratingVotesCount = $product->getRatingVotesCount();
$fullStars = floor($ratingAverage);
$halfStar = ($ratingAverage - $fullStars) > 0;
$ratingAverageLabel = number_format($ratingAverage, 1, ',', '.');
$content = '';
for ($i = 1; $i <= $fullStars; $i++)
{
$content .= '<i class="fa fa-star" aria-hidden="true"></i>';
}
if ($halfStar) {
$content .= '<i class="fa fa-star-half-o" aria-hidden="true"></i>';
}
$content .= sprintf('%s Sterne (%d)', $ratingAverageLabel, $ratingVotesCount);
return $content;
}
}
@@ -0,0 +1,76 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class TopnavItemViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('item', 'string', 'The navigation item');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$item = $renderChildrenClosure();
if ($item === null) {
$item = $arguments['item'];
}
$parts = explode(' ', $item);
if (count($parts) === 1) {
return $item;
}
$hiddenMobileText = array_shift($parts);
$linkText = implode(' ', $parts);
return '<span class="hidden-md">' . $hiddenMobileText . '</span> ' . $linkText;
}
}
@@ -0,0 +1,89 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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 TYPO3\CMS\Core\Utility\RootlineUtility;
use TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
class AjaxViewHelper extends ActionViewHelper
{
const PAGE_TYPE_JSON = 1701;
const PAGE_TYPE_HTML = 1702;
public function initializeArguments()
{
parent::initializeArguments();
$this->overrideArgument('extensionName', 'string', 'Target extension name', false, 'epproducts');
$this->overrideArgument('pluginName', 'string', 'Target plugin name', false, 'Ajax');
$this->overrideArgument('format', 'string', 'The requested format', false, 'json');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic
(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
// Determine page type from format argument
if (strtolower(trim($arguments['format'])) === 'json') {
$arguments['pageType'] = self::PAGE_TYPE_JSON;
} else {
$arguments['pageType'] = self::PAGE_TYPE_HTML;
}
// Unset argument to keep it out of resulting url
$arguments['format'] = '';
// Use current page uid as target unless provided
if ($arguments['pageUid'] === null) {
$rootlineUtility = new RootlineUtility($GLOBALS['TSFE']->id);
$rootline = $rootlineUtility->get();
$rootPage = array_pop($rootline);
$arguments['pageUid'] = $rootPage['uid'];
}
// Force absolute urls
$arguments['absolute'] = true;
// Disable cache hash
$arguments['noCacheHash'] = true;
return parent::renderStatic($arguments, $renderChildrenClosure, $renderingContext);
}
}
@@ -0,0 +1,92 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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\EpProducts\Utility\BookingUrlUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class BookingViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var array
*/
protected static $settings = [];
/**
* @param ConfigurationManagerInterface $configurationManager
*/
public function __construct(ConfigurationManagerInterface $configurationManager)
{
$settings = GeneralUtility::removeDotsFromTS(
$configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
);
static::$settings = $settings['plugin']['tx_theme'];
}
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('bookingId', 'string', 'The booking id', true);
$this->registerArgument('hotelId', 'string', 'The hotel id', true);
$this->registerArgument('template', 'string', 'The booking template');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$template = $arguments['template'];
if ($template === null) {
$template = static::$settings['bpnBookungUrlTemplateCode'];
}
$options = [
'bookingId' => $arguments['bookingId'],
'hotelId' => $arguments['hotelId'],
'template' => $template,
];
return BookingUrlUtility::generateUrl($options);
}
}
@@ -0,0 +1,71 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ExternalImageViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('url', 'string', 'The url');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$url = $renderChildrenClosure();
if ($url === null) {
$url = $arguments['url'];
}
$encryptionKey = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
$token = sha1($url . $encryptionKey);
return 'https://www.ep-reisen.de/typo3conf/ext/ep_theme/extimg.php?url=' . urlencode($url) . '&token=' . $token;
}
}
@@ -0,0 +1,97 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* 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\EpProducts\Domain\Model\Product;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class ProductViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('product', Product::class, 'The product', true);
$this->registerArgument('hotel', 'mixed', 'The hotel');
$this->registerArgument('linkHotel', 'bool', 'Whether to link the hotel', false, false);
$this->registerArgument('referringPageUid', 'int', 'Uid of the referring page');
$this->registerArgument('defaultDetailPageUid', 'int', 'Uid of default page for product details');
$this->registerArgument('origin', 'string', 'Origin of the link');
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
$product = $arguments['product'];
if ($product->getDetailPage()) {
/** @var ContentObjectRenderer $contentObject */
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
return $contentObject->typoLink_URL(
[
'parameter' => $product->getDetailPage(),
]
);
}
$pageUid = $arguments['defaultDetailPageUid'];
$uriArguments = [ 'product' => $product ];
if ((int) $arguments['referringPageUid'] > 0) {
$uriArguments['referringPageUid'] = $arguments['referringPageUid'];
}
if ($arguments['origin'] !== null) {
$uriArguments['origin'] = $arguments['origin'];
}
if ((bool) $arguments['linkHotel'] && $arguments['hotel'] !== null) {
$uriArguments['hotel'] = $arguments['hotel'];
}
return $renderingContext
->getControllerContext()
->getUriBuilder()
->reset()
->setTargetPageUid($pageUid)
->uriFor('detail', $uriArguments, 'Product', 'epproducts', 'product_detail')
;
}
}
@@ -0,0 +1,75 @@
<?php
namespace EP\EpTheme\ViewHelpers\Uri;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class VideoViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* @var bool
*/
protected $escapeOutput = false;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('value', 'string', 'The video url', true);
$this->registerArgument('layout', 'int', 'The layout', false, 1);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return mixed
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
)
{
// YouTube
if ((int) $arguments['layout'] === 0) {
return $arguments['value'] . '?rel=0&amp;controls=0&amp;showinfo=0';
}
// Vimeo
if ((int) $arguments['layout'] === 1) {
return sprintf('https://player.vimeo.com/video/%d?html5=1', $arguments['value']);
}
return '';
}
}