2 declare(strict_types = 1);
19 use Psr\Http\Message\ServerRequestInterface;
51 return 'actions-preview';
68 'LLL:EXT:adminpanel/Resources/Private/Language/locallang_preview.xlf:module.label'
78 $simulateGroupByRequest = (int)($request->getQueryParams()[
'ADMCMD_simUser'] ?? 0);
79 $simulateTimeByRequest = (int)($request->getQueryParams()[
'ADMCMD_simTime'] ?? 0);
87 if ($this->config[
'showFluidDebug']) {
89 unset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'caching'][
'cacheConfigurations'][
'fluid_template'][
'frontend']);
90 $GLOBALS[
'TSFE']->set_no_cache(
'Cache is disabled if fluid debugging is enabled',
true);
93 $this->config[
'showHiddenPages'],
94 $this->config[
'showHiddenRecords'],
95 $this->config[
'simulateDate'],
96 $this->config[
'simulateUserGroup']
105 $view = GeneralUtility::makeInstance(StandaloneView::class);
106 $templateNameAndPath =
'EXT:adminpanel/Resources/Private/Templates/Modules/Settings/Preview.html';
107 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
108 $view->setPartialRootPaths([
'EXT:adminpanel/Resources/Private/Partials']);
110 $frontendGroupsRepository = GeneralUtility::makeInstance(FrontendGroupsRepository::class);
112 $view->assignMultiple(
116 'hiddenPages' => $this->config[
'showHiddenPages'],
117 'hiddenRecords' => $this->config[
'showHiddenRecords'],
118 'fluidDebug' => $this->config[
'showFluidDebug'],
120 'simulateDate' => $this->config[
'simulateDate'],
121 'frontendUserGroups' => [
122 'availableGroups' => $frontendGroupsRepository->getAvailableFrontendUserGroups(),
123 'selected' => (
int)$this->config[
'simulateUserGroup'],
127 return $view->render();
136 return $this->configurationService->getConfigurationOption(
161 bool $showHiddenPages,
162 bool $showHiddenRecords,
164 int $simulateUserGroup
166 $context = GeneralUtility::makeInstance(Context::class);
168 $typoScriptFrontendController->clear_preview();
169 $typoScriptFrontendController->fePreview = 1;
174 GeneralUtility::makeInstance(VisibilityAspect::class, $showHiddenPages, $showHiddenRecords)
183 $GLOBALS[
'SIM_ACCESS_TIME'] = $simTime - $simTime % 60;
186 GeneralUtility::makeInstance(
187 DateTimeAspect::class,
188 new \DateTimeImmutable(
'@' .
$GLOBALS[
'SIM_EXEC_TIME'])
194 if ($simulateUserGroup) {
195 $typoScriptFrontendController->simUserGroup = $simulateUserGroup;
197 $typoScriptFrontendController->fe_user = GeneralUtility::makeInstance(
198 FrontendUserAuthentication::class
201 if (!is_array($typoScriptFrontendController->fe_user->user)) {
203 $typoScriptFrontendController->fe_user->user = [
'uid' => PHP_INT_MAX];
205 $typoScriptFrontendController->fe_user->user[$typoScriptFrontendController->fe_user->usergroup_column] = $simulateUserGroup;
208 GeneralUtility::makeInstance(
210 $typoScriptFrontendController->fe_user ?:
null,
215 if (!$simulateUserGroup && !$simTime && !$showHiddenPages && !$showHiddenRecords) {
216 $typoScriptFrontendController->fePreview = 0;
225 return [
'EXT:adminpanel/Resources/Public/JavaScript/Modules/Preview.js'];
237 protected function parseDate(
int $simulateDate): ?
int
240 $simTime = (new \DateTime(
'@' . $simulateDate))->getTimestamp();
241 $simTime = max($simTime, 60);
242 }
catch (\Exception $e) {