2 namespace TYPO3\CMS\Version\Hook;
56 $this->tsfeObj = $pObj;
58 if (is_array($this->previewConfiguration)) {
64 \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class,
80 unset($_COOKIE[
'be_typo_user']);
95 if ((is_null($params[
'BE_USER']) || $params[
'BE_USER'] ===
false) && $this->previewConfiguration !==
false && $this->previewConfiguration[
'BEUSER_uid'] > 0) {
98 $BE_USER->userTS_dontGetCached = 1;
99 $BE_USER->setBeUserByUid($this->previewConfiguration[
'BEUSER_uid']);
100 $BE_USER->unpack_uc(
'');
101 if ($BE_USER->user[
'uid']) {
102 $BE_USER->fetchGroupData();
103 $pObj->beUserLogin =
true;
106 $pObj->beUserLogin =
false;
108 $params[
'BE_USER'] = $BE_USER;
112 $workspaceUid = $this->previewConfiguration[
'fullWorkspace'];
113 if ($pObj->beUserLogin && is_object($params[
'BE_USER']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($workspaceUid)) {
114 if ($workspaceUid == 0 || $workspaceUid >= -1 && $params[
'BE_USER']->checkWorkspace($workspaceUid)) {
116 $pObj->workspacePreview = (int)$workspaceUid;
119 $pObj->workspacePreview = -99;
146 if ($inputCode ==
'LOGOUT') {
148 if ($this->tsfeObj->TYPO3_CONF_VARS[
'FE'][
'workspacePreviewLogoutTemplate']) {
149 $templateFile = PATH_site . $this->tsfeObj->TYPO3_CONF_VARS[
'FE'][
'workspacePreviewLogoutTemplate'];
150 if (@is_file($templateFile)) {
151 $message =
GeneralUtility::getUrl(PATH_site . $this->tsfeObj->TYPO3_CONF_VARS[
'FE'][
'workspacePreviewLogoutTemplate']);
153 $message =
'<strong>ERROR!</strong><br>Template File "'
154 . $this->tsfeObj->TYPO3_CONF_VARS[
'FE'][
'workspacePreviewLogoutTemplate']
155 .
'" configured with $TYPO3_CONF_VARS["FE"]["workspacePreviewLogoutTemplate"] not found. Please contact webmaster about this problem.';
158 $message =
'You logged out from Workspace preview mode. Click this link to <a href="%1$s">go back to the website</a>';
161 die(sprintf($message, htmlspecialchars(preg_replace(
'/\\&?' . $this->previewKey .
'=[[:alnum:]]+/',
'', $returnUrl))));
164 $where =
'keyword=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($inputCode,
'sys_preview') .
' AND endtime>' .
$GLOBALS[
'EXEC_TIME'];
165 $previewData =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'*',
'sys_preview', $where);
169 if (is_array($previewData)) {
172 $previewConfig = unserialize($previewData[
'config']);
179 if ($previewConfig[
'fullWorkspace']) {
190 return $previewConfig;
194 parse_str($previewConfig[
'getVars'], $GET_VARS);
197 return $previewConfig;
201 throw new \Exception(htmlspecialchars(
'Request URL did not match "'
203 . $inputCode .
'"', 1294585190));
206 throw new \Exception(
'POST requests are incompatible with keyword preview.', 1294585191);
209 throw new \Exception(
'ADMCMD command could not be executed! (No keyword configuration found)', 1294585192);
224 if (!$inputCode && $_COOKIE[$this->previewKey]) {
247 'keyword' => md5(uniqid(microtime(),
true)),
249 'endtime' =>
$GLOBALS[
'EXEC_TIME'] + $ttl,
250 'config' => serialize(array(
251 'fullWorkspace' => $fullWorkspace,
252 'getVars' => $getVarsStr,
253 'BEUSER_uid' => $backendUserUid
256 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery(
'sys_preview', $fieldData);
257 return $fieldData[
'keyword'];
269 $ttlHours = (int)
$GLOBALS[
'BE_USER']->getTSConfigVal(
'options.workspaces.previewLinkTTLHours');
270 return $ttlHours ? $ttlHours : 24 * 2;