Formular-Infrastruktur: Contact/Demo/Helpdesk mit E-Mail- und Salesforce-Delivery, JSON-Renderer-Erweiterungen, Crop-Variants
Build-Artefakte in public/_frontend/assets nicht enthalten.
This commit is contained in:
1 parent
eae40f4286
commit
a739dd8fe3
51 files changed
+1598
-303
No files matched your search
@@ -204,13 +204,13 @@ class CustomerlogosJsonRenderer
|
||||
foreach (self::IMAGE_WIDTHS as $width) {
|
||||
$variant = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => $width, 'crop' => $ref['crop'] ?? null]
|
||||
['width' => $width, 'crop' => $ref['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
$srcset[] = ['url' => $imageService->getImageUri($variant), 'width' => $width, 'descriptor' => $width . 'w'];
|
||||
}
|
||||
$default = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 400, 'crop' => $ref['crop'] ?? null]
|
||||
['width' => 400, 'crop' => $ref['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -338,7 +338,7 @@ class DatasheetsJsonRenderer
|
||||
|
||||
$default = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 400, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 400, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -211,7 +211,7 @@ class DownloadcardcollectionJsonRenderer
|
||||
foreach ([400, 800, 1200, 1600] as $width) {
|
||||
$variant = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
$srcset[] = [
|
||||
'url' => $imageService->getImageUri($variant),
|
||||
@@ -222,7 +222,7 @@ class DownloadcardcollectionJsonRenderer
|
||||
|
||||
$default = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -247,7 +247,7 @@ class EventlistJsonRenderer
|
||||
foreach ([400, 800] as $width) {
|
||||
$variant = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
$srcset[] = [
|
||||
'url' => $imageService->getImageUri($variant),
|
||||
@@ -258,7 +258,7 @@ class EventlistJsonRenderer
|
||||
|
||||
$default = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 400, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 400, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Evomedien\Vitec\UserFunc;
|
||||
|
||||
use TYPO3\CMS\Core\Attribute\AsAllowedCallable;
|
||||
|
||||
/**
|
||||
* Headless JSON renderer for the site-wide favicon / app-icon set.
|
||||
*
|
||||
* Emits a stable `favicons` object into every page response so the React
|
||||
* frontend can render the <link>/<meta> head tags from the CMS instead of
|
||||
* hard-coding them. The icon files live under public/fileadmin/icons/ and are
|
||||
* referenced root-relative — identical convention to the image URLs emitted by
|
||||
* UsecaseSerializer::image() (getImageUri also returns /fileadmin/... paths).
|
||||
* If the frontend ever runs on a separate origin from the CMS, it must prefix
|
||||
* these hrefs with the CMS base URL, exactly as it does for image URLs.
|
||||
*
|
||||
* Static by nature (same for every page) — no DB access, exception-free.
|
||||
*/
|
||||
final class FaviconsJsonRenderer
|
||||
{
|
||||
private const BASE = '/fileadmin/icons';
|
||||
|
||||
/** Browser UI / address-bar tint (VITEC navy). */
|
||||
private const THEME_COLOR = '#26358C';
|
||||
|
||||
#[AsAllowedCallable]
|
||||
public function render(string $content, array $conf): string
|
||||
{
|
||||
$payload = [
|
||||
'themeColor' => self::THEME_COLOR,
|
||||
'manifest' => self::BASE . '/site.webmanifest',
|
||||
// Ready-to-render <link> descriptors, ordered most- to least-specific.
|
||||
'links' => [
|
||||
['rel' => 'icon', 'type' => 'image/x-icon', 'href' => self::BASE . '/favicon.ico'],
|
||||
['rel' => 'icon', 'type' => 'image/png', 'sizes' => '32x32', 'href' => self::BASE . '/favicon-32.png'],
|
||||
['rel' => 'icon', 'type' => 'image/png', 'sizes' => '16x16', 'href' => self::BASE . '/favicon-16.png'],
|
||||
['rel' => 'apple-touch-icon', 'sizes' => '180x180', 'href' => self::BASE . '/apple-touch-icon.png'],
|
||||
['rel' => 'manifest', 'href' => self::BASE . '/site.webmanifest'],
|
||||
],
|
||||
];
|
||||
|
||||
return json_encode($payload) ?: '';
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Evomedien\Vitec\UserFunc;
|
||||
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Evomedien\Vitec\Forms\FormDefinitions;
|
||||
use TYPO3\CMS\Core\Attribute\AsAllowedCallable;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Service\FlexFormService;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* UserFunc: render ONE of the VITEC form plugins as JSON (headless).
|
||||
* Serves vitec_contactform, vitec_demoform and vitec_helpdeskform — the
|
||||
* CType picks the definition from FormDefinitions.
|
||||
*
|
||||
* Output under content.form:
|
||||
* { "formKey": "contact", "title": "…", "endpoint": "/api/vitec/form/contact",
|
||||
* "honeypot": "_website", "fields": [ … ] }
|
||||
*
|
||||
* The React frontend renders the fields generically and POSTs JSON to the
|
||||
* endpoint (handled by FormSubmissionMiddleware). Exception-safe.
|
||||
*/
|
||||
class FormsJsonRenderer
|
||||
{
|
||||
#[AsAllowedCallable]
|
||||
public function render(string $content, array $conf): string
|
||||
{
|
||||
$row = is_array($this->cObj->data ?? null) ? $this->cObj->data : null;
|
||||
if ($row && isset(FormDefinitions::CTYPE_MAP[(string)($row['CType'] ?? '')])) {
|
||||
return $this->renderForRecord($row);
|
||||
}
|
||||
|
||||
$pageId = 0;
|
||||
$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
|
||||
if ($request !== null) {
|
||||
$pageInfo = $request->getAttribute('frontend.page.information');
|
||||
if ($pageInfo !== null) {
|
||||
$pageId = (int)$pageInfo->getId();
|
||||
}
|
||||
}
|
||||
if ($pageId <= 0) {
|
||||
$pageId = (int)($GLOBALS['TSFE']->id ?? 0);
|
||||
}
|
||||
if ($pageId <= 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
|
||||
$ces = $qb
|
||||
->select('*')
|
||||
->from('tt_content')
|
||||
->where(
|
||||
$qb->expr()->eq('pid', $qb->createNamedParameter($pageId, ParameterType::INTEGER)),
|
||||
$qb->expr()->in('CType', $qb->createNamedParameter(
|
||||
array_keys(FormDefinitions::CTYPE_MAP),
|
||||
\TYPO3\CMS\Core\Database\Connection::PARAM_STR_ARRAY
|
||||
)),
|
||||
$qb->expr()->eq('deleted', 0),
|
||||
$qb->expr()->eq('hidden', 0)
|
||||
)
|
||||
->executeQuery()
|
||||
->fetchAllAssociative();
|
||||
|
||||
if (empty($ces)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->renderForRecord($ces[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $contentElement
|
||||
*/
|
||||
public function renderForRecord(array $contentElement): string
|
||||
{
|
||||
try {
|
||||
$formKey = FormDefinitions::CTYPE_MAP[(string)($contentElement['CType'] ?? '')] ?? '';
|
||||
$definition = FormDefinitions::get($formKey);
|
||||
if ($definition === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
|
||||
$flexFormData = $flexFormService->convertFlexFormContentToArray($contentElement['pi_flexform'] ?? '');
|
||||
$settings = $flexFormData['settings'] ?? [];
|
||||
$debugMode = (bool)($settings['debug'] ?? false);
|
||||
|
||||
$response = [
|
||||
'formKey' => $definition['formKey'],
|
||||
'title' => $definition['title'],
|
||||
'endpoint' => '/api/vitec/form/' . $definition['formKey'],
|
||||
'honeypot' => FormDefinitions::HONEYPOT_FIELD,
|
||||
'fields' => $definition['fields'],
|
||||
];
|
||||
|
||||
if ($debugMode) {
|
||||
$response['debug'] = ['settings' => $settings];
|
||||
}
|
||||
|
||||
return (string)json_encode($response);
|
||||
} catch (\Throwable $e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class MarketShowJsonRenderer
|
||||
foreach ([400, 800, 1200, 1600] as $width) {
|
||||
$variant = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
$srcset[] = [
|
||||
'url' => $imageService->getImageUri($variant),
|
||||
@@ -212,7 +212,7 @@ class MarketShowJsonRenderer
|
||||
|
||||
$default = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -157,8 +157,8 @@ class ModelcardJsonRenderer
|
||||
'slug' => (string)($row['slug'] ?? ''),
|
||||
'subtitle' => (string)($row['subtitle'] ?? ''),
|
||||
'teaser' => (string)($row['teaser'] ?? ''),
|
||||
'image' => $serializer->image($uid, 'image', 'tx_vitec_domain_model_product')
|
||||
?? $serializer->image($uid, 'productimage', 'tx_vitec_domain_model_product'),
|
||||
'image' => $serializer->image($uid, 'image', 'tx_vitec_domain_model_product', true)
|
||||
?? $serializer->image($uid, 'productimage', 'tx_vitec_domain_model_product', true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class ModelcardJsonRenderer
|
||||
'subtitle' => (string)($row['subtitle'] ?? ''),
|
||||
'teaser' => (string)($row['teaser'] ?? ''),
|
||||
'description' => (string)($row['description'] ?? ''),
|
||||
'image' => $serializer->image($uid, 'image', self::MODEL_TABLES[$modelType]),
|
||||
'image' => $serializer->image($uid, 'image', self::MODEL_TABLES[$modelType], true),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -596,7 +596,7 @@ final class NewsJsonRenderer
|
||||
foreach ($rows as $row) {
|
||||
try {
|
||||
$fileReference = $resourceFactory->getFileReferenceObject((int)$row['uid']);
|
||||
$processed = $imageService->applyProcessingInstructions($fileReference, ['width' => 1400]);
|
||||
$processed = $imageService->applyProcessingInstructions($fileReference, ['width' => 1400, 'fileExtension' => 'webp']);
|
||||
|
||||
$files[] = [
|
||||
'uid' => (int)$row['uid'],
|
||||
|
||||
@@ -246,7 +246,8 @@ class ProductListJsonRenderer
|
||||
[
|
||||
'width' => $dimensions['width'],
|
||||
'height' => $dimensions['height'],
|
||||
'crop' => $fileRefData['crop'] ?? null
|
||||
'crop' => $fileRefData['crop'] ?? null,
|
||||
'fileExtension' => 'webp'
|
||||
]
|
||||
);
|
||||
|
||||
@@ -260,7 +261,7 @@ class ProductListJsonRenderer
|
||||
|
||||
$defaultProcessed = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
$images[] = [
|
||||
@@ -318,7 +319,7 @@ class ProductListJsonRenderer
|
||||
|
||||
$processed = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 1200, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 1200, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -327,14 +327,14 @@ class ProductShowJsonRenderer
|
||||
|
||||
$processedImage = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => '1874c', 'height' => '625c']
|
||||
['width' => '1874c', 'height' => '625c', 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
$srcset = [];
|
||||
foreach ([400, 800, 1200, 1600] as $width) {
|
||||
$processedVariant = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => $width . 'c', 'height' => (int)($width / 3) . 'c']
|
||||
['width' => $width . 'c', 'height' => (int)($width / 3) . 'c', 'fileExtension' => 'webp']
|
||||
);
|
||||
$srcset[] = [
|
||||
'url' => $imageService->getImageUri($processedVariant),
|
||||
@@ -399,7 +399,7 @@ class ProductShowJsonRenderer
|
||||
|
||||
$processedImage = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 1200]
|
||||
['width' => 1200, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
@@ -201,7 +201,7 @@ class SolutionShowJsonRenderer
|
||||
foreach ([400, 800, 1200, 1600] as $width) {
|
||||
$variant = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => $width, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
$srcset[] = [
|
||||
'url' => $imageService->getImageUri($variant),
|
||||
@@ -212,7 +212,7 @@ class SolutionShowJsonRenderer
|
||||
|
||||
$default = $imageService->applyProcessingInstructions(
|
||||
$fileReference,
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null]
|
||||
['width' => 800, 'crop' => $fileRefData['crop'] ?? null, 'fileExtension' => 'webp']
|
||||
);
|
||||
|
||||
return [
|
||||
|
||||
Reference in new issue
Block a user