2 declare(strict_types = 1);
52 $this->workspaceService = GeneralUtility::makeInstance(WorkspaceService::class);
67 $this->workspaceService->getCurrentWorkspace()
70 $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
72 $site = $siteFinder->getSiteByPageId($uid);
74 $language = $site->getLanguageById($languageId);
75 }
catch (\InvalidArgumentException $e) {
76 $language = $site->getDefaultLanguage();
78 $uri = $site->getRouter()->generateUri($uid, [
'ADMCMD_prev' => $previewKeyword,
'_language' => $language],
'');
80 }
catch (SiteNotFoundException | InvalidRouteArgumentsException $e) {
82 'ADMCMD_prev' => $previewKeyword,
101 foreach ($previewLanguages as $languageUid => $language) {
105 return $previewLinks;
122 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
124 $viewScript = $uriBuilder->buildUriFromRoute(
'workspace_previewcontrols', [
'id' => $uid]);
125 if ($addDomain ===
true) {
126 $viewScript = $uriBuilder->buildUriFromRoute(
'workspace_previewcontrols', [
'id' => $uid]);
129 return (
string)$viewScript;
141 public function buildUriForElement(
string $table,
int $uid, array $liveRecord =
null, array $versionRecord =
null): string
143 if ($table ===
'pages') {
147 if ($liveRecord ===
null) {
150 if ($versionRecord ===
null) {
158 $previewPageId = (empty($movePlaceholder[
'pid']) ? $liveRecord[
'pid'] : $movePlaceholder[
'pid']);
159 $additionalParameters =
'&previewWS=' . $versionRecord[
't3ver_wsid'];
162 $languageField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
163 if ($versionRecord[$languageField] > 0) {
164 $additionalParameters .=
'&L=' . $versionRecord[$languageField];
172 if ($table ===
'tt_content') {
174 } elseif (!empty($pageTsConfig[
'options.'][
'workspaces.'][
'previewPageId.'][$table]) || !empty($pageTsConfig[
'options.'][
'workspaces.'][
'previewPageId'])) {
176 if (!empty($pageTsConfig[
'options.'][
'workspaces.'][
'previewPageId.'][$table])) {
177 $previewConfiguration = $pageTsConfig[
'options.'][
'workspaces.'][
'previewPageId.'][$table];
179 $previewConfiguration = $pageTsConfig[
'options.'][
'workspaces.'][
'previewPageId'];
182 list($previewKey, $previewValue) = explode(
':', $previewConfiguration, 2);
183 if ($previewKey ===
'field') {
184 $previewPageId = (int)$liveRecord[$previewValue];
186 $previewPageId = (int)$previewConfiguration;
189 } elseif (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'workspaces'][
'viewSingleRecord'])) {
194 'record' => $liveRecord,
195 'liveRecord' => $liveRecord,
196 'versionRecord' => $versionRecord,
198 $_funcRef =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'workspaces'][
'viewSingleRecord'];
200 $viewUrl = GeneralUtility::callUserFunction($_funcRef, $_params, $null);
214 protected function compilePreviewKeyword(
int $backendUserUid,
int $ttl = 172800,
int $workspaceId =
null): string
216 $keyword = md5(uniqid(microtime(),
true));
217 GeneralUtility::makeInstance(ConnectionPool::class)
218 ->getConnectionForTable(
'sys_preview')
222 'keyword' => $keyword,
224 'endtime' =>
$GLOBALS[
'EXEC_TIME'] + $ttl,
225 'config' => json_encode([
226 'fullWorkspace' => $workspaceId,
227 'BEUSER_uid' => $backendUserUid
245 return $ttlHours ?: 24 * 2;
258 if (!isset($this->pageCache[$uid])) {
260 if (is_array($pageRecord)) {
261 $this->pageCache[$uid] = $pageRecord[
't3ver_oid'] ? (int)$pageRecord[
't3ver_oid'] : $uid;
263 throw new \InvalidArgumentException(
'uid is supposed to point to an existing page - given value was: ' . $uid, 1290628113);
266 return $this->pageCache[$uid];
277 $languageOptions = [];
278 $translationConfigurationProvider = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
279 $systemLanguages = $translationConfigurationProvider->getSystemLanguages($pageId);
283 $languageOptions[0] = $systemLanguages[0][
'title'];
286 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
287 ->getQueryBuilderForTable(
'pages');
288 $queryBuilder->getRestrictions()
290 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
291 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
293 $result = $queryBuilder->select(
'sys_language_uid')
296 $queryBuilder->expr()->eq(
297 $GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'transOrigPointerField'],
298 $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)
303 while ($row = $result->fetch()) {
304 $languageId = (int)$row[
'sys_language_uid'];
307 $languageOptions[$languageId] = $systemLanguages[$languageId][
'title'];
311 return $languageOptions;