Compare commits

..
1 Commits
Author SHA1 Message Date
Björn Fromme 25789612bf wip: groups bookings calendar 2026-07-14 16:32:15 +02:00
12 changed files with 60 additions and 489 deletions

No files matched your search

@@ -285,56 +285,6 @@ class Hotel extends AbstractEntity implements TeaserInterface
*/
protected $mainSeasonTo;
/**
* @var int
*/
protected $bedsCount = 0;
/**
* @var int
*/
protected $parkingCount = 0;
/**
* @var string
*/
protected $altitude = '';
/**
* @var string
*/
protected $shower = '';
/**
* @var bool
*/
protected $partyroom = false;
/**
* @var bool
*/
protected $gamesroom = false;
/**
* @var bool
*/
protected $sauna = false;
/**
* @var bool
*/
protected $wifi = false;
/**
* @var string
*/
protected $distanceBus = '';
/**
* @var string
*/
protected $distanceLift = '';
public function __construct()
{
$this->initStorageObjects();
@@ -1153,104 +1103,4 @@ class Hotel extends AbstractEntity implements TeaserInterface
{
$this->mainSeasonTo = $mainSeasonTo;
}
public function getBedsCount()
{
return $this->bedsCount;
}
public function setBedsCount($bedsCount)
{
$this->bedsCount = $bedsCount;
}
public function getParkingCount()
{
return $this->parkingCount;
}
public function setParkingCount($parkingCount)
{
$this->parkingCount = $parkingCount;
}
public function getAltitude()
{
return $this->altitude;
}
public function setAltitude($altitude)
{
$this->altitude = $altitude;
}
public function getShower()
{
return $this->shower;
}
public function setShower($shower)
{
$this->shower = $shower;
}
public function isPartyroom()
{
return $this->partyroom;
}
public function setPartyroom($partyroom)
{
$this->partyroom = $partyroom;
}
public function isGamesroom()
{
return $this->gamesroom;
}
public function setGamesroom($gamesroom)
{
$this->gamesroom = $gamesroom;
}
public function isSauna()
{
return $this->sauna;
}
public function setSauna($sauna)
{
$this->sauna = $sauna;
}
public function isWifi()
{
return $this->wifi;
}
public function setWifi($wifi)
{
$this->wifi = $wifi;
}
public function getDistanceBus()
{
return $this->distanceBus;
}
public function setDistanceBus($distanceBus)
{
$this->distanceBus = $distanceBus;
}
public function getDistanceLift()
{
return $this->distanceLift;
}
public function setDistanceLift($distanceLift)
{
$this->distanceLift = $distanceLift;
}
}
@@ -3,57 +3,17 @@
namespace EP\EpProducts\Middleware;
use EP\EpProducts\Service\MyEpImageService;
use EP\EpProducts\Service\ProductImageService;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Service\ImageService;
class ApiMiddleware implements MiddlewareInterface
class ProductApiMiddleware implements MiddlewareInterface
{
/**
* @var MyEpImageService
*/
private $hotelImageService;
/**
* @var MyEpImageService
*/
private $productImageService;
/**
* @var MyEpImageService
*/
private $regionImageService;
/**
* @var FileRepository
*/
private $fileRepository;
/**
* @var ImageService
*/
private $imageService;
public function __construct(
MyEpImageService $hotelImageService,
MyEpImageService $productImageService,
MyEpImageService $regionImageService,
FileRepository $fileRepository,
ImageService $imageService
) {
$this->hotelImageService = $hotelImageService;
$this->productImageService = $productImageService;
$this->regionImageService = $regionImageService;
$this->fileRepository = $fileRepository;
$this->imageService = $imageService;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$path = $request->getUri()->getPath();
@@ -131,15 +91,15 @@ class ApiMiddleware implements MiddlewareInterface
$data = $queryBuilder
->select(
'product.uid as productUid',
'product.name as productName',
'product.code as productCode',
'product.region as regionUid',
'country.name as countryName',
'region.name as regionName',
'city.name as cityName',
)
->from('tx_epproducts_domain_model_product', 'product')
->leftJoin('product', 'tx_epproducts_domain_model_country', 'country', 'product.country = country.uid')
->leftJoin('product', 'tx_epproducts_domain_model_region', 'region', 'product.region = region.uid')
->leftJoin('product', 'tx_epproducts_domain_model_city', 'city', 'product.city = city.uid')
->leftJoin('product', 'tx_epproducts_domain_model_matchcode', 'matchcode', 'product.uid = matchcode.entity AND matchcode.entity_type="hotel"')
->where($queryBuilder->expr()->eq('product.code', $queryBuilder->createNamedParameter($productCode)))
@@ -153,7 +113,8 @@ class ApiMiddleware implements MiddlewareInterface
return null;
}
$images = $this->serializeImages($this->productImageService->getImages((int) $data['productUid']));
$images = GeneralUtility::makeInstance(ProductImageService::class)
->getImages((int) $data['uid']);
return [
'product' => [
@@ -164,7 +125,9 @@ class ApiMiddleware implements MiddlewareInterface
'country' => [
'name' => $data['countryName'],
],
'region' => $this->fetchRegionData((int) $data['regionUid']),
'region' => [
'name' => $data['regionName'],
],
'city' => [
'name' => $data['cityName'],
],
@@ -186,17 +149,6 @@ class ApiMiddleware implements MiddlewareInterface
'hotel.room_types',
'hotel.additional_information',
'hotel.address',
'hotel.beds_count',
'hotel.parking_count',
'hotel.altitude',
'hotel.shower',
'hotel.partyroom',
'hotel.gamesroom',
'hotel.sauna',
'hotel.wifi',
'hotel.distance_bus',
'hotel.distance_lift',
'hotel.region',
)
->from('tx_epproducts_domain_model_hotel', 'hotel')
->leftJoin('hotel', 'tx_epproducts_domain_model_matchcode', 'alias', 'hotel.uid = alias.entity AND alias.entity_type="hotel"')
@@ -215,7 +167,8 @@ class ApiMiddleware implements MiddlewareInterface
return [];
}
$images = $this->serializeImages($this->hotelImageService->getImages((int) $hotel['uid']));
$images = GeneralUtility::makeInstance(MyEpImageService::class)
->getImages((int) $hotel['uid']);
return [
'name' => $hotel['name'],
@@ -226,101 +179,6 @@ class ApiMiddleware implements MiddlewareInterface
'additionalInformation' => $hotel['additional_information'],
'address' => $hotel['address'],
'images' => $images,
'icons' => [
'bedsCount' => (int) $hotel['beds_count'],
'parkingCount' => (int) $hotel['parking_count'],
'altitude' => $hotel['altitude'],
'shower' => $hotel['shower'],
'partyroom' => (bool) $hotel['partyroom'],
'gamesroom' => (bool) $hotel['gamesroom'],
'sauna' => (bool) $hotel['sauna'],
'wifi' => (bool) $hotel['wifi'],
'distanceBus' => $hotel['distance_bus'],
'distanceLift' => $hotel['distance_lift'],
],
'region' => $this->fetchRegionData((int) $hotel['region']),
];
}
private function fetchRegionData(int $regionUid): array
{
if (0 === $regionUid) {
return [];
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_epproducts_domain_model_region');
$region = $queryBuilder
->select(
'region.uid',
'region.name',
'region.latitude',
'region.longitude',
'region.ski_area',
'region.ski_area_extended',
'region.description',
'region.news',
'region.length',
'region.height',
'region.lifts',
'webcam.url as webcamUrl',
)
->from('tx_epproducts_domain_model_region', 'region')
->leftJoin('region', 'tx_epproducts_domain_model_webcam', 'webcam', 'region.webcam = webcam.uid')
->where($queryBuilder->expr()->eq('region.uid', $queryBuilder->createNamedParameter($regionUid, \PDO::PARAM_INT)))
->setMaxResults(1)
->execute()
->fetchAssociative()
;
if (false === $region) {
return [];
}
$images = $this->serializeImages($this->regionImageService->getImages((int) $region['uid']));
$regionMaps = $this->serializeFileReferences(
$this->fileRepository->findByRelation('tx_epproducts_domain_model_region', 'region_maps', (int) $region['uid'])
);
return [
'name' => $region['name'],
'latitude' => $region['latitude'],
'longitude' => $region['longitude'],
'webcam' => $region['webcamUrl'],
'ski_area' => $region['ski_area'],
'ski_area_extended' => $region['ski_area_extended'],
'description' => $region['description'],
'news' => $region['news'],
'length' => $region['length'],
'altitude' => $region['height'],
'lifts' => $region['lifts'],
'images' => $images,
'region_maps' => $regionMaps,
];
}
/**
* The 'original' entry of AbstractImageService::getImages() holds raw FileReference objects,
* which are needed by Fluid templates elsewhere but serialize to empty objects in JSON responses.
* We replace it with the same {url, alt, title} shape used for 'region_maps'.
*/
private function serializeImages(array $images): array
{
return [
'original' => $this->serializeFileReferences($images['original']),
'resized' => $images['resized'],
];
}
private function serializeFileReferences(array $files): array
{
return array_map(function ($file) {
return [
'url' => $this->imageService->getImageUri($file, true),
'alt' => $file->getProperty('alternative'),
'title' => $file->getProperty('title'),
];
}, $files);
}
}
@@ -26,12 +26,13 @@ namespace EP\EpProducts\Service;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Extbase\Service\ImageService;
class MyEpImageService extends AbstractImageService
{
/**
* @var string
*/
protected $table = 'tx_epproducts_domain_model_hotel';
/**
* @var string
*/
@@ -54,10 +55,4 @@ class MyEpImageService extends AbstractImageService
'height' => '960c-100',
]
];
public function __construct(FileRepository $fileRepository, ImageService $imageService, FrontendInterface $cache, string $table = 'tx_epproducts_domain_model_hotel')
{
parent::__construct($fileRepository, $imageService, $cache);
$this->table = $table;
}
}
@@ -12,7 +12,7 @@ return [
],
],
'ep/productapi' => [
'target' => \EP\EpProducts\Middleware\ApiMiddleware::class,
'target' => \EP\EpProducts\Middleware\ProductApiMiddleware::class,
'before' => [
'typo3/cms-frontend/page-resolver',
],
@@ -35,31 +35,3 @@ services:
EP\EpProducts\Controller\AjaxCalendarController:
arguments:
$cache: '@cache.ep_cache'
EP\EpProducts\Service\MyEpImageService:
arguments:
$cache: '@cache.ep_cache'
ep_products.image_service.hotel:
class: EP\EpProducts\Service\MyEpImageService
arguments:
$cache: '@cache.ep_cache'
$table: 'tx_epproducts_domain_model_hotel'
ep_products.image_service.product:
class: EP\EpProducts\Service\MyEpImageService
arguments:
$cache: '@cache.ep_cache'
$table: 'tx_epproducts_domain_model_product'
ep_products.image_service.region:
class: EP\EpProducts\Service\MyEpImageService
arguments:
$cache: '@cache.ep_cache'
$table: 'tx_epproducts_domain_model_region'
EP\EpProducts\Middleware\ApiMiddleware:
arguments:
$hotelImageService: '@ep_products.image_service.hotel'
$productImageService: '@ep_products.image_service.product'
$regionImageService: '@ep_products.image_service.region'
@@ -31,8 +31,7 @@ return [
--div--;Verknüpfungen, facts, teamer, additional_codes, mappings,
--div--;Bilder/Dateien, teaser_images, header_images, images, reseller_images,
--div--;Gruppenhaus Preise, --palette--;;season,--palette--;;others, groups_price_configs,
groups_price_boards, groups_price_options,
--div--;Gruppenhaus Icons, --palette--;;icons',
groups_price_boards, groups_price_options',
],
],
'palettes' => [
@@ -43,8 +42,7 @@ return [
'name' => ['showitem' => 'name,short_name,--linebreak--,header_title,header_subtitle,--linebreak--,headline'],
'categories' => ['showitem' => 'type,category'],
'season' => ['showitem' => 'main_season_from, main_season_to'],
'others' => ['showitem' => 'season,groups_price_tax_label, groups_price_adolescents_age'],
'icons' => ['showitem' => 'beds_count,parking_count,altitude,shower,partyroom,gamesroom,sauna,wifi,distance_bus,distance_lift'],
'others' => ['showitem' => 'season,groups_price_tax_label, groups_price_adolescents_age']
],
'columns' => [
@@ -760,87 +758,5 @@ return [
'renderType' => 'inputDateTime',
],
],
'beds_count' => [
'exclude' => 0,
'label' => 'Anzahl Betten',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'int',
],
],
'parking_count' => [
'exclude' => 0,
'label' => 'Anzahl Parkplätze',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'int',
],
],
'altitude' => [
'exclude' => 0,
'label' => 'Höhe',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'trim',
],
],
'shower' => [
'exclude' => 0,
'label' => 'Dusche',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'trim',
],
],
'partyroom' => [
'exclude' => 0,
'label' => 'Partyraum',
'config' => [
'type' => 'check',
],
],
'gamesroom' => [
'exclude' => 0,
'label' => 'Spieleraum',
'config' => [
'type' => 'check',
],
],
'sauna' => [
'exclude' => 0,
'label' => 'Sauna',
'config' => [
'type' => 'check',
],
],
'wifi' => [
'exclude' => 0,
'label' => 'WiFi',
'config' => [
'type' => 'check',
],
],
'distance_bus' => [
'exclude' => 0,
'label' => 'Entfernung zum Bus',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'trim',
],
],
'distance_lift' => [
'exclude' => 0,
'label' => 'Entfernung zum Lift',
'config' => [
'type' => 'input',
'size' => 50,
'eval' => 'trim',
],
],
],
];
@@ -260,16 +260,6 @@ CREATE TABLE tx_epproducts_domain_model_hotel
groups_price_tax_label varchar(255) DEFAULT '' NOT NULL,
main_season_from date DEFAULT NULL,
main_season_to date DEFAULT NULL,
beds_count int(11) DEFAULT '0' NOT NULL,
parking_count int(11) DEFAULT '0' NOT NULL,
altitude varchar(255) DEFAULT '' NOT NULL,
shower varchar(255) DEFAULT '' NOT NULL,
partyroom tinyint(4) unsigned DEFAULT '0' NOT NULL,
gamesroom tinyint(4) unsigned DEFAULT '0' NOT NULL,
sauna tinyint(4) unsigned DEFAULT '0' NOT NULL,
wifi tinyint(4) unsigned DEFAULT '0' NOT NULL,
distance_bus varchar(255) DEFAULT '' NOT NULL,
distance_lift varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
@@ -93,19 +93,17 @@
</f:else>
</f:if>
</div>
<f:if condition="{teasers -> f:count()} > 3">
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}"
additionalAttributes="{rel: 'nofollow'}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}"
additionalAttributes="{rel: 'nofollow'}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
</div>
</f:if>
@@ -101,18 +101,16 @@
</div>
</f:else>
</f:if>
<f:if condition="{teasers -> f:count()} > 3">
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
</div>
</f:then>
@@ -124,18 +124,16 @@
</div>
</f:else>
</f:if>
<f:if condition="{teasers -> f:count()} > 3">
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
</div>
</f:then>
@@ -240,7 +240,6 @@
</f:if>
</ul>
<f:comment><!--
<f:if condition="{includedServicesAllDates}">
<div class="headline--3 headline--underlined">
Inklusivleistungen
@@ -260,7 +259,6 @@
</ul>
</div>
</f:if>
--></f:comment>
<f:comment><!--
<f:if condition="{includedServicesSomeDates}">
@@ -89,18 +89,16 @@
</div>
</f:else>
</f:if>
<f:if condition="{teasers -> f:count()} > 3">
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
<f:if condition="{settings.hideMoreLink}">
<f:else>
<div class="text-right mt-4">
<f:link.typolink class="button bg-button"
parameter="{settings.defaultSearchPageUid}"
additionalParams="f={filterSettings -> ep:filterSettingsEncoder()}">
Alle anzeigen
</f:link.typolink>
</div>
</f:else>
</f:if>
</f:then>
<f:else>