Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
use HDNET\Calendarize\Service\PluginConfigurationService;
use HDNET\Calendarize\Utility\DateTimeUtility;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Crypto\HashService;
use TYPO3\CMS\Core\Http\PropagateResponseException;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Controller\Arguments;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Security\Cryptography\HashService;
use TYPO3\CMS\Frontend\Controller\ErrorController;
use TYPO3\CMS\Frontend\Page\PageAccessFailureReasons;

Expand Down Expand Up @@ -125,7 +125,7 @@ protected function callActionMethod(RequestInterface $request): ResponseInterfac
if (isset($this->feedFormats[$request->getFormat()])) {
if ($request->hasArgument('hmac')) {
$hmac = $request->getArgument('hmac');
if ($this->validatePluginHmac($hmac)) {
if ($this->validatePluginHmac($hmac, $this->request->getControllerActionName())) {
$this->setHeadersAndExit(
$response,
$this->feedFormats[$request->getFormat()],
Expand Down Expand Up @@ -194,7 +194,7 @@ protected function eventExtendedAssignMultiple(array $variables, string $classNa
{
// use this variable in your extension to add more custom variables
$variables['extended'] = [];
$variables['extended']['pluginHmac'] = $this->calculatePluginHmac();
$variables['extended']['pluginHmac'] = $this->calculatePluginHmac($this->request->getControllerActionName());
$variables['settings'] = $this->settings;
$variables['contentObject'] = $this->request->getAttribute('currentContentObject')->data;

Expand Down Expand Up @@ -223,7 +223,7 @@ protected function eventExtendedRedirect(
'delay' => 0,
'statusCode' => 301,
];
$variables['extended']['pluginHmac'] = $this->calculatePluginHmac();
$variables['extended']['pluginHmac'] = $this->calculatePluginHmac($this->request->getControllerActionName());
$variables['settings'] = $this->settings;
}

Expand Down Expand Up @@ -260,26 +260,36 @@ protected function getStringForPluginHmac(): string
*
* @see HashService::generateHmac
*/
protected function calculatePluginHmac(): string
protected function calculatePluginHmac(string $context = 'default'): string
{
/* Generate a secret that is unique per context */
$contentObject = $this->request->getAttribute('currentContentObject');
$uid = $contentObject ? (string)$contentObject->data['uid'] : '0';
$additionalSecret = $uid . $context;

$string = $this->getStringForPluginHmac();

$hashService = GeneralUtility::makeInstance(HashService::class);

return $hashService->generateHmac($string);
return $hashService->hmac($string, $additionalSecret);
}

/**
* @see HashService::validateHmac
*/
protected function validatePluginHmac(string $hmac): bool
protected function validatePluginHmac(string $hmac, string $context = 'default'): bool
{
/* Generate a secret that is unique per context */
$contentObject = $this->request->getAttribute('currentContentObject');
$uid = $contentObject ? (string)$contentObject->data['uid'] : '0';
$additionalSecret = $uid . $context;

$string = $this->getStringForPluginHmac();

/** @var HashService $hashService */
$hashService = GeneralUtility::makeInstance(HashService::class);

return $hashService->validateHmac($string, $hmac);
return $hashService->validateHmac($string, $additionalSecret, $hmac);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use HDNET\Calendarize\Domain\Model\Request\OptionRequest;
use HDNET\Calendarize\Register;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Backend\Attribute\Controller;
use TYPO3\CMS\Backend\Attribute\AsController;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
Expand All @@ -21,7 +21,7 @@
/**
* BackendController.
*/
#[Controller]
#[AsController]
class BackendController extends AbstractController
{
protected LanguageService $languageService;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use HDNET\Calendarize\Domain\Model\Request\AbstractBookingRequest;
use HDNET\Calendarize\Validation\Validator\BookingRequestValidator;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Attribute as Extbase;

/**
* BookingController.
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use TYPO3\CMS\Core\Pagination\SlidingWindowPagination;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Http\ForwardResponse;
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace HDNET\Calendarize\Domain\Model;

use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use HDNET\Calendarize\Features\KeSearchIndexInterface;
use HDNET\Calendarize\Features\SpeakingUrlInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\Domain\Model\Category;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Request/DefaultBookingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace HDNET\Calendarize\Domain\Model\Request;

use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\Validation\Validator\EmailAddressValidator;

/**
Expand Down
16 changes: 8 additions & 8 deletions Classes/EventListener/PreviewRenderingEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
use HDNET\Calendarize\Utility\TranslateUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Domain\FlexFormFieldValues;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Provides backend preview for calendarize plugins.
Expand All @@ -33,17 +31,19 @@ public function __invoke(PageContentPreviewRenderingEvent $event): void
return;
}

$this->flexFormService->load($record['pi_flexform'] ?? '');
if (!$this->flexFormService->isValid()) {
if (!isset($record['pi_flexform'])) {
return;
}

$iconSize = GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() <= 12 ? Icon::SIZE_SMALL : IconSize::SMALL;
/** @var FlexFormFieldValues $flexFormFieldValues */
$flexFormFieldValues = $record['pi_flexform'];

$extensionIconUsage = $this->iconFactory->getIcon('ext-calendarize-wizard-icon', $iconSize)->render();
$flexFormFieldValues->toArray();

$extensionIconUsage = $this->iconFactory->getIcon('ext-calendarize-wizard-icon', IconSize::SMALL)->render();
$this->layoutService->setTitle($extensionIconUsage . ' Calendarize');

$listType = explode('_', $record['list_type'], 2)[1] ?? '';
$listType = explode('_', $record['CType'], 2)[1] ?? '';
$this->layoutService->addRow(TranslateUtility::get('mode'), TranslateUtility::get('mode.' . $listType));

$pluginConfiguration = (int)$this->flexFormService->get('settings.pluginConfiguration', 'main');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/TcaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function eventTitle(array &$params, ?object $_): void
// base title
$table = $params['table'];
unset($GLOBALS['TCA'][$table]['ctrl']['label_userFunc']);
$params['title'] = BackendUtility::getRecordTitle($table, $params['row']);
$params['title'] = $params['row']['title'];
$GLOBALS['TCA'][$table]['ctrl']['label_userFunc'] = self::class . '->eventTitle';

// base record
Expand Down
8 changes: 4 additions & 4 deletions Classes/Service/TimeTable/Secondary/ManipulationTimeTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
use HDNET\Calendarize\Service\TimeTable\AbstractTimeTable;
use HDNET\Calendarize\Service\TimeTable\TimeTableInterface;
use HDNET\Calendarize\Utility\ConfigurationUtility;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\Utility\MathUtility;

class ManipulationTimeTable extends AbstractTimeTable implements TimeTableInterface
{
public function __construct(protected FlexFormService $flexFormService) {}
public function __construct(protected FlexFormTools $flexFormTools) {}

private function loadFlexForm($flexFormString): array
{
return $this->flexFormService
return $this->flexFormTools
->convertFlexFormContentToArray($flexFormString);
}

Expand Down Expand Up @@ -46,7 +46,7 @@ public function getFlexForm(): string

public function handleConfiguration(array &$times, Configuration $configuration): void
{
$settings = $this->flexFormService->convertFlexFormContentToArray($configuration->getFlexForm());
$settings = $this->flexFormTools->convertFlexFormContentToArray($configuration->getFlexForm());
if (MathUtility::canBeInterpretedAsInteger($settings['settings']['fixedStartTime'] ?? null)) {
foreach ($times as $key => $time) {
$times[$key]['start_time'] = (int)$settings['settings']['fixedStartTime'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Updates/DateFieldUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Types\DateType;
use TYPO3\CMS\Core\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;

#[UpgradeWizard('calendarize_dateFieldUpdate')]
class DateFieldUpdate extends AbstractUpdate
Expand Down
2 changes: 1 addition & 1 deletion Classes/Updates/NewIncludeExcludeStructureUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use HDNET\Calendarize\Domain\Model\ConfigurationInterface;
use HDNET\Calendarize\Utility\HelperUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;

#[UpgradeWizard('calendarize_newIncludeExcludeStructureUpdate')]
Expand Down
8 changes: 3 additions & 5 deletions Classes/Updates/PluginUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

namespace HDNET\Calendarize\Updates;

use TYPO3\CMS\Core\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;

#[UpgradeWizard('calendarize_pluginUpdater')]
Expand Down Expand Up @@ -42,8 +41,7 @@ class PluginUpdater extends AbstractUpdate
public function __construct(
protected readonly QueryBuilder $contentElementsQueryBuilder,
protected readonly QueryBuilder $backendGroupsQueryBuilder,
protected readonly FlexFormTools $flexFormTools,
protected readonly FlexFormService $flexFormService,
protected readonly FlexFormTools $flexFormTools
) {}

/**
Expand All @@ -66,7 +64,7 @@ protected function migratePlugins(): void
$this->output->writeln('Start migration of ' . \count($contentElements) . ' plugins.');

foreach ($contentElements as $contentElement) {
$flexForm = $this->flexFormService->convertFlexFormContentToArray($contentElement['pi_flexform']);
$flexForm = $this->flexFormTools->convertFlexFormContentToArray($contentElement['pi_flexform']);
$newListType = $this->getNewListType($flexForm['switchableControllerActions'] ?? '');
$flexFormData = $this->removeFlexFormSettingsNotForListType($contentElement, $newListType);

Expand Down
2 changes: 1 addition & 1 deletion Classes/Updates/PopulateEventSlugs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace HDNET\Calendarize\Updates;

use HDNET\Calendarize\Service\IndexerService;
use TYPO3\CMS\Core\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory;
use TYPO3\CMS\Core\DataHandling\SlugHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;

#[UpgradeWizard('calendarize_populateEventSlugs')]
Expand Down
2 changes: 1 addition & 1 deletion Classes/Updates/TillDateFieldUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace HDNET\Calendarize\Updates;

use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Attribute\UpgradeWizard;

#[UpgradeWizard('calendarize_tillDateFieldUpdate')]
class TillDateFieldUpdate extends DateFieldUpdate
Expand Down
4 changes: 2 additions & 2 deletions Classes/ViewHelpers/LanguageInformationViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace HDNET\Calendarize\ViewHelpers;

use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ public function render(): string
$title = htmlspecialchars($sysLanguages[$langUid]['title']);
if ($sysLanguages[$langUid]['flagIcon']) {
$out .= '<span title="' . $title . '">'
. $iconFactory->getIcon($sysLanguages[$langUid]['flagIcon'], Icon::SIZE_SMALL)->render()
. $iconFactory->getIcon($sysLanguages[$langUid]['flagIcon'], IconSize::SMALL)->render()
. '</span>&nbsp;';
}
$out .= $title;
Expand Down
19 changes: 9 additions & 10 deletions Classes/ViewHelpers/Link/AbstractLinkViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace HDNET\Calendarize\ViewHelpers\Link;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
Expand Down Expand Up @@ -34,13 +35,11 @@ abstract class AbstractLinkViewHelper extends AbstractTagBasedViewHelper
public function initializeArguments(): void
{
parent::initializeArguments();
$this->registerUniversalTagAttributes();
$this->registerTagAttribute('target', 'string', 'Target of link', false);
$this->registerTagAttribute(
$this->registerArgument('target', 'string', 'Target of link');
$this->registerArgument(
'rel',
'string',
'Specifies the relationship between the current document and the linked document',
false,
'Specifies the relationship between the current document and the linked document'
);
}

Expand Down Expand Up @@ -97,12 +96,12 @@ protected function getPageUid(?string $contextName = null): int
return $this->getRequest()->getAttribute('routing')->getPageId() ?? 0;
}

protected function getRequest(): RequestInterface
protected function getRequest(): ?ServerRequestInterface
{
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$request = null;
if ($this->renderingContext->hasAttribute(ServerRequestInterface::class)) {
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class);
}

return $request;
}
Expand Down
Loading
Loading