chore: copy ep_products and ep_theme from EP/website@9593cc8
Copied unchanged from public/typo3conf/ext/ of EP/website at 9593cc8631354f8a363d6609de8b7433f669a9a0 (Git-tracked files only). History stays in the old repository. Only composer.json files are added so the extensions install as path packages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
59afaecea1
commit
a46918de9d
778 files changed
+67000
-2
No files matched your search
Executable
+1
@@ -0,0 +1 @@
|
||||
deny from all
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Controller;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2020 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\Repository\PageRepository;
|
||||
use TYPO3\CMS\Backend\View\BackendTemplateView;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
|
||||
class BackendController extends ActionController
|
||||
{
|
||||
/**
|
||||
* Backend Template Container
|
||||
*
|
||||
* @var BackendTemplateView
|
||||
*/
|
||||
protected $defaultViewObjectName = BackendTemplateView::class;
|
||||
|
||||
/**
|
||||
* BackendTemplateContainer
|
||||
*
|
||||
* @var BackendTemplateView
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $pageUid;
|
||||
|
||||
/**
|
||||
* @var PageRepository
|
||||
*/
|
||||
protected $pageRepository;
|
||||
|
||||
/**
|
||||
* @param PageRepository $pageRepository
|
||||
*/
|
||||
public function __construct(PageRepository $pageRepository)
|
||||
{
|
||||
$this->pageRepository = $pageRepository;
|
||||
}
|
||||
|
||||
public function initializeAction()
|
||||
{
|
||||
$this->pageUid = (int)GeneralUtility::_GET('id');
|
||||
|
||||
parent::initializeAction();
|
||||
}
|
||||
|
||||
public function listPagesAction()
|
||||
{
|
||||
$pages = $this->pageRepository->findPagesByPid($this->pageUid, true);
|
||||
|
||||
$this->view->assign('pages', $pages);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?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');
|
||||
}
|
||||
if ($data['tx_eptheme_context_pacode']) {
|
||||
$processedData['context']['paCode'] = $data['tx_eptheme_context_pacode'];
|
||||
} elseif ($paCode = $this->getPaCodeFromRequest()) {
|
||||
$processedData['context']['paCode'] = $paCode;
|
||||
}
|
||||
|
||||
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)) {
|
||||
return $items['pa'];
|
||||
}
|
||||
|
||||
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,60 @@
|
||||
<?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)) {
|
||||
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
|
||||
$processedData['data']['flexForm'] = $flexFormService->convertFlexFormContentToArray($data['pi_flexform']);
|
||||
}
|
||||
return $processedData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\DataProcessing;
|
||||
|
||||
use EP\EpProducts\Traits\DbConnectionTrait;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
|
||||
|
||||
class ProductRatingProcessor implements DataProcessorInterface
|
||||
{
|
||||
use DbConnectionTrait;
|
||||
|
||||
public function process(
|
||||
ContentObjectRenderer $cObj,
|
||||
array $contentObjectConfiguration,
|
||||
array $processorConfiguration,
|
||||
array $processedData
|
||||
) {
|
||||
$qb = $this->getDbConnection()->createQueryBuilder();
|
||||
|
||||
$result = $qb
|
||||
->selectLiteral('SUM(product.rating_votes_count) as totalCount', 'SUM(product.rating_average) as totalAverage')
|
||||
->from('tx_epproducts_domain_model_product', 'product')
|
||||
->execute()
|
||||
->fetchAssociative()
|
||||
;
|
||||
|
||||
$totalCount = $result['totalCount'];
|
||||
$totalAverage = $result['totalAverage'];
|
||||
|
||||
$result = $qb
|
||||
->selectLiteral('COUNT(*) as ratedCount')
|
||||
->from('tx_epproducts_domain_model_product', 'product')
|
||||
->where($qb->expr()->gt('product.rating_average', 0))
|
||||
->execute()
|
||||
->fetchAssociative()
|
||||
;
|
||||
|
||||
$ratedCount = $result['ratedCount'];
|
||||
|
||||
$jsonData = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'LocalBusiness',
|
||||
'name' => 'E&P Reisen und Events GmbH',
|
||||
'address' => [
|
||||
'@type' => 'PostalAddress',
|
||||
'streetAddress' => 'Aachener Str. 326-328',
|
||||
'postalCode' => '50933',
|
||||
'addressLocality' => 'Köln,Deutschland'
|
||||
],
|
||||
'telephone' => '00492212722760',
|
||||
'url' => 'https://www.ep-reisen.de/',
|
||||
'contactPoint' => [
|
||||
'@type' => 'ContactPoint',
|
||||
'telephone' => '+492212722760',
|
||||
'email' => '[email protected]',
|
||||
'contactType' => 'customer service',
|
||||
'areaServed' => 'DE',
|
||||
'availableLanguage' => 'German'
|
||||
],
|
||||
'logo' => 'https://www.ep-reisen.de/typo3conf/ext/ep_theme/Resources/Public/images/logo_wide.svg',
|
||||
'priceRange' => '€',
|
||||
'image' => 'https://www.ep-reisen.de/typo3conf/ext/ep_theme/Resources/Public/images/logo_wide.svg',
|
||||
'aggregateRating' => [
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => number_format($totalAverage/$ratedCount, 2),
|
||||
'bestRating' => '5',
|
||||
'worstRating' => '1',
|
||||
'ratingCount' => $totalCount
|
||||
],
|
||||
'sameAs' => [
|
||||
'https://www.facebook.com/ep.reisen.events',
|
||||
'https://www.instagram.com/ep_reisen/',
|
||||
'https://www.youtube.com/user/epreisende'
|
||||
]
|
||||
];
|
||||
|
||||
$processedData['totalRatings'] = [
|
||||
'totalCount' => $totalCount,
|
||||
'totalAverage' => $totalAverage/$ratedCount,
|
||||
'jsonData' => $jsonData,
|
||||
];
|
||||
|
||||
return $processedData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?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', 'skipass')
|
||||
->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']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (1 === count($slides)) {
|
||||
$processedData['slide'] = reset($processedData['slides']);
|
||||
}
|
||||
|
||||
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,130 @@
|
||||
<?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 = [
|
||||
'productUid' => $productUid,
|
||||
'hotelUid' => $hotelUid,
|
||||
];
|
||||
|
||||
$dateFromTimestamp = (int) $processedData['data']['tx_eptheme_context_date_from'];
|
||||
if ($dateFromTimestamp > 0) {
|
||||
$dateFrom = new \DateTime();
|
||||
$dateFrom->setTimestamp($dateFromTimestamp);
|
||||
$filterSettings['dateFrom'] = $dateFrom->format('Y-m-d');
|
||||
}
|
||||
$dateToTimestamp = (int) $processedData['data']['tx_eptheme_context_date_to'];
|
||||
if ($dateToTimestamp > 0) {
|
||||
$dateTo = new \DateTime();
|
||||
$dateTo->setTimestamp($dateToTimestamp);
|
||||
$filterSettings['dateTo'] = $dateTo->format('Y-m-d');
|
||||
}
|
||||
|
||||
/** @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,351 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Honeypot field!!
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $subject;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
|
||||
*/
|
||||
protected $firstName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
|
||||
*/
|
||||
protected $gender;
|
||||
|
||||
/**
|
||||
* @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 getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
*/
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName()
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $firstName
|
||||
*/
|
||||
public function setFirstName($firstName)
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGender()
|
||||
{
|
||||
return $this->gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $gender
|
||||
*/
|
||||
public function setGender($gender)
|
||||
{
|
||||
$this->gender = $gender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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,102 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Domain\Model;
|
||||
|
||||
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
|
||||
|
||||
class Page extends AbstractEntity
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $uid;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $pid;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $hidden;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $seoTitle;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return $this->hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hidden
|
||||
*/
|
||||
public function setHidden($hidden)
|
||||
{
|
||||
$this->hidden = $hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSeoTitle()
|
||||
{
|
||||
return $this->seoTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $seoTitle
|
||||
*/
|
||||
public function setSeoTitle($seoTitle)
|
||||
{
|
||||
$this->seoTitle = $seoTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Domain\Repository;
|
||||
|
||||
use TYPO3\CMS\Core\Domain\Repository\PageRepository as CorePageRepository;
|
||||
use TYPO3\CMS\Extbase\Persistence\Repository;
|
||||
|
||||
class PageRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultOrderings = [
|
||||
'sorting' => 'ASC',
|
||||
];
|
||||
|
||||
public function findPagesByPid(int $pid, bool $includeDisabled = false)
|
||||
{
|
||||
$query = $this->createQuery();
|
||||
$query
|
||||
->getQuerySettings()
|
||||
->setRespectStoragePage(false)
|
||||
->setIgnoreEnableFields($includeDisabled)
|
||||
->setIncludeDeleted(false)
|
||||
->setRespectSysLanguage(false)
|
||||
;
|
||||
$query->matching($query->logicalAnd([
|
||||
$query->equals('pid', $pid),
|
||||
$query->equals('doktype', CorePageRepository::DOKTYPE_DEFAULT),
|
||||
$query->equals('navHide', false),
|
||||
]));
|
||||
|
||||
return $query->execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Exception;
|
||||
|
||||
class ConfigurationMissingException extends \Exception
|
||||
{}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Exception;
|
||||
|
||||
class TemplateFileMissingException extends \Exception
|
||||
{}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use TYPO3\CMS\Core\Log\LogManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
|
||||
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
|
||||
|
||||
abstract class AbstractMappedFinisher extends AbstractFinisher
|
||||
{
|
||||
/**
|
||||
* Resolves the 'mapping' option into remote name => local form element identifier.
|
||||
*/
|
||||
protected function parseMapping(): array
|
||||
{
|
||||
$mappings = [];
|
||||
$mappingOption = (string)$this->parseOption('mapping');
|
||||
|
||||
foreach (GeneralUtility::trimExplode(',', $mappingOption, true) as $mapping) {
|
||||
$parts = GeneralUtility::trimExplode(':', $mapping, true, 2);
|
||||
if (2 !== count($parts)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[$remote, $local] = $parts;
|
||||
if ('' === $remote || '' === $local) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mappings[$remote] = $local;
|
||||
}
|
||||
|
||||
return $mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapped values, keyed by the remote name the receiving side expects. Values pass through
|
||||
* normalizeValue() just like the labeled ones do, so a date element arrives as a Y-m-d string
|
||||
* instead of a serialized DateTime. A value that does not survive normalization keeps its key:
|
||||
* the remote names make up the request shape and dropping one would change it.
|
||||
*/
|
||||
protected function buildPayload(): array
|
||||
{
|
||||
$values = [];
|
||||
$formValues = $this->finisherContext->getFormValues();
|
||||
|
||||
foreach ($this->parseMapping() as $remote => $local) {
|
||||
if (false === array_key_exists($local, $formValues)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values[$remote] = $this->normalizeValue($formValues[$local], $local);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every submitted value that the mapping does not already cover, keyed by the element label
|
||||
* as the editor sees it in the form editor. Forms built in the backend use generated
|
||||
* identifiers (text-1, singleselect-2, ...) that carry no meaning and cannot be renamed
|
||||
* without breaking existing finisher options, so the label is the only stable description
|
||||
* of what was asked.
|
||||
*
|
||||
* The label is taken from the form definition, not through TranslationService: a translated
|
||||
* label would change the payload keys with the site language, and these keys are stored.
|
||||
*/
|
||||
protected function buildLabeledValues(): array
|
||||
{
|
||||
$formValues = $this->finisherContext->getFormValues();
|
||||
$skip = array_merge(
|
||||
array_values($this->parseMapping()),
|
||||
GeneralUtility::trimExplode(',', (string)$this->parseOption('exclude'), true)
|
||||
);
|
||||
|
||||
// Keyed by identifier in form order, and contains only real form elements - iterating
|
||||
// this instead of the form values keeps the collection in the order of the form and
|
||||
// leaves out anything that is not an element the visitor filled in.
|
||||
$elements = $this->finisherContext->getFormRuntime()->getFormDefinition()->getElements();
|
||||
|
||||
$collected = [];
|
||||
foreach ($elements as $identifier => $element) {
|
||||
if (true === in_array($identifier, $skip, true) || false === array_key_exists($identifier, $formValues)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $this->normalizeValue($formValues[$identifier], $identifier);
|
||||
if (null === $value || '' === $value || [] === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = trim($element->getLabel());
|
||||
if ('' === $label) {
|
||||
$label = $identifier;
|
||||
}
|
||||
if (true === array_key_exists($label, $collected)) {
|
||||
$label .= ' (' . $identifier . ')';
|
||||
}
|
||||
|
||||
$collected[$label] = $value;
|
||||
}
|
||||
|
||||
return $collected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed null when the value has no JSON representation
|
||||
*/
|
||||
protected function normalizeValue($value, string $identifier)
|
||||
{
|
||||
if (true === is_array($value)) {
|
||||
$normalized = [];
|
||||
foreach ($value as $item) {
|
||||
$item = $this->normalizeValue($item, $identifier);
|
||||
if (null !== $item && '' !== $item) {
|
||||
$normalized[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
return $value->format('Y-m-d');
|
||||
}
|
||||
|
||||
if ($value instanceof FileReference) {
|
||||
$resource = $value->getOriginalResource();
|
||||
|
||||
return null !== $resource ? $resource->getName() : null;
|
||||
}
|
||||
|
||||
if (true === is_object($value)) {
|
||||
$this->logWarning('Form value skipped while collecting labeled values: unsupported type.', [
|
||||
'element' => $identifier,
|
||||
'class' => get_class($value),
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function logWarning(string $message, array $context = []): void
|
||||
{
|
||||
GeneralUtility::makeInstance(LogManager::class)
|
||||
->getLogger(static::class)
|
||||
->warning($message, array_merge([
|
||||
'finisher' => static::class,
|
||||
], $context));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
|
||||
|
||||
class AddReferrerFinisher extends AbstractFinisher
|
||||
{
|
||||
protected function executeInternal()
|
||||
{
|
||||
$this->addCurrentUrlField();
|
||||
$this->addReferrerField();
|
||||
}
|
||||
|
||||
private function addReferrerField(): void
|
||||
{
|
||||
// Look for key 'referrer' in frontend session
|
||||
$referrer = $GLOBALS['TSFE']->fe_user->getKey('ses', 'referrer');
|
||||
|
||||
if (null === $referrer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add textfield to form containing referrer value
|
||||
$field = $this->finisherContext
|
||||
->getFormRuntime()
|
||||
->getFormDefinition()
|
||||
->getPageByIndex(0)
|
||||
->createElement('referrer', 'Text');
|
||||
|
||||
$field->setDefaultValue($referrer);
|
||||
$field->setDataType('string');
|
||||
$field->setLabel('Referrer');
|
||||
|
||||
// Add finisher variable for potential later use
|
||||
$this->finisherContext->getFinisherVariableProvider()->add(
|
||||
$this->shortFinisherIdentifier,
|
||||
'referrer',
|
||||
$referrer
|
||||
);
|
||||
|
||||
// Remove session key
|
||||
$GLOBALS['TSFE']->fe_user->setKey('ses', 'referrer', null);
|
||||
$GLOBALS['TSFE']->fe_user->storeSessionData();
|
||||
}
|
||||
|
||||
private function addCurrentUrlField(): void
|
||||
{
|
||||
// Get URL of current page
|
||||
$pageId = $GLOBALS['TSFE']->id;
|
||||
$site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
|
||||
$url = $site->getRouter()->generateUri($pageId);
|
||||
|
||||
// Add textfield to form containing url value
|
||||
$field = $this->finisherContext
|
||||
->getFormRuntime()
|
||||
->getFormDefinition()
|
||||
->getPageByIndex(0)
|
||||
->createElement('pageurl', 'Text');
|
||||
|
||||
$field->setDefaultValue($url);
|
||||
$field->setDataType('string');
|
||||
$field->setLabel('URL');
|
||||
|
||||
// Add finisher variable for potential later use
|
||||
$this->finisherContext->getFinisherVariableProvider()->add(
|
||||
$this->shortFinisherIdentifier,
|
||||
'pageurl',
|
||||
$url
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use EP\EpProducts\EpTeam\ApiClient;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
class ApplicationApiFinisher extends AbstractMappedFinisher
|
||||
{
|
||||
/**
|
||||
* @var ApiClient
|
||||
*/
|
||||
protected $apiClient;
|
||||
|
||||
/**
|
||||
* @param ApiClient $apiClient
|
||||
*/
|
||||
public function injectApiClient(ApiClient $apiClient)
|
||||
{
|
||||
$this->apiClient = $apiClient;
|
||||
}
|
||||
|
||||
protected function executeInternal()
|
||||
{
|
||||
try {
|
||||
$payload = $this->buildPayload();
|
||||
if ([] === $payload) {
|
||||
$this->logWarning('Application form API finisher skipped: the mapping produced no values.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$formDefinition = $this->finisherContext->getFormRuntime()->getFormDefinition();
|
||||
$formLabel = trim($formDefinition->getLabel());
|
||||
|
||||
$payload['form'] = $formDefinition->getIdentifier();
|
||||
// The name the editor gave the form, so the receiving side can label a submission
|
||||
// without keeping a list of identifiers. Taken from the definition rather than
|
||||
// through TranslationService: a translated label would differ per site language.
|
||||
$payload['formLabel'] = '' !== $formLabel ? $formLabel : $formDefinition->getIdentifier();
|
||||
$payload['submittedAt'] = (new \DateTimeImmutable())->format(\DateTimeInterface::ATOM);
|
||||
$payload = array_merge($payload, $this->resolvePageContext());
|
||||
$payload['details'] = $this->buildLabeledValues();
|
||||
|
||||
$this->apiClient->submitApplicationForm($payload);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logWarning('Application form API finisher request failed.', [
|
||||
'exception' => $e,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The page the form was submitted from. The URL is generated through the site router in the
|
||||
* visitor's language, the same way AddReferrerFinisher does it, so it is the page's canonical
|
||||
* URL rather than the submit request with its form arguments attached.
|
||||
*/
|
||||
private function resolvePageContext(): array
|
||||
{
|
||||
if (false === isset($GLOBALS['TSFE']) || 0 === (int)$GLOBALS['TSFE']->id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$pageUid = (int)$GLOBALS['TSFE']->id;
|
||||
$context = ['pageUid' => $pageUid];
|
||||
|
||||
try {
|
||||
$site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageUid);
|
||||
$context['pageUrl'] = (string)$site->getRouter()->generateUri($pageUid, [
|
||||
'_language' => $GLOBALS['TSFE']->getLanguage(),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
// An unroutable page must not cost the submission, so the uid is sent without a URL.
|
||||
$this->logWarning('Application form API finisher could not resolve the page URL.', [
|
||||
'pageUid' => $pageUid,
|
||||
'exception' => $e,
|
||||
]);
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use EP\EpProducts\MyEP\ApiClient;
|
||||
|
||||
class BpnApiFinisher extends AbstractMappedFinisher
|
||||
{
|
||||
/**
|
||||
* @var ApiClient
|
||||
*/
|
||||
protected $apiClient;
|
||||
|
||||
/**
|
||||
* @param ApiClient $apiClient
|
||||
*/
|
||||
public function injectApiClient(ApiClient $apiClient)
|
||||
{
|
||||
$this->apiClient = $apiClient;
|
||||
}
|
||||
|
||||
protected function executeInternal()
|
||||
{
|
||||
try {
|
||||
$values = $this->buildPayload();
|
||||
if ([] !== $values) {
|
||||
$this->apiClient->registerAddress($values);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->logWarning('Bpn API finisher request failed.', [
|
||||
'exception' => $e,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
class WebhookFinisher extends AbstractMappedFinisher
|
||||
{
|
||||
protected function executeInternal()
|
||||
{
|
||||
try {
|
||||
$url = trim((string)$this->parseOption('url'));
|
||||
if ('' === $url) {
|
||||
return;
|
||||
}
|
||||
|
||||
$payload = $this->buildPayload();
|
||||
if ([] === $payload) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response = HttpClient::create()->request('POST', $url, [
|
||||
'json' => $payload,
|
||||
]);
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
if ($statusCode < 200 || $statusCode >= 300) {
|
||||
$this->logWarning('Webhook finisher returned an unexpected response status.', [
|
||||
'url' => $url,
|
||||
'statusCode' => $statusCode,
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->logWarning('Webhook finisher request failed.', [
|
||||
'exception' => $e,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use EP\EpTheme\Exception\ConfigurationMissingException;
|
||||
use EP\EpTheme\Exception\TemplateFileMissingException;
|
||||
use TYPO3\CMS\Backend\View\PageLayoutView;
|
||||
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Resource\FileRepository;
|
||||
use TYPO3\CMS\Core\Service\FlexFormService;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
|
||||
/**
|
||||
* Class AbstractPreviewRenderer
|
||||
*/
|
||||
abstract class AbstractPreviewRenderer implements PageLayoutViewDrawItemHookInterface
|
||||
{
|
||||
/**
|
||||
* @var array tt_content.*
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Define a CType
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cType = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $templatePath = 'EXT:ep_theme/Resources/Private/Templates/PreviewRenderer/';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (empty($this->cType)) {
|
||||
throw new ConfigurationMissingException('Property cType must not be empty', 1586703436);
|
||||
}
|
||||
}
|
||||
|
||||
public function preProcess(
|
||||
PageLayoutView &$parentObject,
|
||||
&$drawItem,
|
||||
&$headerContent,
|
||||
&$itemContent,
|
||||
array &$row
|
||||
) {
|
||||
$this->data = &$row;
|
||||
if ($this->isCtypeMatching() && $this->checkTemplateFile()) {
|
||||
$drawItem = false;
|
||||
$headerContent = $this->getHeaderContent();
|
||||
$itemContent .= $this->getBodytext();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderContent(): string
|
||||
{
|
||||
return '<div id="element-tt_content-' . (int)$this->data['uid']
|
||||
. '" class="t3-ctype-identifier " data-ctype="' . $this->cType . '"></div>';
|
||||
}
|
||||
|
||||
protected function getBodytext(): string
|
||||
{
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$standaloneView = $objectManager->get(StandaloneView::class);
|
||||
$standaloneView->setTemplatePathAndFilename($this->getTemplateFile());
|
||||
$standaloneView->assignMultiple($this->getAssignmentsForTemplate() + [
|
||||
'data' => $this->data,
|
||||
'flexForm' => $this->getFlexForm(),
|
||||
'firstImage' => count($this->getImages()) > 0 ? $this->getImages()[0] : null,
|
||||
'images' => $this->getImages()
|
||||
]);
|
||||
return $standaloneView->render();
|
||||
}
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getFlexForm(): array
|
||||
{
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$flexFormService = $objectManager->get(FlexFormService::class);
|
||||
return $flexFormService->convertFlexFormContentToArray($this->data['pi_flexform']);
|
||||
}
|
||||
|
||||
protected function getImages(int $uid = null, string $tablenames = 'tt_content', string $fieldname = 'image'): array
|
||||
{
|
||||
$uid = $uid ?? $this->data['uid'];
|
||||
$references = [];
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
$fileRepository = $objectManager->get(FileRepository::class);
|
||||
/** @var ConnectionPool $connectionPool */
|
||||
$connectionPool = $objectManager->get(ConnectionPool::class);
|
||||
$queryBuilder = $connectionPool->getQueryBuilderForTable('sys_file_reference');
|
||||
$identifiers = (array)$queryBuilder
|
||||
->select('uid')
|
||||
->from('sys_file_reference')
|
||||
->where('uid_foreign=' . $uid . ' and tablenames="' . $tablenames . '" and fieldname="' . $fieldname . '"')
|
||||
->execute()
|
||||
->fetch(\PDO::FETCH_COLUMN);
|
||||
foreach ($identifiers as $identifier) {
|
||||
if ($identifier > 0) {
|
||||
$reference = $fileRepository->findFileReferenceByUid($identifier);
|
||||
if ($reference !== null) {
|
||||
$references[] = $reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isCtypeMatching(): bool
|
||||
{
|
||||
return $this->data['CType'] === $this->cType;
|
||||
}
|
||||
|
||||
protected function checkTemplateFile(): bool
|
||||
{
|
||||
if (is_file($this->getTemplateFile()) === false) {
|
||||
throw new TemplateFileMissingException(
|
||||
'Expected template file for preview rendering for CType ' . $this->cType . ' is missing',
|
||||
1586703260
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getTemplateFile(): string
|
||||
{
|
||||
return GeneralUtility::getFileAbsFileName(
|
||||
$this->templatePath . GeneralUtility::underscoredToUpperCamelCase($this->data['CType']) . '.html'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class DisrupterPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'disrupter';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$uid = $this->data['tx_eptheme_disrupter'];
|
||||
$content = BackendUtility::getRecord('tx_eptheme_domain_model_disrupter', $uid);
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
class DisturberPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'disturber';
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class GmapPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'gmap';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$uid = $this->data['tx_eptheme_context_region'];
|
||||
if ((int)$uid > 0) {
|
||||
$content = BackendUtility::getRecord('tx_epproducts_domain_model_region', $uid);
|
||||
} else {
|
||||
$uid = $this->data['tx_eptheme_context_hotel'];
|
||||
$content = BackendUtility::getRecord('tx_epproducts_domain_model_hotel', $uid);
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
|
||||
class LineupPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'lineup';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
/** @var ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
/** @var ConnectionPool $connectionPool */
|
||||
$connectionPool = $objectManager->get(ConnectionPool::class);
|
||||
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_eptheme_domain_model_lineup');
|
||||
$rows = $queryBuilder->select('*')
|
||||
->from('tx_eptheme_domain_model_lineup')
|
||||
->where('tt_content='.$this->data['uid'])
|
||||
->orderBy('sorting', 'ASC')
|
||||
->execute()
|
||||
->fetchAllAssociative();
|
||||
|
||||
return [
|
||||
'rows' => $rows,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserBookingLinkPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_booking_link';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$productUid = $this->data['tx_eptheme_context_product'];
|
||||
$images = $this->getImages($productUid, 'tx_epproducts_domain_model_product', 'teaser_images');
|
||||
$product = BackendUtility::getRecord('tx_epproducts_domain_model_product', $productUid);
|
||||
return [
|
||||
'images' => $images,
|
||||
'product' => $product,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserCityPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_city';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$uid = $this->data['tx_eptheme_context_city'];
|
||||
$images = $this->getImages($uid, 'tx_epproducts_domain_model_city', 'teaser_images');
|
||||
return [
|
||||
'images' => $images,
|
||||
'city' => BackendUtility::getRecord('tx_epproducts_domain_model_city', $uid),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserConceptPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_concept';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$uid = $this->data['tx_eptheme_context_concept'];
|
||||
$images = $this->getImages($uid, 'tx_epproducts_domain_model_concept', 'teaser_images');
|
||||
return [
|
||||
'images' => $images,
|
||||
'concept' => BackendUtility::getRecord('tx_epproducts_domain_model_concept', $uid),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserCountryPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_country';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$countryUid = $this->data['tx_eptheme_context_country'];
|
||||
$images = $this->getImages($countryUid, 'tx_epproducts_domain_model_country', 'teaser_images');
|
||||
return [
|
||||
'images' => $images,
|
||||
'country' => BackendUtility::getRecord('tx_epproducts_domain_model_country', $countryUid),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserHotelPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_hotel';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$uid = $this->data['tx_eptheme_context_hotel'];
|
||||
$images = $this->getImages($uid, 'tx_epproducts_domain_model_hotel', 'teaser_images');
|
||||
return [
|
||||
'images' => $images,
|
||||
'hotel' => BackendUtility::getRecord('tx_epproducts_domain_model_hotel', $uid),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserProductPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_product';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$productUid = $this->data['tx_eptheme_context_product'];
|
||||
$hotelUid = $this->data['tx_eptheme_context_hotel'];
|
||||
$images = $this->getImages($productUid, 'tx_epproducts_domain_model_product', 'teaser_images');
|
||||
$product = BackendUtility::getRecord('tx_epproducts_domain_model_product', $productUid);
|
||||
$hotel = $hotelUid ? BackendUtility::getRecord('tx_epproducts_domain_model_hotel', $hotelUid) : null;
|
||||
return [
|
||||
'images' => $images,
|
||||
'product' => $product,
|
||||
'hotel' => $hotel,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks\PageLayoutView;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
|
||||
class TeaserRegionPreviewRenderer extends AbstractPreviewRenderer
|
||||
{
|
||||
protected $cType = 'teaser_region';
|
||||
|
||||
protected function getAssignmentsForTemplate(): array
|
||||
{
|
||||
$uid = $this->data['tx_eptheme_context_region'];
|
||||
$images = $this->getImages($uid, 'tx_epproducts_domain_model_region', 'teaser_images');
|
||||
return [
|
||||
'images' => $images,
|
||||
'region' => BackendUtility::getRecord('tx_epproducts_domain_model_region', $uid),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Hooks;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* 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,69 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\MetaTag;
|
||||
|
||||
use TYPO3\CMS\Core\Resource\FileRepository;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\RootlineUtility;
|
||||
use TYPO3\CMS\Extbase\Service\ImageService;
|
||||
|
||||
class OpenGraphMetaTagManager extends \TYPO3\CMS\Seo\MetaTag\OpenGraphMetaTagManager
|
||||
{
|
||||
public function renderAllProperties(): string
|
||||
{
|
||||
if (array_key_exists('og:image', $this->properties)) {
|
||||
return parent::renderAllProperties();
|
||||
}
|
||||
/** @var FileRepository $fileRepository */
|
||||
$fileRepository = GeneralUtility::makeInstance(FileRepository::class);
|
||||
|
||||
$pageUid = $this->getPageWithImage();
|
||||
|
||||
if (null === $pageUid) {
|
||||
return parent::renderAllProperties();
|
||||
}
|
||||
|
||||
$images = $fileRepository->findByRelation('pages', 'og_image', $pageUid);
|
||||
|
||||
/** @var ImageService $imageService */
|
||||
$imageService = GeneralUtility::makeInstance(ImageService::class);
|
||||
|
||||
foreach ($images as $image) {
|
||||
$processedImage = $imageService->applyProcessingInstructions(
|
||||
$image,
|
||||
[
|
||||
'width' => '1200'
|
||||
]
|
||||
);
|
||||
$this->addProperty(
|
||||
'og:image',
|
||||
$imageService->getImageUri($processedImage, true),
|
||||
[
|
||||
'url' => $imageService->getImageUri($processedImage, true),
|
||||
'width' => $processedImage->getProperty('width'),
|
||||
'height' => $processedImage->getProperty('height'),
|
||||
'type' => $processedImage->getMimeType(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return parent::renderAllProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
protected function getPageWithImage()
|
||||
{
|
||||
$rootLineUtility = new RootlineUtility($GLOBALS['TSFE']->id);
|
||||
$rootLine = $rootLineUtility->get();
|
||||
|
||||
foreach ($rootLine as $page) {
|
||||
if ($page['og_image'] > 0) {
|
||||
return $page['uid'];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Middleware;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
class ReferrerMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
|
||||
if (!array_key_exists('ref', $queryParams)) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
$ref = $queryParams['ref'];
|
||||
|
||||
if (false === is_numeric($ref)) {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
/** @var SiteFinder $siteFinder */
|
||||
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
|
||||
|
||||
try {
|
||||
$site = $siteFinder->getSiteByPageId((int) $ref);
|
||||
$url = $site->getRouter()->generateUri($ref);
|
||||
$GLOBALS['TSFE']->fe_user->setKey('ses', 'referrer', $url);
|
||||
$GLOBALS['TSFE']->fe_user->storeSessionData();
|
||||
}
|
||||
catch (SiteNotFoundException $exception) {
|
||||
}
|
||||
|
||||
return $handler->handle($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?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 Symfony\Component\Mime\Address;
|
||||
use TYPO3\CMS\Core\Mail\FluidEmail;
|
||||
use TYPO3\CMS\Core\Mail\Mailer;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
|
||||
class EmailService implements SingletonInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
public function __construct(ConfigurationManagerInterface $manager)
|
||||
{
|
||||
$settings = GeneralUtility::removeDotsFromTS(
|
||||
$manager->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
|
||||
*/
|
||||
public function send($toEmail, $toName, $subject, $templateName, array $variables = [])
|
||||
{
|
||||
/** @var Mailer $mailer */
|
||||
$mailer = GeneralUtility::makeInstance(Mailer::class);
|
||||
$fromEmail = $this->settings['settings']['contactFormToEmail'];
|
||||
$fromName = $this->settings['settings']['contactFormToName'];
|
||||
$enableAutoreply = (bool)$this->settings['settings']['enableContactFormAutoreply'];
|
||||
$autoreplySubject = $this->settings['settings']['contactFormAutoreplySubject'];
|
||||
|
||||
/** @var FluidEmail $message */
|
||||
$message = GeneralUtility::makeInstance(FluidEmail::class);
|
||||
$message
|
||||
->to(new Address($toEmail, $toName))
|
||||
->from(new Address($fromEmail, $fromName))
|
||||
->format('html')
|
||||
->subject($subject)
|
||||
->setTemplate($templateName)
|
||||
->assignMultiple($variables)
|
||||
;
|
||||
|
||||
$mailer->send($message);
|
||||
|
||||
if ($enableAutoreply) {
|
||||
$contactForm = $variables['contactForm'];
|
||||
$toEmail = $contactForm->getEmail();
|
||||
$toName = $contactForm->getName();
|
||||
$templateName = 'Autoreply';
|
||||
|
||||
/** @var FluidEmail $message */
|
||||
$message = GeneralUtility::makeInstance(FluidEmail::class);
|
||||
$message
|
||||
->to(new Address($toEmail, $toName))
|
||||
->from(new Address($fromEmail, $fromName))
|
||||
->format('html')
|
||||
->subject($autoreplySubject)
|
||||
->setTemplate($templateName)
|
||||
->assignMultiple($variables)
|
||||
;
|
||||
|
||||
$mailer->send($message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -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,201 @@
|
||||
<?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 DateInterval;
|
||||
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;
|
||||
|
||||
private const LEVEL_GREEN = 1;
|
||||
private const LEVEL_YELLOW = 2;
|
||||
private const LEVEL_RED = 3;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('day', \DateTimeInterface::class, 'The day', true);
|
||||
$this->registerArgument('calendar', 'array', 'The calendar payload', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$day = $arguments['day'];
|
||||
$calendar = $arguments['calendar'];
|
||||
$now = new \DateTimeImmutable('now');
|
||||
$dayDate = new \DateTimeImmutable($day->format('Y-m-d H:i:s'), $day->getTimezone());
|
||||
$dayDate = $dayDate->setTime(0, 0, 0);
|
||||
|
||||
if (!empty($calendar['error'])) {
|
||||
$class = [ 'text-zinc-400' ];
|
||||
return static::getHtml($class, $dayDate->format('d'));
|
||||
}
|
||||
|
||||
if ($now > $dayDate) {
|
||||
$class = [ 'text-zinc-400' ];
|
||||
return static::getHtml($class, $dayDate->format('d'));
|
||||
}
|
||||
$statusMap = static::getStatusMap($calendar);
|
||||
$status = static::normalizeStatus($statusMap[$dayDate->format('Y-m-d')] ?? 'OK');
|
||||
$previousStatus = static::normalizeStatus($statusMap[$dayDate->sub(new DateInterval('P1D'))->format('Y-m-d')] ?? 'OK');
|
||||
$level = static::getOccupancyLevel($status);
|
||||
$previousLevel = static::getOccupancyLevel($previousStatus);
|
||||
|
||||
if ($previousLevel !== $level) {
|
||||
$class = static::getTransientLabelClasses($previousStatus, $status);
|
||||
} else {
|
||||
$class = static::getLabelClasses($status);
|
||||
}
|
||||
|
||||
return static::getHtml($class, $dayDate->format('d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected static function getLabelClasses(string $status): array
|
||||
{
|
||||
return [
|
||||
'block p-1 leading-none text-sm text-white',
|
||||
static::getStatusClass($status),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected static function getTransientLabelClasses(string $statusFrom, ?string $statusTo = null): array
|
||||
{
|
||||
$classes = [ 'block p-1 leading-none text-sm text-white' ];
|
||||
$class = static::getStatusClass($statusFrom);
|
||||
if ($statusTo !== null) {
|
||||
$class .= '-to-' . static::getStatusSuffix($statusTo);
|
||||
}
|
||||
$classes[] = $class;
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected static function getOccupancyLevel(string $status): int
|
||||
{
|
||||
if ($status === 'BLOCKED') {
|
||||
return static::LEVEL_RED;
|
||||
}
|
||||
if ($status === 'ON_REQUEST') {
|
||||
return static::LEVEL_YELLOW;
|
||||
}
|
||||
return static::LEVEL_GREEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected static function getStatusMap(array $calendar): array
|
||||
{
|
||||
$statusMap = [];
|
||||
foreach (($calendar['data'] ?? []) as $row) {
|
||||
if (!isset($row['date'])) {
|
||||
continue;
|
||||
}
|
||||
$statusMap[$row['date']] = static::normalizeStatus((string)($row['status'] ?? 'OK'));
|
||||
}
|
||||
|
||||
return $statusMap;
|
||||
}
|
||||
|
||||
protected static function normalizeStatus(string $status): string
|
||||
{
|
||||
$status = strtoupper(trim($status));
|
||||
if ($status === 'ONREQUEST') {
|
||||
return 'ON_REQUEST';
|
||||
}
|
||||
|
||||
if (in_array($status, [ 'OK', 'ON_REQUEST', 'BLOCKED' ], true)) {
|
||||
return $status;
|
||||
}
|
||||
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
protected static function getStatusClass(string $status): string
|
||||
{
|
||||
if ($status === 'BLOCKED') {
|
||||
return 'availability-none';
|
||||
}
|
||||
if ($status === 'ON_REQUEST') {
|
||||
return 'availability-partial';
|
||||
}
|
||||
|
||||
return 'availability-full';
|
||||
}
|
||||
|
||||
protected static function getStatusSuffix(string $status): string
|
||||
{
|
||||
if ($status === 'BLOCKED') {
|
||||
return 'none';
|
||||
}
|
||||
if ($status === 'ON_REQUEST') {
|
||||
return 'partial';
|
||||
}
|
||||
|
||||
return 'full';
|
||||
}
|
||||
|
||||
/**
|
||||
* @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,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,117 @@
|
||||
<?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 int[]
|
||||
*/
|
||||
protected static $scale = [
|
||||
'default' => 0,
|
||||
'small' => 8,
|
||||
'large' => 16,
|
||||
];
|
||||
|
||||
/**
|
||||
* @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('rteContent', 'boolean', 'Is RTE content', false, false);
|
||||
$this->registerArgument('data', 'Array', 'The record 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';
|
||||
}
|
||||
|
||||
if ($arguments['cssClasses'] !== null) {
|
||||
$classes[] = $arguments['cssClasses'];
|
||||
}
|
||||
|
||||
if (!empty($arguments['data']['space_before_class'])) {
|
||||
$scaleTop = static::$scale[$arguments['data']['space_before_class']];
|
||||
$classes[] = sprintf('pt-%d', $scaleTop);
|
||||
}
|
||||
|
||||
if (!empty($arguments['data']['space_after_class'])) {
|
||||
$scaleBottom = static::$scale[$arguments['data']['space_after_class']];
|
||||
$classes[] = sprintf('pb-%d', $scaleBottom);
|
||||
}
|
||||
|
||||
if ('default' !== $arguments['data']['frame_class']) {
|
||||
$classes[] = $arguments['data']['frame_class'];
|
||||
}
|
||||
|
||||
if (count($classes) > 0) {
|
||||
return sprintf('<div class="%s"%s>%s</div>', implode(' ', $classes), $arguments['rteContent'] ? ' data-rte-content' : '', $content);
|
||||
}
|
||||
|
||||
if ($arguments['rteContent']) {
|
||||
return sprintf('<div data-rte-content>%s</div>', $content);
|
||||
}
|
||||
|
||||
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,67 @@
|
||||
<?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', 'string', 'Date range start');
|
||||
$this->registerArgument('dateTo', 'string', '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,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\Service\FilterSettingsEncoder;
|
||||
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 '';
|
||||
}
|
||||
|
||||
$encoder = new FilterSettingsEncoder();
|
||||
|
||||
return $encoder->encode($argument);
|
||||
}
|
||||
}
|
||||
@@ -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,41 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Service\ImageService;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
|
||||
|
||||
class IconViewHelper extends AbstractTagBasedViewHelper
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tagName = 'svg';
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerUniversalTagAttributes();
|
||||
$this->registerArgument('icon', 'string', 'Icon name', true);
|
||||
}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$imageService = self::getImageService();
|
||||
$sprite = $imageService->getImage('EXT:ep_theme/Resources/Public/images/icons_sprite.svg', null, false);
|
||||
$imageUrl = $sprite->getPublicUrl();
|
||||
|
||||
$content = sprintf('<use href="%s#icon-%s"></use>', $imageUrl, $this->arguments['icon']);
|
||||
$this->tag->setContent($content);
|
||||
$this->tag->addAttributes(['aria-hidden' => 'true']);
|
||||
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
protected static function getImageService()
|
||||
{
|
||||
return GeneralUtility::makeInstance(ImageService::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use EP\EpProducts\Service\MyEpUrlResolverService;
|
||||
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 MyEpUrlViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
): string {
|
||||
return GeneralUtility::makeInstance(MyEpUrlResolverService::class)->resolve();
|
||||
}
|
||||
}
|
||||
@@ -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,66 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2021 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 PriceRangeViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('min', 'mixed', 'Price range start');
|
||||
$this->registerArgument('max', 'mixed', 'Price range end');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
) {
|
||||
if (1 === (int) $arguments['min']) {
|
||||
return sprintf('bis %d €', $arguments['max']);
|
||||
}
|
||||
if (999 === (int) $arguments['max']) {
|
||||
return sprintf('ab %d €', $arguments['min']);
|
||||
}
|
||||
|
||||
return sprintf('%d bis %d €', $arguments['min'], $arguments['max']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
|
||||
|
||||
/**
|
||||
* Formats a euro amount the way the website always has for whole euros ("229",
|
||||
* "1234"), and with German decimals where there are cents ("99,90"). Prices are
|
||||
* stored with cents, and the database hands them over as strings like "229.00".
|
||||
*
|
||||
* Keep in sync with formatPrice() in pricetable_controller.js.
|
||||
*
|
||||
* Usage: {row.minPrice -> ep:price()} €
|
||||
*/
|
||||
class PriceViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithContentArgumentAndRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('value', 'mixed', 'Amount in euros');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
) {
|
||||
$amount = round((float) $renderChildrenClosure(), 2);
|
||||
$decimals = floor($amount) === $amount ? 0 : 2;
|
||||
|
||||
return number_format($amount, $decimals, ',', '');
|
||||
}
|
||||
}
|
||||
@@ -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,41 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers\Stimulus;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* This code is adapted from the Symfony WebpackEncoreBundle package.
|
||||
* (c) Fabien Potencier <[email protected]>
|
||||
*/
|
||||
class AbstractStimulusViewHelper extends AbstractViewHelper
|
||||
{
|
||||
/**
|
||||
* This method is taken from symfony/webpack-encore-bundle
|
||||
*
|
||||
* Normalize a Stimulus controller name into its HTML equivalent (no special character and / becomes --).
|
||||
*
|
||||
* @see https://stimulus.hotwire.dev/reference/controllers
|
||||
*/
|
||||
protected static function normalizeControllerName(string $str): string
|
||||
{
|
||||
return preg_replace('/^@/', '', str_replace('_', '-', str_replace('/', '--', $str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is taken from symfony/webpack-encore-bundle
|
||||
*
|
||||
* Normalize a Stimulus Value API key into its HTML equivalent ("kebab case").
|
||||
* Backport features from symfony/string.
|
||||
*
|
||||
* @see https://stimulus.hotwire.dev/reference/values
|
||||
*/
|
||||
protected static function normalizeKeyName(string $str): string
|
||||
{
|
||||
// Adapted from ByteString::camel
|
||||
$str = ucfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $str))));
|
||||
|
||||
// Adapted from ByteString::snake
|
||||
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1-\2', $str));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers\Stimulus;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* This code is adapted from the Symfony WebpackEncoreBundle package.
|
||||
* (c) Fabien Potencier <[email protected]>
|
||||
*/
|
||||
class ActionViewHelper extends AbstractStimulusViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('controller', 'mixed', 'Controller name(s)', true);
|
||||
$this->registerArgument('action', 'string', 'Action name', false);
|
||||
$this->registerArgument('event', 'string', 'Event name', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$dataOrControllerName = $arguments['controller'];
|
||||
$actionName = $arguments['action'];
|
||||
$eventName = $arguments['event'];
|
||||
|
||||
if (\is_string($dataOrControllerName)) {
|
||||
$data = [$dataOrControllerName => null === $eventName ? [[$actionName]] : [[$eventName => $actionName]]];
|
||||
} else {
|
||||
if ($actionName || $eventName) {
|
||||
throw new \InvalidArgumentException('You cannot pass a string to the second or third argument while passing an array to the first argument of stimulus_action(): check the documentation.');
|
||||
}
|
||||
|
||||
$data = $dataOrControllerName;
|
||||
|
||||
if (!$data) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$actions = [];
|
||||
|
||||
foreach ($data as $controllerName => $controllerActions) {
|
||||
$controllerName = static::normalizeControllerName($controllerName);
|
||||
|
||||
if (\is_string($controllerActions)) {
|
||||
$controllerActions = [[$controllerActions]];
|
||||
}
|
||||
|
||||
foreach ($controllerActions as $possibleEventName => $controllerAction) {
|
||||
if (\is_string($possibleEventName) && \is_string($controllerAction)) {
|
||||
$controllerAction = [$possibleEventName => $controllerAction];
|
||||
} elseif (\is_string($controllerAction)) {
|
||||
$controllerAction = [$controllerAction];
|
||||
}
|
||||
|
||||
foreach ($controllerAction as $eventName => $actionName) {
|
||||
$action = $controllerName.'#'.htmlspecialchars($actionName, ENT_QUOTES);
|
||||
|
||||
if (\is_string($eventName)) {
|
||||
$action = $eventName.'->'.$action;
|
||||
}
|
||||
|
||||
$actions[] = $action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'data-action="'.implode(' ', $actions).'"';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers\Stimulus;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* This code is adapted from the Symfony WebpackEncoreBundle package.
|
||||
* (c) Fabien Potencier <[email protected]>
|
||||
*/
|
||||
class ControllerViewHelper extends AbstractStimulusViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('controller', 'mixed', 'Controller name(s)', true);
|
||||
$this->registerArgument('values', 'array', 'Controller values', false, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$dataOrControllerName = $arguments['controller'];
|
||||
$controllerValues = $arguments['values'];
|
||||
|
||||
if (\is_string($dataOrControllerName)) {
|
||||
$data = [$dataOrControllerName => $controllerValues];
|
||||
} else {
|
||||
if ($controllerValues) {
|
||||
throw new \InvalidArgumentException('You cannot pass an array to the first and second argument of stimulus_controller(): check the documentation.');
|
||||
}
|
||||
|
||||
$data = $dataOrControllerName;
|
||||
|
||||
if (!$data) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$controllers = [];
|
||||
$values = [];
|
||||
|
||||
foreach ($data as $controllerName => $controllerValues) {
|
||||
$controllerName = static::normalizeControllerName($controllerName);
|
||||
$controllers[] = $controllerName;
|
||||
|
||||
foreach ($controllerValues as $key => $value) {
|
||||
if (!is_scalar($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
if (\is_bool($value)) {
|
||||
$value = $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
$key = static::normalizeKeyName($key);
|
||||
$value = htmlspecialchars($value, ENT_QUOTES);
|
||||
|
||||
$values[] = 'data-'.$controllerName.'-'.$key.'-value="'.$value.'"';
|
||||
}
|
||||
}
|
||||
|
||||
return rtrim('data-controller="'.implode(' ', $controllers).'" '.implode(' ', $values));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers\Stimulus;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* This code is adapted from the Symfony WebpackEncoreBundle package.
|
||||
* (c) Fabien Potencier <[email protected]>
|
||||
*/
|
||||
class TargetViewHelper extends AbstractStimulusViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('controller', 'mixed', 'Controller name(s)', true);
|
||||
$this->registerArgument('targets', 'string', 'Target names', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$dataOrControllerName = $arguments['controller'];
|
||||
$targetNames = $arguments['target'];
|
||||
|
||||
if (\is_string($dataOrControllerName)) {
|
||||
$data = [$dataOrControllerName => $targetNames];
|
||||
} else {
|
||||
if ($targetNames) {
|
||||
throw new \InvalidArgumentException('You cannot pass a string to the second argument while passing an array to the first argument of stimulus_target(): check the documentation.');
|
||||
}
|
||||
|
||||
$data = $dataOrControllerName;
|
||||
|
||||
if (!$data) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$targets = [];
|
||||
|
||||
foreach ($data as $controllerName => $targetNames) {
|
||||
$controllerName = static::normalizeControllerName($controllerName);
|
||||
|
||||
$targets['data-'.$controllerName.'-target'] = htmlspecialchars($targetNames, ENT_QUOTES);
|
||||
}
|
||||
|
||||
return implode(' ', array_map(static function (string $attribute, string $value): string {
|
||||
return $attribute.'="'.$value.'"';
|
||||
}, array_keys($targets), $targets));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2021 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 ThemeClassesViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('key', 'string', 'The theme key', false, 'ep');
|
||||
$this->registerArgument('classes', 'array', 'The classes to apply per theme key', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$themeKey = $arguments['key'];
|
||||
|
||||
if (!array_key_exists($themeKey, $arguments['classes'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $arguments['classes'][$themeKey];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// Reset argument to keep it out of resulting url
|
||||
unset($arguments['format']);
|
||||
|
||||
// Use root 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;
|
||||
|
||||
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 = [
|
||||
'dateId' => $arguments['bookingId'],
|
||||
'hotelId' => $arguments['hotelId'],
|
||||
'theme' => $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,103 @@
|
||||
<?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 ProductViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('product', 'mixed', 'The product');
|
||||
$this->registerArgument('hotel', 'array', 'The hotel');
|
||||
$this->registerArgument('forceHotelUid', 'bool', 'Whether to force link a hotel');
|
||||
$this->registerArgument('dateFrom', 'string', 'Date to limit table on detail page by (Y-m-d)');
|
||||
$this->registerArgument('dateTo', 'string', 'Date to limit table on detail page by (Y-m-d)');
|
||||
$this->registerArgument('ref', 'string', 'Referring URL');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
) {
|
||||
$product = $arguments['product'];
|
||||
$hotel = $arguments['hotel'];
|
||||
|
||||
if ($arguments['forceHotelUid']) {
|
||||
// Product detail page with forced hotel
|
||||
$linkArguments = [
|
||||
'product' => is_array($product) ? $product['uid'] : $product,
|
||||
'hotel' => is_array($hotel) ? $hotel['uid'] : $hotel,
|
||||
];
|
||||
} elseif ($arguments['dateFrom'] || $arguments['dateTo']) {
|
||||
// Product detail page with forced date range
|
||||
$linkArguments = [
|
||||
'dateFrom' => $arguments['dateFrom'],
|
||||
'dateTo' => $arguments['dateTo'],
|
||||
];
|
||||
} else {
|
||||
// Default product detail page by product uid
|
||||
$linkArguments = [
|
||||
'product' => is_array($product) ? $product['uid'] : $product,
|
||||
];
|
||||
}
|
||||
|
||||
$targetPageUid = is_array($product) ? (int)$product['detailPage'] : $product->getDetailPage();
|
||||
|
||||
$uri = $renderingContext
|
||||
->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setTargetPageUid($targetPageUid)
|
||||
->uriFor('detail', $linkArguments, 'Product', 'epproducts', 'product_detail')
|
||||
;
|
||||
|
||||
if ($arguments['ref']) {
|
||||
$referringPageUri = urlencode($arguments['ref']);
|
||||
$hasQuery = null !== parse_url($uri, PHP_URL_QUERY);
|
||||
$separator = $hasQuery ? '&' : '?';
|
||||
$uri .= $separator . 'ref=' . $referringPageUri;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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&controls=0&showinfo=0';
|
||||
}
|
||||
// Vimeo
|
||||
if ((int) $arguments['layout'] === 1) {
|
||||
return sprintf('https://player.vimeo.com/video/%d?html5=1', $arguments['value']);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user