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
+1
View File
@@ -0,0 +1 @@
deny from all
@@ -0,0 +1,93 @@
<?php
namespace EP\EpTheme\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpTheme\Service\EmailService;
use EP\EpTheme\Domain\Model\Dto\ContactForm;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
class AjaxFormController extends ActionController
{
/**
* @var EmailService
*/
protected $emailService;
/**
* @param EmailService $service
*/
public function injectEmailService(EmailService $service)
{
$this->emailService = $service;
}
/**
* @param ContactForm $contactForm
* @return string
*/
public function processFormAction(ContactForm $contactForm)
{
$response['status'] = 'ok';
$this->emailService->send(
$this->settings['contactFormToEmail'],
$this->settings['contactFormToName'],
'Kontaktformular E&P Reisen',
'Email/ContactForm',
[ 'contactForm' => $contactForm ]
);
return json_encode($response);
}
/**
* @return string
*/
protected function errorAction() {
$formErrors = [];
if ($this->arguments->getValidationResults()->hasErrors()) {
foreach ($this->arguments->getValidationResults()->getFlattenedErrors() as $key => $errors)
{
list($formName, $fieldName) = explode('.', $key);
$errorsRaw = [];
foreach ($errors as $error)
{
$translationKey = sprintf('tx_eptheme.message.%s.%s', $key, $error->getCode());
$errorsRaw[] = LocalizationUtility::translate($translationKey, 'ep_theme');
}
$formErrors[$fieldName] = implode(', ', $errorsRaw);
}
}
$response['status'] = 'validation';
$response['errors'] = $formErrors;
return json_encode($response);
}
}
@@ -0,0 +1,76 @@
<?php
namespace EP\EpTheme\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpTheme\Domain\Model\Dto\ContactForm;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class FormController extends ActionController
{
/**
* @param ContactForm $contactForm
*/
public function simpleFormAction(ContactForm $contactForm = null)
{
if ($contactForm === null) {
$pageUrl = $this->getCurrentPageUrl();
$contactForm = new ContactForm($pageUrl, ContactForm::FORM_TYPE_SIMPLE);
}
$this->view->assign('contactForm', $contactForm);
}
/**
* @param ContactForm $contactForm
*/
public function fullFormAction(ContactForm $contactForm = null)
{
if ($contactForm === null) {
$pageUrl = $this->getCurrentPageUrl();
$contactForm = new ContactForm($pageUrl, ContactForm::FORM_TYPE_FULL);
}
$this->view->assign('contactForm', $contactForm);
}
/**
* @return string
*/
private function getCurrentPageUrl()
{
if (GeneralUtility::_GET('ref')) {
$pageUid = GeneralUtility::_GET('ref');
} else {
$pageUid = $GLOBALS['TSFE']->id;
}
return $this->uriBuilder
->reset()
->setCreateAbsoluteUri(true)
->setTargetPageUid($pageUid)
->build()
;
}
}
@@ -0,0 +1,77 @@
<?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\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class ContextProcessor 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;
$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');
}
return $processedData;
}
/**
* @param int $uid
* @param string $table
* @return array
*/
private function getContextRecord($uid, $table)
{
$where = $GLOBALS['TSFE']->sys_page->enableFields($table);
return $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
'*',
$table,
$table . '.uid=' . $uid . $where
);
}
}
@@ -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\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Service\FlexFormService;
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,96 @@
<?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\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class SliderProcessor 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
) {
$page = $cObj->data;
$pageUid = $page['uid'];
if ((int) $page['tx_eptheme_slides'] === 0) {
$pageUid = $this->getParentPageWithSlides();
}
if ($pageUid === null) {
return $processedData;
}
$slides = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'uid, headline, subline, button, page_uid',
'tx_eptheme_domain_model_slide',
'page=' . $pageUid . $GLOBALS['TSFE']->sys_page->enableFields('tx_eptheme_domain_model_slide')
);
if (is_array($slides) && count($slides) > 0) {
$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()
{
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($GLOBALS['TSFE']->id);
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,131 @@
<?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\HotelRepository;
use EP\EpProducts\Domain\Repository\ProductRepository;
use EP\EpProducts\Domain\Repository\RegionRepository;
use EP\EpProducts\Service\HotelService;
use EP\EpProducts\Service\ProductService;
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\HotelService $service */
$service = $objectManager->get(HotelService::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\ProductService $productService */
$productService = $objectManager->get(ProductService::class);
$processedData['teaser'] = $productService->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
* @validate NotEmpty
*/
protected $name;
/**
* @var string
*/
protected $company;
/**
* @var string
* @validate NotEmpty
* @validate EmailAddress
*/
protected $email;
/**
* @var string
* @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,140 @@
<?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'];
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 '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 'deal_of_the_week':
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>Deal der Woche</strong><br />' . $product['name'];
}
break;
case 'lineup':
$drawItem = false;
$itemContent = '<strong>Lineup</strong><br />' . $row['tx_eptheme_lineup'] . ' Einträge';
break;
default:
}
}
}
@@ -0,0 +1,63 @@
<?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 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,110 @@
<?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'];
/** @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');
$message->send();
return $message->isSent();
}
/**
* @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,53 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Fluid\Core\ViewHelper\AbstractViewHelper;
class ArgumentPrefixViewHelper extends AbstractViewHelper
{
/**
* @param string $pluginName
* @param string $extensionName
*
* @return string
*/
public function render($pluginName = null, $extensionName = null)
{
$request = $this->controllerContext->getRequest();
if ($pluginName === null) {
$pluginName = $request->getPluginName();
}
if ($extensionName === null) {
$extensionName = $request->getControllerExtensionName();
}
return strtolower(implode('_', ['tx', $extensionName, $pluginName]));
}
}
@@ -0,0 +1,149 @@
<?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 CalendR\Event\Collection\Basic;
use CalendR\Period\Day;
use CalendR\Period\Month;
use EP\EpProducts\Domain\Model\Contingent;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ContingentViewHelper extends AbstractViewHelper
{
const LEVEL_GREEN = 1;
const LEVEL_YELLOW = 2;
const LEVEL_RED = 3;
public function render(Month $month, Day $day, Basic $events)
{
if (!$month->includes($day)) {
return '';
}
$now = new \DateTime('now');
if ($now > $day->getBegin()) {
$class = [ 'text-muted' ];
return $this->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 = $this->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 = $this->getOccupancyLevel($previousPercentage, $previousStatus);
}
if ($previousLevel !== $level) {
$class = $this->getTransientLabelClasses($previousLevel, $level);
} else {
$class = $this->getLabelClasses($percentage, $level);
}
return $this->getHtml($class, $day->format('d'));
}
/**
* @param int $percentage
* @param int $level
*
* @return array
*/
protected function getLabelClasses($percentage, $level)
{
$classes = $this->getTransientLabelClasses($level);
$classes[] = 'available-' . $percentage;
return $classes;
}
/**
* @param int $levelFrom
* @param int|null $levelTo
*
* @return array
*/
protected 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 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 function getHtml(array $class, $label)
{
$cssClass = ' class="' . implode(' ', $class) . '"';
return sprintf('<span%s>%s</span>', $cssClass, $label);
}
}
@@ -0,0 +1,53 @@
<?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 TYPO3\CMS\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,70 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Hotel;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ComfortCategoryViewHelper extends AbstractViewHelper
{
/**
* @param Hotel $hotel
*
* @return string
*/
public function render(Hotel $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_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,65 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Fluid\Core\ViewHelper\AbstractViewHelper;
class ContainerViewHelper extends AbstractViewHelper
{
/**
* @var array
*/
protected $columnsWithoutContainers = [ 0, 1, 3 ];
/**
* @param array $data
* @param string $content
* @param string $cssClasses
*
* @return string
*/
public function render(array $data, $content = null, $cssClasses = null)
{
if ($content === null) {
$content = $this->renderChildren();
}
$classes = [];
if (in_array($data['colPos'], $this->columnsWithoutContainers, false)) {
$classes[] = 'container';
} else {
$classes[] = 'in-column';
}
if ($cssClasses !== null) {
$classes[] = $cssClasses;
}
if (count($classes) > 0) {
return '<div class="' . implode(' ', $classes) . '">' . $content . '</div>';
}
return $content;
}
}
@@ -0,0 +1,57 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Fluid\Core\ViewHelper\AbstractViewHelper;
class ContextClassesViewHelper extends AbstractViewHelper
{
/**
* @param array $context
*
* @return string
*/
public function render(array $context)
{
$classes = [];
if (isset($context['country'])) {
$classes[] = mb_strtolower($context['country']['name']);
}
if (isset($context['region'])) {
$classes[] = mb_strtolower($context['region']['name']);
}
$classesString = implode(' ', $classes);
$classesString = str_replace(['ä', 'ö', 'ü', 'ß'], ['ae', 'oe', 'ue', 'ss'], $classesString);
return $classesString;
}
}
@@ -0,0 +1,49 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Utility\DateUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class DateRangeViewHelper extends AbstractViewHelper
{
/**
* @param \DateTime $dateFrom
* @param \DateTime $dateTo
* @param bool $includeLabel
* @param string $format
*
* @return string
*/
public function render(\DateTime $dateFrom = null, \DateTime $dateTo = null, $includeLabel = true, $format = 'd.m.Y')
{
return DateUtility::formatDateRange($dateFrom, $dateTo, $includeLabel, $format);
}
}
@@ -0,0 +1,53 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\FilterSettingsEncoder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class FilterSettingsEncoderViewHelper extends AbstractViewHelper
{
/**
* @param string $argument
*
* @return string
*/
public function render($argument = null)
{
if ($argument === null) {
$argument = $this->renderChildren();
}
if ($argument === null) {
return '';
}
/** @var \EP\EpProducts\Service\FilterSettingsEncoder $encoder */
$encoder = GeneralUtility::makeInstance(FilterSettingsEncoder::class);
return $encoder->encode($argument);
}
}
@@ -0,0 +1,61 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Country;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class FlagiconSourceViewHelper extends AbstractViewHelper
{
public function initializeArguments()
{
$this->registerArgument('countryCode', 'string', 'Country code to return a flag icon source for.');
$this->registerArgument('country', 'object', 'Country entity to return a flag icon source for.');
}
public function render()
{
$code = null;
if (is_object($this->arguments['country']) && $this->arguments['country'] instanceof Country) {
/** @var \EP\EpProducts\Domain\Model\Country $country */
$country = $this->arguments['country'];
$code = strtolower($country->getCode());
} elseif (!empty($this->arguments['countryCode'])) {
$code = strtolower($this->arguments['countryCode']);
}
if ($code !== null) {
return 'EXT:ep_theme/Resources/Public/images/' . $code . '.png';
}
return '';
}
}
@@ -0,0 +1,89 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Hotel;
use EP\EpProducts\Domain\Model\Region;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class GmapsStaticMapViewHelper extends AbstractViewHelper
{
const URLBASE = '%s&center=%s,%s&zoom=%d&size=%dx%d';
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @var array
*/
protected $settings = [];
/**
* @param ConfigurationManagerInterface $manager
* @return void
*/
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']['settings'];
}
/**
* @param Hotel $hotel
* @param Region $region
* @param int $zoom
* @param int $width
* @param int $height
*
* @return string
*/
public function render(Hotel $hotel = null, Region $region = null, $zoom = 10, $width = 0, $height = 0)
{
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 '';
}
$staticMapsBaseUrl = $this->settings['googleStaticMapsBaseUrl'];
$url = sprintf(static::URLBASE, $staticMapsBaseUrl, $source->getLatitude(), $source->getLongitude(), $zoom, $width, $height);
$tag = sprintf('<img class="scale" src="%s" alt="%s" title="%s"/>', $url, $source->getName(), $source->getName());
return $tag;
}
}
@@ -0,0 +1,59 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Hotel;
use EP\EpProducts\Domain\Model\Region;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class GmapsUrlViewHelper extends AbstractViewHelper
{
const URLBASE = 'http://maps.google.com/maps?q=%s,%s&t=%s&z=%d';
/**
* @param Hotel $hotel
* @param Region $region
* @param string $type
* @param int $zoom
*
* @return string
*/
public function render(Hotel $hotel = null, Region $region = null, $type = 'p', $zoom = 10)
{
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(), $type, $zoom);
}
}
@@ -0,0 +1,54 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Hotel;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class HotelCategoryViewHelper extends AbstractViewHelper
{
/**
* @var array
*/
static protected $categoryLabels = [
Hotel::CATEGORY_STANDARD => 'Standard',
Hotel::CATEGORY_COMFORT => 'Comfort',
Hotel::CATEGORY_DELUXE => 'Deluxe',
Hotel::CATEGORY_SUPER_DELUXE => 'Super Deluxe',
];
/**
* @param int $category
*
* @return string
*/
public function render($category)
{
return static::$categoryLabels[$category];
}
}
@@ -0,0 +1,60 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Fluid\Core\ViewHelper\AbstractViewHelper;
class NightsOptionsViewHelper extends AbstractViewHelper
{
/**
* @param array $options
*
* @return string
*/
public function render(array $options = null)
{
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,61 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Product;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class RatingViewHelper extends AbstractViewHelper
{
/**
* @param Product $product
*
* @return string
*/
public function render(Product $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,55 @@
<?php
namespace EP\EpTheme\ViewHelpers;
/***************************************************************
*
* 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\Fluid\Core\ViewHelper\AbstractViewHelper;
class TopnavItemViewHelper extends AbstractViewHelper
{
/**
* @param string $item
*
* @return string
*/
public function render($item = null)
{
if ($item === null) {
$item = $this->renderChildren();
}
$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,94 @@
<?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 TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper;
class AjaxViewHelper extends ActionViewHelper
{
const PAGE_TYPE_JSON = 1701;
const PAGE_TYPE_HTML = 1702;
/**
* @var array
*/
protected $settings;
/**
* @param ConfigurationManagerInterface $manager
*/
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
{
$configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS($configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
$this->settings = $settings['plugin']['tx_eptheme']['settings'];
}
/**
* @param string $action Target action
* @param array $arguments Arguments
* @param string $controller Target controller. If NULL current controllerName is used
* @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
* @param string $pluginName Target plugin. If empty, the current plugin name is used
* @param int $pageUid target page. See TypoLink destination
* @param int $pageType type of the target page. See typolink.parameter
* @param bool $noCache set this to disable caching for the target page. You should not need this.
* @param bool $noCacheHash set this to suppress the cHash query parameter created by TypoLink. You should not need this.
* @param string $section the anchor to be added to the URI
* @param string $format The requested format, e.g. ".html
* @param bool $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
* @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
* @param bool $absolute If set, an absolute URI is rendered
* @param bool $addQueryString If set, the current query parameters will be kept in the URI
* @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
* @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
*
* @return string Rendered link
*/
public function render($action = null, array $arguments = array(), $controller = null, $extensionName = 'epproducts', $pluginName = 'Ajax', $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = true, $section = '', $format = 'json', $linkAccessRestrictedPages = false, array $additionalParams = array(), $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array(), $addQueryStringMethod = null)
{
if (array_key_exists('defaultAjaxUid', $this->settings)) {
$pageUid = $this->settings['defaultAjaxUid'];
}
if (strtolower(trim($format)) === 'json') {
$pageType = self::PAGE_TYPE_JSON;
} else {
$pageType = self::PAGE_TYPE_HTML;
}
if ($pageUid === null) {
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($GLOBALS['TSFE']->id);
$rootPage = array_pop($rootLine);
$pageUid = $rootPage['uid'];
}
return parent::render($action, $arguments, $controller, $extensionName, $pluginName, $pageUid, $pageType, $noCache, $noCacheHash, $section, '', $linkAccessRestrictedPages, $additionalParams, $absolute, $addQueryString, $argumentsToBeExcludedFromQueryString, $addQueryStringMethod);
}
}
@@ -0,0 +1,72 @@
<?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 EP\EpProducts\Utility\BookingUrlUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class BookingViewHelper extends AbstractViewHelper
{
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @var array
*/
protected $settings = [];
/**
* @param ConfigurationManagerInterface $manager
* @return void
*/
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
{
$this->configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
$this->settings = $settings['plugin']['tx_theme'];
}
/**
* @param int $bookingId
* @param int $hotelId
* @param string $template
*
* @return string
*/
public function render($bookingId, $hotelId, $template = null)
{
if ($template === null) {
$template = $this->settings['bpnBookingUrlTemplateCode'];
}
return BookingUrlUtility::generateUrl($bookingId, $hotelId, $template);
}
}
@@ -0,0 +1,45 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ExternalImageViewHelper extends AbstractViewHelper
{
/**
* @param string $url
*
* @return string
*/
public function render($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,100 @@
<?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 EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Product;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class ProductViewHelper extends AbstractViewHelper
{
/**
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @var array
*/
protected $settings = [];
/**
* @param ConfigurationManagerInterface $manager
* @return void
*/
public function injectConfigurationManager(ConfigurationManagerInterface $manager)
{
$this->configurationManager = $manager;
$settings = GeneralUtility::removeDotsFromTS($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT));
$this->settings = $settings['plugin']['tx_epproducts'];
}
/**
* @param Product $product
* @param Hotel|null $hotel
* @param bool $linkHotel
* @param int $referringPageUid
* @param string $origin
*
* @return string
*/
public function render(Product $product, Hotel $hotel = null, $linkHotel = false, $referringPageUid = null, $origin = null)
{
if ($product->getDetailPage()) {
return $this
->controllerContext
->getUriBuilder()
->reset()
->setTargetPageUid($product->getDetailPage())
->build()
;
}
$pageUid = $this->settings['defaultDetailPageUid'];
$arguments = [ 'product' => $product ];
if ((int) $referringPageUid > 0) {
$arguments['referringPageUid'] = $referringPageUid;
}
if ($origin !== null) {
$arguments['origin'] = $origin;
}
if ((bool) $linkHotel && $hotel !== null) {
$arguments['hotel'] = $hotel;
}
return $this
->controllerContext
->getUriBuilder()
->reset()
->setTargetPageUid($pageUid)
->uriFor('detail', $arguments, 'Product', 'epproducts', 'product_detail')
;
}
}
@@ -0,0 +1,51 @@
<?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 TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
class VideoViewHelper extends AbstractViewHelper
{
/**
* @param string $value
* @param int $layout
* @return string
*/
public function render($value, $layout = 1)
{
// YouTube
if ((int) $layout === 0) {
return $value . '?rel=0&amp;controls=0&amp;showinfo=0';
}
// Vimeo
if ((int) $layout === 1) {
return sprintf('https://player.vimeo.com/video/%d?html5=1', $value);
}
return '';
}
}