[CHORE] Remove old code
This commit is contained in:
parent
30f3dd37d0
commit
2e75454bb0
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Form\FormDataProvider;
|
||||
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\SiteDatabaseEditRow;
|
||||
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
|
||||
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
readonly class UsercentricsDatabaseEditRow extends SiteDatabaseEditRow
|
||||
{
|
||||
public function __construct(private SiteConfiguration $siteConfiguration)
|
||||
{
|
||||
parent::__construct($this->siteConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* First level of ['customData']['siteData'] to ['databaseRow']
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function addData(array $result): array
|
||||
{
|
||||
if ($result['command'] !== 'edit' || $result['tableName'] !== 'site_usercentrics') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class, $this->siteConfiguration);
|
||||
|
||||
$rootPageId = (int)($result['inlineTopMostParentUid'] ?? $result['inlineParentUid']);
|
||||
try {
|
||||
$rowData = $this->getRawConfigurationForSiteWithRootPageId($siteFinder, $rootPageId);
|
||||
$parentFieldName = $result['inlineParentFieldName'];
|
||||
if (!isset($rowData[$parentFieldName])) {
|
||||
throw new \RuntimeException('Field "' . $parentFieldName . '" not found', 1520886092);
|
||||
}
|
||||
$rowData = $rowData[$parentFieldName][$result['vanillaUid']];
|
||||
$result['databaseRow']['uid'] = $result['vanillaUid'];
|
||||
} catch (SiteNotFoundException) {
|
||||
$rowData = [];
|
||||
}
|
||||
|
||||
foreach ($rowData as $fieldName => $value) {
|
||||
// Flat values only - databaseRow has no "tree"
|
||||
if (!is_array($value)) {
|
||||
$result['databaseRow'][$fieldName] = $value;
|
||||
}
|
||||
}
|
||||
// All "records" are always on pid 0
|
||||
$result['databaseRow']['pid'] = 0;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Form\FormDataProvider;
|
||||
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\SiteTcaInline;
|
||||
|
||||
/**
|
||||
* Special data provider for the sites configuration module.
|
||||
*
|
||||
* Handle inline children of 'site'
|
||||
*/
|
||||
class UsercentricsTcaInline extends SiteTcaInline
|
||||
{
|
||||
/**
|
||||
* Resolve inline fields
|
||||
*
|
||||
* @param array $result
|
||||
* @return array
|
||||
*/
|
||||
public function addData(array $result): array
|
||||
{
|
||||
$result = $this->addInlineFirstPid($result);
|
||||
foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
|
||||
if (!$this->isInlineField($fieldConfig)) {
|
||||
continue;
|
||||
}
|
||||
$childTableName = $fieldConfig['config']['foreign_table'] ?? '';
|
||||
if ($childTableName !== 'site_usercentrics') {
|
||||
continue;
|
||||
}
|
||||
$result['processedTca']['columns'][$fieldName]['children'] = [];
|
||||
$result = $this->resolveSiteRelatedChildren($result, $fieldName);
|
||||
if (!empty($result['processedTca']['columns'][$fieldName]['config']['selectorOrUniqueConfiguration'])) {
|
||||
throw new \RuntimeException('selectorOrUniqueConfiguration not implemented in sites module', 1624313533);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Hooks;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use TYPO3\CMS\Core\Core\Environment;
|
||||
use TYPO3\CMS\Core\Site\Entity\Site;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
|
||||
class UsercentricsPostRenderHook
|
||||
{
|
||||
private array $siteArguments = [
|
||||
'id' => '',
|
||||
'version' => 'loader',
|
||||
'useBlocker' => false,
|
||||
];
|
||||
|
||||
protected ?Site $site = null;
|
||||
|
||||
public function __construct(protected SiteFinder $siteFinder) {}
|
||||
|
||||
public function executePostRenderHook(array $params): void
|
||||
{
|
||||
$pageUid = $this->getRequest()->getAttribute('frontend.controller')->page['uid'] ?? 0;
|
||||
if ($pageUid < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$siteArguments = $this->getCurrentSiteArguments($pageUid);
|
||||
$id = $siteArguments['id'] ?? '';
|
||||
if ($id !== '') {
|
||||
$extensionConfig = $this->getExtensionConfiguration($pageUid);
|
||||
|
||||
$preload = [];
|
||||
$userCentrics = [];
|
||||
|
||||
// CMP 1, 2, ...
|
||||
$version = $siteArguments['version'] ?? '';
|
||||
if ($config = $extensionConfig[$version] ?? false) {
|
||||
$preload[] = $config['preload'] ?? '';
|
||||
$userCentrics[] = $config['template'] ?? '';
|
||||
}
|
||||
|
||||
// Blocker
|
||||
if (
|
||||
($siteArguments['useBlocker'] ?? false)
|
||||
&& $config = $extensionConfig['block'] ?? false
|
||||
) {
|
||||
$preload[] = $config['preload'] ?? '';
|
||||
$userCentrics[] = $config['template'] ?? '';
|
||||
}
|
||||
|
||||
$params['titleTag'] .= str_replace('###ID###', $id, implode(LF, array_merge($preload, $userCentrics)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getCurrentSiteArguments(int $pageUid): array
|
||||
{
|
||||
$siteArguments = $this->siteArguments;
|
||||
|
||||
$site = $this->getSiteByPageUid($pageUid);
|
||||
try {
|
||||
foreach ($site->getAttribute('usercentrics') as $usercentrics) {
|
||||
if (str_contains($usercentrics['applicationContext'] ?? '', (string)Environment::getContext())) {
|
||||
$siteArguments = $usercentrics;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception) {
|
||||
$siteArguments = [];
|
||||
}
|
||||
|
||||
return is_array($siteArguments) ? $siteArguments : [];
|
||||
}
|
||||
|
||||
protected function getExtensionConfiguration($pageUid): array
|
||||
{
|
||||
$siteSettings = $this->getSiteByPageUid($pageUid)->getSettings();
|
||||
$configuration = $siteSettings->has('ew-base') ? $siteSettings->get('ew-base') : [];
|
||||
return is_array($configuration['userCentrics'] ?? false) ? $configuration['userCentrics'] : [];
|
||||
}
|
||||
|
||||
protected function getSiteByPageUid(int $pageUid): Site
|
||||
{
|
||||
if (!$this->site) {
|
||||
try {
|
||||
$this->site = $this->siteFinder->getSiteByPageId($pageUid);
|
||||
} catch (\Exception) {
|
||||
}
|
||||
}
|
||||
return $this->site;
|
||||
}
|
||||
|
||||
protected function getRequest(): ServerRequestInterface
|
||||
{
|
||||
return $GLOBALS['TYPO3_REQUEST'];
|
||||
}
|
||||
}
|
||||
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Updates;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
|
||||
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
|
||||
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
|
||||
use TYPO3\CMS\Core\Log\LogManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
|
||||
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
|
||||
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
|
||||
|
||||
/**
|
||||
* Migrate gridelements elements to container elements
|
||||
*/
|
||||
#[UpgradeWizard('gridelementsToContainer')]
|
||||
class GridelementsToContainerMigration implements UpgradeWizardInterface
|
||||
{
|
||||
private const TABLE_NAME = 'tt_content';
|
||||
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
protected GridelementsToContainerService $service,
|
||||
protected LogManager $logManager,
|
||||
) {
|
||||
$this->logger = $logManager->getLogger(self::class);
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Migrate gridelements to container';
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Migrates content elements that are type gridelements to corresponding container elements';
|
||||
}
|
||||
|
||||
public function getPrerequisites(): array
|
||||
{
|
||||
return [
|
||||
DatabaseUpdatedPrerequisite::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function updateNecessary(): bool
|
||||
{
|
||||
return $this->hasRecordsToUpdate();
|
||||
}
|
||||
|
||||
public function executeUpdate(): bool
|
||||
{
|
||||
$updateSuccessful = true;
|
||||
try {
|
||||
$this->service->migrate();
|
||||
} catch (\Exception $exception) {
|
||||
$this->logger->log(LogLevel::ERROR, $exception->getMessage());
|
||||
$updateSuccessful = false;
|
||||
}
|
||||
|
||||
return $updateSuccessful;
|
||||
}
|
||||
|
||||
protected function hasRecordsToUpdate(): bool
|
||||
{
|
||||
return (bool)$this->getPreparedQueryBuilder()->count('uid')->executeQuery()->fetchOne();
|
||||
}
|
||||
|
||||
protected function getPreparedQueryBuilder(): QueryBuilder
|
||||
{
|
||||
$queryBuilder = $this->getConnectionPool()->getQueryBuilderForTable(self::TABLE_NAME);
|
||||
$queryBuilder->getRestrictions()
|
||||
->removeByType(HiddenRestriction::class)
|
||||
->removeByType(StartTimeRestriction::class)
|
||||
->removeByType(EndTimeRestriction::class);
|
||||
$queryBuilder
|
||||
->from(self::TABLE_NAME)
|
||||
->where(
|
||||
$queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('gridelements_pi1'))
|
||||
);
|
||||
return $queryBuilder;
|
||||
}
|
||||
|
||||
protected function getConnectionPool(): ConnectionPool
|
||||
{
|
||||
return GeneralUtility::makeInstance(ConnectionPool::class);
|
||||
}
|
||||
}
|
||||
@ -1,277 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Updates;
|
||||
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
|
||||
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
|
||||
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
|
||||
use TYPO3\CMS\Core\DataHandling\DataHandler;
|
||||
use TYPO3\CMS\Core\Service\FlexFormService;
|
||||
use TYPO3\CMS\Core\Utility\ArrayUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ew_base']['migrationResolveContainer'] = [];
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ew_base']['migrationColPosOffset'] = 0;
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ew_base']['migrationMapping'] = [
|
||||
'130' => [
|
||||
'CType' => 'three-col-columns',
|
||||
],
|
||||
'140' => [
|
||||
'CType' => [
|
||||
'search' => 'pi_flexform/type',
|
||||
'matches' => [
|
||||
0 => 'two-col-columns-11',
|
||||
1 => 'two-col-columns-12',
|
||||
2 => 'two-col-columns-21',
|
||||
],
|
||||
],
|
||||
'map' => [
|
||||
'pi_flexform/row_class' => 'frame_class',
|
||||
]
|
||||
],
|
||||
];
|
||||
*/
|
||||
class GridelementsToContainerService
|
||||
{
|
||||
private const TABLE_NAME = 'tt_content';
|
||||
|
||||
protected array $resolveContainer = [];
|
||||
|
||||
protected int $colPosOffset = 0;
|
||||
|
||||
protected array $configuration = [];
|
||||
|
||||
public function __construct(
|
||||
protected ConnectionPool $connectionPool,
|
||||
protected DataHandler $dataHandler,
|
||||
protected FlexFormService $flexFormService,
|
||||
) {
|
||||
$config = & $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['ew_base'];
|
||||
$this->resolveContainer = $config['migrationResolveContainer'] ?? [];
|
||||
$this->colPosOffset = $config['migrationColPosOffset'] ?? 0;
|
||||
$this->configuration = $config['migrationMapping'] ?? [];
|
||||
}
|
||||
|
||||
public function migrate(): void
|
||||
{
|
||||
$this->initializeDataHandler();
|
||||
|
||||
// Move children out of container and remove container
|
||||
foreach ($this->resolveContainer as $containerId) {
|
||||
$this->resolveContainers((string)$containerId);
|
||||
}
|
||||
|
||||
$this->migrateConfiguredContainer();
|
||||
}
|
||||
|
||||
protected function initializeDataHandler(): void
|
||||
{
|
||||
$backendUser = GeneralUtility::makeInstance(BackendUserAuthentication::class);
|
||||
$backendUser->user = [
|
||||
'uid' => 0,
|
||||
'admin' => 1,
|
||||
];
|
||||
$this->dataHandler->start([], [], $backendUser);
|
||||
}
|
||||
|
||||
protected function resolveContainers(string $layout): void
|
||||
{
|
||||
$containers = $this->getGridElementsByLayout($layout);
|
||||
foreach ($containers as $container) {
|
||||
$this->processContainerResolve($container);
|
||||
}
|
||||
}
|
||||
|
||||
protected function processContainerResolve(array $container): void
|
||||
{
|
||||
$children = $this->getGridContainerChildren($container['uid']);
|
||||
// move first child after container
|
||||
$moveAfterThis = $container;
|
||||
foreach ($children as $child) {
|
||||
[$moveAfterThis, $container] = $this->processContainerResolveChild($child, $moveAfterThis, $container);
|
||||
}
|
||||
|
||||
$this->deleteElement($container['uid']);
|
||||
}
|
||||
|
||||
protected function processContainerResolveChild(array $child, array $moveAfterThis, array $container): array
|
||||
{
|
||||
$this->updateElement(
|
||||
$child['uid'],
|
||||
[
|
||||
'tx_gridelements_container' => 0,
|
||||
'colPos' => $container['colPos'],
|
||||
'header' => $child['header'] ?: $container['header'],
|
||||
]
|
||||
);
|
||||
$this->moveElementAfterElement($child['uid'], $moveAfterThis['uid']);
|
||||
// use this child to move the next child after
|
||||
$moveAfterThis = $child;
|
||||
// empty container header so only the first child gets the header
|
||||
$container['header'] = '';
|
||||
|
||||
return [$moveAfterThis, $container];
|
||||
}
|
||||
|
||||
protected function deleteElement(int $uid): void
|
||||
{
|
||||
$this->connectionPool
|
||||
->getConnectionForTable(self::TABLE_NAME)
|
||||
->update(self::TABLE_NAME, ['delete' => 1], ['uid' => $uid]);
|
||||
}
|
||||
|
||||
protected function moveElementAfterElement(int $elementToMove, int $elementToMoveAfter): void
|
||||
{
|
||||
$this->dataHandler->moveRecord(self::TABLE_NAME, $elementToMove, $elementToMoveAfter * -1);
|
||||
}
|
||||
|
||||
protected function migrateConfiguredContainer(): void
|
||||
{
|
||||
array_walk($this->configuration, function ($config, $key) {
|
||||
$containers = $this->getGridElementsByLayout((string)$key);
|
||||
foreach ($containers as $container) {
|
||||
$container['pi_flexform'] = $this->flexFormService->convertFlexFormContentToArray(
|
||||
$container['pi_flexform']
|
||||
);
|
||||
$this->processContainerMigration($container, $config);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function processContainerMigration(array $container, array $config): void
|
||||
{
|
||||
$children = $this->getGridContainerChildren($container['uid']);
|
||||
foreach ($children as $child) {
|
||||
$this->processContainerMigrationChild($child, $container);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'CType' => $this->getCType($container, $config),
|
||||
'tx_gridelements_backend_layout' => '',
|
||||
];
|
||||
|
||||
if (isset($config['map']) && is_array($config['map']) && !empty($container['pi_flexform'])) {
|
||||
$data = $this->addMappedValues($data, $container, $config['map']);
|
||||
}
|
||||
|
||||
$this->updateElement($container['uid'], $data);
|
||||
}
|
||||
|
||||
protected function processContainerMigrationChild(array $child, array $container): void
|
||||
{
|
||||
$this->updateElement(
|
||||
$child['uid'],
|
||||
[
|
||||
'hidden' => $child['hidden'] ?: $container['hidden'],
|
||||
'colPos' => $child['tx_gridelements_columns'] + $this->colPosOffset,
|
||||
'tx_container_parent' => $child['tx_gridelements_container'],
|
||||
'tx_gridelements_columns' => 0,
|
||||
'tx_gridelements_container' => 0,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCType(array $container, array $config): string
|
||||
{
|
||||
if (is_array($config['CType'])) {
|
||||
$value = ArrayUtility::getValueByPath($container, $config['CType']['search']);
|
||||
$result = $config['CType']['matches'][$value] ?? null;
|
||||
} else {
|
||||
$result = $config['CType'] ?? null;
|
||||
}
|
||||
|
||||
if (empty($result)) {
|
||||
throw new \Exception('CType must always be set');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function addMappedValues(array $data, array $container, array $config): array
|
||||
{
|
||||
foreach ($config as $from => $to) {
|
||||
try {
|
||||
$value = ArrayUtility::getValueByPath($container, $from);
|
||||
if (empty($container[$to]) && !empty($value)) {
|
||||
$data[$to] = $value;
|
||||
}
|
||||
} catch (\throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function updateElement(int $uid, array $changes): void
|
||||
{
|
||||
$this->connectionPool
|
||||
->getConnectionForTable(self::TABLE_NAME)
|
||||
->update(self::TABLE_NAME, $changes, ['uid' => $uid]);
|
||||
}
|
||||
|
||||
protected function getGridContainerChildren(int $containerUid): array
|
||||
{
|
||||
$queryBuilder = $this->getQueryBuilderForTable();
|
||||
|
||||
return $queryBuilder
|
||||
->select('*')
|
||||
->where(
|
||||
$queryBuilder->expr()->eq(
|
||||
'tx_gridelements_container',
|
||||
$queryBuilder->createNamedParameter($containerUid, ParameterType::INTEGER)
|
||||
)
|
||||
)
|
||||
->orderBy('sorting')
|
||||
->executeQuery()
|
||||
->fetchAllAssociative();
|
||||
}
|
||||
|
||||
protected function getGridElementsByLayout(string $layout): array
|
||||
{
|
||||
$queryBuilder = $this->getQueryBuilderForTable();
|
||||
$expr = $queryBuilder->expr();
|
||||
|
||||
return $queryBuilder
|
||||
->select('*')
|
||||
->where(
|
||||
$expr->eq('CType', $queryBuilder->createNamedParameter('gridelements_pi1')),
|
||||
$expr->eq('tx_gridelements_backend_layout', $queryBuilder->createNamedParameter($layout))
|
||||
)
|
||||
->orderBy('sorting')
|
||||
->executeQuery()
|
||||
->fetchAllAssociative();
|
||||
}
|
||||
|
||||
protected function getQueryBuilderForTable(string $table = 'tt_content'): QueryBuilder
|
||||
{
|
||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
|
||||
->getQueryBuilderForTable($table);
|
||||
|
||||
$queryBuilder->getRestrictions()
|
||||
->removeByType(HiddenRestriction::class)
|
||||
->removeByType(StartTimeRestriction::class)
|
||||
->removeByType(EndTimeRestriction::class);
|
||||
|
||||
$queryBuilder->from($table);
|
||||
|
||||
return $queryBuilder;
|
||||
}
|
||||
}
|
||||
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Xclass;
|
||||
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\SiteDatabaseEditRow as BaseSiteDatabaseEditRow;
|
||||
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
|
||||
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
|
||||
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
readonly class SiteDatabaseEditRow extends BaseSiteDatabaseEditRow
|
||||
{
|
||||
public function __construct(private SiteConfiguration $siteConfiguration)
|
||||
{
|
||||
parent::__construct($this->siteConfiguration);
|
||||
}
|
||||
|
||||
/**
|
||||
* First level of ['customData']['siteData'] to ['databaseRow']
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function addData(array $result): array
|
||||
{
|
||||
if ($result['command'] !== 'edit' || !empty($result['databaseRow'])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$tableName = $result['tableName'];
|
||||
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class, $this->siteConfiguration);
|
||||
if ($tableName === 'site') {
|
||||
$rootPageId = (int)$result['vanillaUid'];
|
||||
$rowData = $this->getRawConfigurationForSiteWithRootPageId($siteFinder, $rootPageId);
|
||||
$result['databaseRow']['uid'] = $rowData['rootPageId'];
|
||||
$result['databaseRow']['identifier'] = $result['customData']['siteIdentifier'];
|
||||
} elseif (
|
||||
in_array(
|
||||
$tableName,
|
||||
['site_errorhandling', 'site_language', 'site_route', 'site_base_variant'],
|
||||
true
|
||||
)
|
||||
) {
|
||||
$rootPageId = (int)($result['inlineTopMostParentUid'] ?? $result['inlineParentUid']);
|
||||
try {
|
||||
$rowData = $this->getRawConfigurationForSiteWithRootPageId($siteFinder, $rootPageId);
|
||||
$parentFieldName = $result['inlineParentFieldName'];
|
||||
if (!isset($rowData[$parentFieldName])) {
|
||||
throw new \RuntimeException('Field "' . $parentFieldName . '" not found', 1520886092);
|
||||
}
|
||||
$rowData = $rowData[$parentFieldName][$result['vanillaUid']];
|
||||
$result['databaseRow']['uid'] = $result['vanillaUid'];
|
||||
} catch (SiteNotFoundException) {
|
||||
$rowData = [];
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($rowData as $fieldName => $value) {
|
||||
// Flat values only - databaseRow has no "tree"
|
||||
if (!is_array($value)) {
|
||||
$result['databaseRow'][$fieldName] = $value;
|
||||
}
|
||||
}
|
||||
// All "records" are always on pid 0
|
||||
$result['databaseRow']['pid'] = 0;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is developed by evoWeb.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Evoweb\EwBase\Xclass;
|
||||
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\SiteTcaInline as BaseSiteTcaInline;
|
||||
|
||||
class SiteTcaInline extends BaseSiteTcaInline
|
||||
{
|
||||
/**
|
||||
* Resolve inline fields
|
||||
*/
|
||||
public function addData(array $result): array
|
||||
{
|
||||
$result = $this->addInlineFirstPid($result);
|
||||
foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
|
||||
if (!$this->isInlineField($fieldConfig)) {
|
||||
continue;
|
||||
}
|
||||
$childTableName = $fieldConfig['config']['foreign_table'] ?? '';
|
||||
if (!in_array($childTableName, ['site_errorhandling', 'site_route', 'site_base_variant'], true)) {
|
||||
return $result;
|
||||
}
|
||||
$result['processedTca']['columns'][$fieldName]['children'] = [];
|
||||
$result = $this->resolveSiteRelatedChildren($result, $fieldName);
|
||||
if (!empty($result['processedTca']['columns'][$fieldName]['config']['selectorOrUniqueConfiguration'])) {
|
||||
throw new \RuntimeException(
|
||||
'selectorOrUniqueConfiguration not implemented in sites module',
|
||||
1624313533
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -16,21 +16,3 @@ services:
|
||||
|
||||
Evoweb\EwBase\ToolbarItems\ReleaseToolbarItem:
|
||||
tags: ['backend.toolbar.item']
|
||||
|
||||
Evoweb\EwBase\Hooks\UsercentricsPostRenderHook:
|
||||
public: true
|
||||
|
||||
Evoweb\EwBase\Updates\GridelementsToContainerMigration:
|
||||
public: true
|
||||
|
||||
Evoweb\EwBase\Updates\GridelementsToContainerService:
|
||||
public: true
|
||||
|
||||
Evoweb\EwBase\Updates\ParentChildToContainerMigration:
|
||||
public: true
|
||||
|
||||
Evoweb\EwBase\Updates\ParentChildToContainerService:
|
||||
public: true
|
||||
|
||||
Evoweb\EwBase\Form\FormDataProvider\UsercentricsDatabaseEditRow:
|
||||
public: true
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
$GLOBALS['SiteConfiguration']['site']['columns']['usercentrics'] = [
|
||||
'label' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site.usercentrics',
|
||||
'description' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site.usercentrics.description',
|
||||
'config' => [
|
||||
'type' => 'inline',
|
||||
'foreign_table' => 'site_usercentrics',
|
||||
'maxitems' => 1,
|
||||
'appearance' => [
|
||||
'enabledControls' => [
|
||||
'info' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] = str_replace(
|
||||
' routes',
|
||||
' routes, usercentrics,',
|
||||
$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem']
|
||||
);
|
||||
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'ctrl' => [
|
||||
'label' => 'id',
|
||||
'title' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site_usercentrics.ctrl.title',
|
||||
'typeicon_classes' => [
|
||||
'default' => 'ew-usercentrics',
|
||||
],
|
||||
],
|
||||
'columns' => [
|
||||
'id' => [
|
||||
'label' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site_usercentrics.column.id',
|
||||
'config' => [
|
||||
'type' => 'input',
|
||||
'size' => 12,
|
||||
'max' => 12,
|
||||
],
|
||||
],
|
||||
'version' => [
|
||||
'label' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site_usercentrics.column.version',
|
||||
'config' => [
|
||||
'type' => 'select',
|
||||
'renderType' => 'selectSingle',
|
||||
'minitems' => 0,
|
||||
'maxitems' => 1,
|
||||
'size' => 1,
|
||||
'items' => [
|
||||
[
|
||||
0 => 'CMP 2',
|
||||
1 => 'loader',
|
||||
],
|
||||
[
|
||||
0 => 'CMP 1',
|
||||
1 => 'main',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'applicationContext' => [
|
||||
'label' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site_usercentrics.column.applicationContext',
|
||||
'description' => 'Values are separated by line breaks',
|
||||
'config' => [
|
||||
'type' => 'text',
|
||||
'eval' => 'trim',
|
||||
],
|
||||
],
|
||||
'useBlocker' => [
|
||||
'label' => 'LLL:EXT:ew_base/Resources/Private/Language/locallang_siteconfiguration.xlf:site_usercentrics.column.useBlocker',
|
||||
'config' => [
|
||||
'type' => 'check',
|
||||
'renderType' => 'checkboxToggle',
|
||||
'default' => false,
|
||||
'items' => [
|
||||
[
|
||||
0 => '',
|
||||
1 => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'types' => [
|
||||
'1' => [
|
||||
'showitem' => '
|
||||
--palette--;;usercentrics,
|
||||
',
|
||||
],
|
||||
],
|
||||
'palettes' => [
|
||||
'usercentrics' => [
|
||||
'showitem' => '
|
||||
id, version, --linebreak--,
|
||||
applicationContext, useBlocker,
|
||||
',
|
||||
],
|
||||
],
|
||||
];
|
||||
@ -3,45 +3,13 @@
|
||||
defined('TYPO3') or die('access denied');
|
||||
|
||||
use Evoweb\EwBase\Form\Element\PickColorFromImage;
|
||||
use Evoweb\EwBase\Form\FormDataProvider\UsercentricsDatabaseEditRow;
|
||||
use Evoweb\EwBase\Form\FormDataProvider\UsercentricsTcaInline;
|
||||
use Evoweb\EwBase\Hooks\UsercentricsPostRenderHook;
|
||||
use Evoweb\EwBase\Xclass\SiteDatabaseEditRow;
|
||||
use Evoweb\EwBase\Xclass\SiteTcaInline;
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow;
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\SiteDatabaseEditRow as BaseSiteDatabaseEditRow;
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\SiteTcaInline as BaseSiteTcaInline;
|
||||
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSiteLanguage;
|
||||
|
||||
call_user_func(function () {
|
||||
(static function () {
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['ewb'] = [ 'Evoweb\\EwBase\\ViewHelpers' ];
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-postProcess'][] =
|
||||
UsercentricsPostRenderHook::class . '->executePostRenderHook';
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1681197508] = [
|
||||
'nodeName' => 'pick-color-from-image',
|
||||
'priority' => '70',
|
||||
'class' => PickColorFromImage::class,
|
||||
];
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseSiteDatabaseEditRow::class] = [
|
||||
'className' => SiteDatabaseEditRow::class,
|
||||
];
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][BaseSiteTcaInline::class] = [
|
||||
'className' => SiteTcaInline::class,
|
||||
];
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'][
|
||||
UsercentricsDatabaseEditRow::class
|
||||
] = [
|
||||
'depends' => [ BaseSiteDatabaseEditRow::class ],
|
||||
'before' => [ DatabaseParentPageRow::class ],
|
||||
];
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'][
|
||||
UsercentricsTcaInline::class
|
||||
] = [
|
||||
'depends' => [ BaseSiteTcaInline::class ],
|
||||
'before' => [ TcaSiteLanguage::class ],
|
||||
];
|
||||
});
|
||||
})();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user