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,43 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use In2code\Femanager\Utility\BackendUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Class BackendEditLinkViewHelper
*/
class BackendEditLinkViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* initialize arguments
*/
public function initializeArguments()
{
$this->registerArgument('tableName', 'string', 'Records table name (like "fe_users")', true);
$this->registerArgument('identifier', 'integer', 'Record identifier to edit', true);
$this->registerArgument('addReturnUrl', 'bool', 'Add current URI as returnUrl', false, true);
}
/**
* Get an URI for backend edit
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): string {
return BackendUtility::getBackendEditUri($arguments['tableName'], $arguments['identifier'], $arguments['addReturnUrl']);
}
}
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use In2code\Femanager\Utility\BackendUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
/**
* Class BackendNewLinkViewHelper
*/
class BackendNewLinkViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;
/**
* initialize arguments
*/
public function initializeArguments()
{
$this->registerArgument('tableName', 'string', 'Records table name (like "fe_users")', true);
$this->registerArgument('addReturnUrl', 'bool', 'Add current URI as returnUrl', false, true);
}
/**
* Get an URI for new records in backend
*
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): string {
return BackendUtility::getBackendNewUri($arguments['tableName'], BackendUtility::getPageIdentifier(), $arguments['addReturnUrl']);
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as FluidViewHelperException;
/**
* Look if captcha is enabled
*/
class CaptchaEnabledViewHelper extends AbstractViewHelper
{
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('settings', 'bool', 'array $settings TypoScript', true);
}
/**
* Check if captcha is enabled
* @return bool
* @throws FluidViewHelperException
*/
public function render(): bool
{
if (! $this->renderingContext instanceof RenderingContext) {
throw new FluidViewHelperException(
'Something went wrong; RenderingContext should be available in ViewHelper',
1638341672
);
}
$controllerName = strtolower($this->renderingContext->getRequest()->getControllerName());
return ExtensionManagementUtility::isLoaded('sr_freecap')
&& $this->templateVariableContainer->getByPath('settings.' . $controllerName . '.validation.captcha.captcha');
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class ExplodeViewHelper
*/
class ExplodeViewHelper extends AbstractViewHelper
{
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('string', 'string', 'Any list (e.g. "a,b,c,d")', false);
$this->registerArgument('seperator', 'string', 'Separator sign (e.g. ",")', false, ',');
$this->registerArgument('trim', 'bool', 'Should be trimmed?', false, true);
}
/**
* View helper to explode a list
* @return array
*/
public function render()
{
$string = $this->arguments['string'];
$separator = $this->arguments['seperator'];
$trim = $this->arguments['trim'];
return $trim ? GeneralUtility::trimExplode($separator, $string, true) : explode($separator, $string);
}
}
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper;
/**
* Class GetFirstViewHelper
*/
class GetFirstViewHelper extends AbstractFormFieldViewHelper
{
/**
* Initialize the arguments.
*
* @api
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerArgument('objectStorage', 'object', 'first subobject of objectstorage', false);
}
/**
* View helper to get first subobject of objectstorage
*
* @return \mixed
*/
public function render()
{
$objectStorage = $this->arguments['objectStorage'];
if ($objectStorage === null) {
return null;
}
foreach ($objectStorage as $object) {
return $object;
}
// try to get value from originalRequest
if ($this->configurationManager->isFeatureEnabled('rewrittenPropertyMapper')) {
// seperate if version is 6.2 or lower
if ((method_exists($this, 'hasMappingErrorOccured') && $this->hasMappingErrorOccured()) ||
(method_exists($this, 'hasMappingErrorOccurred') && $this->hasMappingErrorOccurred())
) {
return $this->getValueAttribute();
}
}
return null;
}
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class JsonEncodeViewHelper
*/
class JsonEncodeViewHelper extends AbstractViewHelper
{
/**
* @var null
*/
protected $escapeOutput = false;
/**
* @return string
*/
public function render(): string
{
$array = $this->arguments['array'];
return json_encode($array);
}
/**
* Initialize the arguments.
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('array', 'array ', 'Json array', false);
}
}
@@ -0,0 +1,95 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class RequestViewHelper
*/
class RequestViewHelper extends AbstractViewHelper
{
/**
* @var array|string
*/
protected $variable = [];
/**
* @var int
*/
protected $depth = 1;
/**
* @var array
*/
protected $testVariables;
/**
* Get a GET or POST parameter
*
* @return string
*/
public function render(): string
{
$parameter = $this->arguments['parameter'];
$htmlspecialchars = $this->arguments['htmlspecialchars'];
$parts = $this->init($parameter);
$result = $this->getVariableFromDepth($parts);
if ($htmlspecialchars === true) {
if (is_string($result)) {
$result = htmlspecialchars($result);
}
}
if (is_array($result) or $result === null) {
// ensure that the return value is always as string
$result='';
}
return $result;
}
/**
* @param array $param
* @return array|string
*/
protected function getVariableFromDepth(array $param)
{
if (is_array($this->variable)) {
$this->variable = $this->variable[$param[$this->depth]] ?? null;
$this->depth++;
$this->getVariableFromDepth($param);
}
return $this->variable;
}
/**
* Initially sets $this->variable
*
* @param $parameter
* @return array
*/
protected function init($parameter)
{
$parts = explode('|', $parameter);
$this->variable = GeneralUtility::_GP($parts[0]);
if ($this->testVariables) {
$this->variable = $this->testVariables[$parts[0]];
}
return $parts;
}
/**
* Register all arguments for this viewhelper
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('parameter', 'string', 'like tx_ext_pi1|list|field', false, '');
$this->registerArgument('htmlspecialchars', 'bool', 'Enable/Disable htmlspecialchars', false, true);
}
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace In2code\Femanager\ViewHelpers\Misc;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class UpperViewHelper
*/
class UpperViewHelper extends AbstractViewHelper
{
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('string', 'string', 'string', false);
}
public function render(): string
{
return ucfirst((string)($this->arguments['string'] ?? ''));
}
}