first commit

This commit is contained in:
salam committed 2026-10-06 19:40:28 +02:00
commit e81864e683
2984 files changed
+267797

No files matched your search

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Validation;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
/**
* Class AbstractValidationViewHelper
*/
abstract class AbstractValidationViewHelper extends AbstractViewHelper
{
/**
* Get key for typoscript configuration "validation"
*
* @return string
* @throws FluidViewHelperException
*/
protected function getValidationName(): string
{
$validationName = 'validation';
// special case for second step in invitation
if (! $this->renderingContext instanceof RenderingContext) {
throw new FluidViewHelperException(
'Something went wrong; RenderingContext should be available in ViewHelper',
1638341336
);
}
if ($this->getControllerName() === 'invitation' &&
$this->renderingContext->getRequest()->getControllerActionName() === 'edit') {
$validationName = 'validationEdit';
}
return $validationName;
}
/**
* Return controllername in lowercase
*
* @return string "new", "edit", "invitation"
* @throws FluidViewHelperException
*/
protected function getControllerName(): string
{
if (! $this->renderingContext instanceof RenderingContext) {
throw new FluidViewHelperException(
'Something went wrong; RenderingContext should be available in ViewHelper',
1638341335
);
}
return strtolower($this->renderingContext->getRequest()->getControllerName());
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Validation;
use In2code\Femanager\Domain\Service\ValidationSettingsService;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class FormValidationDataViewHelper
*/
class FormValidationDataViewHelper extends AbstractValidationViewHelper implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Set javascript validation data for input fields
*
* @return array
*/
public function render()
{
$settings = $this->arguments['settings'];
$fieldName = $this->arguments['fieldName'];
$additionalAttributes = $this->arguments['additionalAttributes'];
if ($settings !== []) {
$this->logger->debug(
'Settings should not be filled any more in field partials. Pls update your femanager partial files.'
);
}
$validationService = GeneralUtility::makeInstance(
ValidationSettingsService::class,
$this->getControllerName(),
$this->getValidationName()
);
if ($validationService->isValidationEnabled('client')) {
$validationString = $validationService->getValidationStringForField($fieldName);
if (!empty($validationString)) {
if (!empty($additionalAttributes['data-validation'])) {
$additionalAttributes['data-validation'] .= ',' . $validationString;
} else {
$additionalAttributes['data-validation'] = $validationString;
}
}
}
return $additionalAttributes;
}
/**
* Initialize the arguments.
*
* @api
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('settings', 'array ', 'all TypoScript settings for this form', true);
$this->registerArgument('fieldName', 'string ', 'Fieldname which should get validated', true);
$this->registerArgument('additionalAttributes', 'array ', '$additionalAttributes for this field', false);
}
}
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Validation;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
* Class IsRequiredFieldViewHelper
*/
class IsRequiredFieldViewHelper extends AbstractValidationViewHelper
{
protected ConfigurationManagerInterface $configurationManager;
/**
* @param ConfigurationManagerInterface $configurationManager
*/
public function __construct(ConfigurationManagerInterface $configurationManager)
{
$this->configurationManager = $configurationManager;
}
/**
* Check if this field is a required field
*
* @return bool
*/
public function render()
{
$fieldName = $this->arguments['fieldName'];
$settings = $this->getSettingsConfiguration();
return !empty($settings[$this->getControllerName()][$this->getValidationName()][$fieldName]['required']);
}
/**
* @return array
*/
protected function getSettingsConfiguration()
{
return (array)$this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
'Femanager',
'Pi1'
);
}
/**
* Initialize the arguments.
*
* @api
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('fieldName', 'string ', 'Check if this field is a required field', true);
}
}