TYPO3 CMS  TYPO3_8-7
TypoScriptFrontendControllerHook.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
25 {
41  public function renderPreviewInfo(array $params, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj)
42  {
43  // 2 means preview of a non-live workspace
44  if ($pObj->fePreview !== 2) {
45  return '';
46  }
47 
48  $content = '';
49 
50  if (!isset($pObj->config['config']['disablePreviewNotification']) || (int)$pObj->config['config']['disablePreviewNotification'] !== 1) {
51  // get the title of the current workspace
52  $currentWorkspaceId = $pObj->whichWorkspace();
53  $currentWorkspaceTitle = $this->getWorkspaceTitle($currentWorkspaceId);
54  $currentWorkspaceTitle = htmlspecialchars($currentWorkspaceTitle);
55  if ($pObj->config['config']['message_preview_workspace']) {
56  $content .= sprintf(
57  $pObj->config['config']['message_preview_workspace'],
58  $currentWorkspaceTitle,
59  $currentWorkspaceId ?? -1
60  );
61  } else {
63  'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod.xlf:previewText',
64  'workspaces',
65  [$currentWorkspaceTitle, $currentWorkspaceId ?? -1]
66  );
67  if ($pObj->doWorkspacePreview()) {
68  $urlForStoppingPreview = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php?ADMCMD_prev=LOGOUT&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
69  $text .= '<br><a style="color: #000;pointer-events: auto;" href="' . $urlForStoppingPreview . '">Stop preview</a>';
70  }
71  $styles = [];
72  $styles[] = 'position: fixed';
73  $styles[] = 'top: 15px';
74  $styles[] = 'right: 15px';
75  $styles[] = 'padding: 8px 18px';
76  $styles[] = 'background: #fff3cd';
77  $styles[] = 'border: 1px solid #ffeeba';
78  $styles[] = 'font-family: sans-serif';
79  $styles[] = 'font-size: 14px';
80  $styles[] = 'font-weight: bold';
81  $styles[] = 'color: #856404';
82  $styles[] = 'z-index: 20000';
83  $styles[] = 'user-select: none';
84  $styles[] = 'pointer-events:none';
85  $styles[] = 'text-align: center';
86  $styles[] = 'border-radius: 2px';
87  $content .= '<div id="typo3-preview-info" style="' . implode(';', $styles) . '">' . $text . '</div>';
88  }
89  }
90  return $content;
91  }
92 
99  protected function getWorkspaceTitle(int $workspaceId): string
100  {
101  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
102  ->getQueryBuilderForTable('sys_workspace');
103  $title = $queryBuilder
104  ->select('title')
105  ->from('sys_workspace')
106  ->where(
107  $queryBuilder->expr()->eq(
108  'uid',
109  $queryBuilder->createNamedParameter($workspaceId, \PDO::PARAM_INT)
110  )
111  )
112  ->execute()
113  ->fetchColumn();
114  return $title !== false ? $title : '';
115  }
116 
120  protected function getBackendUserAuthentication()
121  {
122  return $GLOBALS['BE_USER'];
123  }
124 }
renderPreviewInfo(array $params, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj)
static translate($key, $extensionName=null, $arguments=null)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']