50 $availableWorkspaces = array();
52 if (
$GLOBALS[
'BE_USER']->checkWorkspace(array(
'uid' => (
string) self::LIVE_WORKSPACE_ID))) {
53 $availableWorkspaces[self::LIVE_WORKSPACE_ID] = self::getWorkspaceTitle(self::LIVE_WORKSPACE_ID);
56 $customWorkspaces =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid, title, adminusers, members',
'sys_workspace',
'pid = 0' .
BackendUtility::deleteClause(
'sys_workspace'),
'',
'title');
57 if (count($customWorkspaces)) {
58 foreach ($customWorkspaces as $workspace) {
59 if (
$GLOBALS[
'BE_USER']->checkWorkspace($workspace)) {
60 $availableWorkspaces[$workspace[
'uid']] = $workspace[
'title'];
64 return $availableWorkspaces;
73 $workspaceId =
$GLOBALS[
'BE_USER']->workspace;
74 $activeId =
$GLOBALS[
'BE_USER']->getSessionData(
'tx_workspace_activeWorkspace');
77 if ($activeId !== NULL && $activeId !== self::SELECT_ALL_WORKSPACES) {
79 if (!isset($availableWorkspaces[$activeId])) {
84 if ($activeId !== NULL) {
85 $workspaceId = $activeId;
100 case self::LIVE_WORKSPACE_ID:
101 $title =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_misc.xlf:shortcut_onlineWS');
104 $labelField =
$GLOBALS[
'TCA'][
'sys_workspace'][
'ctrl'][
'label'];
105 $wsRecord = BackendUtility::getRecord(
'sys_workspace', $wsId,
'uid,' . $labelField);
106 if (is_array($wsRecord)) {
107 $title = $wsRecord[$labelField];
110 if ($title === FALSE) {
111 throw new \InvalidArgumentException(
'No such workspace defined');
128 if ($wsid >= -1 && $wsid !== 0) {
132 $workspaceRec = BackendUtility::getRecord(
'sys_workspace', $wsid);
133 if ($workspaceRec[
'publish_access'] & 1) {
140 foreach ($versions as $table => $records) {
141 foreach ($records as $rec) {
143 $cmd[$table][$rec[
't3ver_oid']][
'version'] = array(
'action' =>
'swap',
'swapWith' => $rec[
'uid'],
'swapIntoWS' => $doSwap ? 1 : 0);
162 if ($wsid >= -1 && $wsid !== 0) {
168 foreach ($versions as $table => $records) {
169 foreach ($records as $rec) {
171 $cmd[$table][$rec[
'uid']][
'version'] = array(
'action' => $flush ?
'flush' :
'clearWSID');
192 public function selectVersionsInWorkspace($wsid, $filter = 0, $stage = -99, $pageId = -1, $recursionLevel = 0, $selectionType =
'tables_select', $language = NULL) {
194 $filter = (int)$filter;
197 if ($pageId != -1 && $recursionLevel > 0) {
198 $pageList = $this->getTreeUids($pageId, $wsid, $recursionLevel);
199 } elseif ($pageId != -1) {
204 $mountPoints = array_map(
'intval',
$GLOBALS[
'BE_USER']->returnWebmounts());
205 $mountPoints = array_unique($mountPoints);
206 if (!in_array(0, $mountPoints)) {
207 $tempPageIds = array();
208 foreach ($mountPoints as $mountPoint) {
209 $tempPageIds[] = $this->getTreeUids($mountPoint, $wsid, $recursionLevel);
211 $pageList = implode(
',', $tempPageIds);
212 $pageList = implode(
',', array_unique(explode(
',', $pageList)));
216 foreach (
$GLOBALS[
'TCA'] as $table => $cfg) {
218 if (!
$GLOBALS[
'BE_USER']->check($selectionType, $table)) {
221 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
223 if ((
int)
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] === 2) {
225 $recs = array_merge($recs, $moveRecs);
229 $output[$table] = $recs;
253 $languageParentField =
'';
256 if ($isTableLocalizable === FALSE && $language > 0) {
258 } elseif ($isTableLocalizable) {
259 $languageParentField =
'A.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] .
', ';
261 $fields =
'A.uid, A.t3ver_oid, A.t3ver_stage, ' . $languageParentField .
'B.pid AS wspid, B.pid AS livepid';
262 if ($isTableLocalizable) {
263 $fields .=
', A.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
265 $from = $table .
' A,' . $table .
' B';
269 $pidField = $table ===
'pages' ?
'uid' :
'pid';
270 $pidConstraint = strstr($pageList,
',') ?
' IN (' . $pageList .
')' :
'=' . $pageList;
271 $where .=
' AND B.' . $pidField . $pidConstraint;
273 if ($isTableLocalizable && \
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($language)) {
274 $where .=
' AND A.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] .
'=' . $language;
279 if ($wsid > self::SELECT_ALL_WORKSPACES) {
280 $where .=
' AND A.t3ver_wsid=' . $wsid;
281 } elseif ($wsid === self::SELECT_ALL_WORKSPACES) {
282 $where .=
' AND A.t3ver_wsid!=0';
287 if ($filter === 1 || $filter === 2) {
288 $where .=
' AND A.t3ver_count ' . ($filter === 1 ?
'= 0' :
'> 0');
291 $where .=
' AND A.t3ver_stage=' . (int)$stage;
294 $where .=
' AND B.pid>=0';
296 $where .=
' AND A.t3ver_oid=B.uid';
303 return is_array($res) ? $res : array();
321 $fields =
'A.pid AS wspid, B.uid AS t3ver_oid, C.uid AS uid, B.pid AS livepid';
322 $from = $table .
' A, ' . $table .
' B,' . $table .
' C';
326 if ($wsid > self::SELECT_ALL_WORKSPACES) {
327 $where .=
' AND A.t3ver_wsid=' . $wsid .
' AND C.t3ver_wsid=' . $wsid;
328 } elseif ($wsid === self::SELECT_ALL_WORKSPACES) {
329 $where .=
' AND A.t3ver_wsid!=0 AND C.t3ver_wsid!=0 ';
334 if ($filter === 1 || $filter === 2) {
335 $where .=
' AND C.t3ver_count ' . ($filter === 1 ?
'= 0' :
'> 0');
338 $where .=
' AND C.t3ver_stage=' . (int)$stage;
341 $pidField = $table ===
'pages' ?
'B.uid' :
'A.pid';
342 $pidConstraint = strstr($pageList,
',') ?
' IN (' . $pageList .
')' :
'=' . $pageList;
343 $where .=
' AND ' . $pidField . $pidConstraint;
345 $where .=
' AND A.t3ver_move_id = B.uid AND B.uid = C.t3ver_oid';
350 return is_array($res) ? $res : array();
361 protected function getTreeUids($pageId, $wsid, $recursionLevel) {
364 $perms_clause =
$GLOBALS[
'BE_USER']->getPagePermsClause(1);
368 $pageList = $searchObj->getTreeList($pageId, $recursionLevel, 0, $perms_clause);
370 $mountPoints =
$GLOBALS[
'BE_USER']->uc[
'pageTree_temporaryMountPoint'];
371 if (!is_array($mountPoints) || empty($mountPoints)) {
372 $mountPoints = array_map(
'intval',
$GLOBALS[
'BE_USER']->returnWebmounts());
373 $mountPoints = array_unique($mountPoints);
376 foreach ($mountPoints as $mountPoint) {
377 $newList[] = $searchObj->getTreeList($mountPoint, $recursionLevel, 0, $perms_clause);
379 $pageList = implode(
',', $newList);
382 if ((
int)
$GLOBALS[
'TCA'][
'pages'][
'ctrl'][
'versioningWS'] === 2 && $pageList) {
384 $movedAwayPages =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid, pid, t3ver_move_id',
'pages',
't3ver_move_id IN (' . $pageList .
') AND t3ver_wsid=' . (
int)$wsid .
BackendUtility::deleteClause(
'pages'),
'',
'uid',
'',
't3ver_move_id');
387 $newList = array_diff($pageIds, array_keys($movedAwayPages));
389 $newList[] = $pageId;
393 foreach ($movedAwayPages as
$uid => $rec) {
394 if (in_array($rec[
'pid'], $newList) && !in_array(
$uid, $newList)) {
400 $pageList = implode(
',', $newList);
405 if (!in_array($pageId, $pageIds)) {
406 $pageIds[] = $pageId;
408 foreach ($pageIds as $pageId) {
409 if ((
int)$pages[$pageId][
't3ver_move_id'] > 0) {
410 $newList[] = (int)$pages[$pageId][
't3ver_move_id'];
412 $newList[] = $pageId;
415 $pageList = implode(
',', $newList);
428 $permittedElements = array();
429 if (is_array($recs)) {
430 foreach ($recs as $rec) {
432 $permittedElements[] = $rec;
436 return $permittedElements;
447 $pageIdField = $table ===
'pages' ?
'uid' :
'wspid';
448 $pageId = isset($record[$pageIdField]) ? (int)$record[$pageIdField] : NULL;
449 if ($pageId === NULL) {
455 $page = BackendUtility::getRecord(
'pages', $pageId,
'uid,pid,perms_userid,perms_user,perms_groupid,perms_group,perms_everybody');
457 return $GLOBALS[
'BE_USER']->doesUserHaveAccess($page, 1);
469 $languageUid = $record[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']];
473 return $GLOBALS[
'BE_USER']->checkLanguageAccess($languageUid);
483 $cacheKey =
'workspace-oldstyleworkspace-notused';
484 $cacheResult =
$GLOBALS[
'BE_USER']->getSessionData($cacheKey);
486 $where =
'adminusers != \'\' AND adminusers NOT LIKE \'%be_users%\' AND adminusers NOT LIKE \'%be_groups%\' AND deleted=0';
487 $count =
$GLOBALS[
'TYPO3_DB']->exec_SELECTcountRows(
'uid',
'sys_workspace', $where);
488 $oldStyleWorkspaceIsUsed = $count > 0;
489 $GLOBALS[
'BE_USER']->setAndSaveSessionData($cacheKey, !$oldStyleWorkspaceIsUsed);
491 $oldStyleWorkspaceIsUsed = !$cacheResult;
493 return $oldStyleWorkspaceIsUsed;
508 $whereClause =
'pid = ' . (int)$id;
509 $whereClause .=
' AND ' .
$GLOBALS[
'TCA'][
'pages_language_overlay'][
'ctrl'][
'languageField'] .
' = ' . (int)$language;
510 $whereClause .=
' AND t3ver_wsid = ' . (int)
$GLOBALS[
'BE_USER']->workspace;
512 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
't3ver_state',
'pages_language_overlay', $whereClause);
513 if ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
517 $rec = BackendUtility::getRecord(
'pages', $id,
't3ver_state');
518 if (is_array($rec)) {
538 if ($table ==
'pages') {
540 } elseif ($table ===
'pages_language_overlay' || $table ===
'tt_content') {
541 if ($liveRecord === NULL) {
544 if ($versionRecord === NULL) {
545 $versionRecord = BackendUtility::getRecord($table,
$uid);
551 $previewPageId = (empty($movePlaceholder[
'pid']) ? $liveRecord[
'pid'] : $movePlaceholder[
'pid']);
552 $additionalParameters =
'&tx_workspaces_web_workspacesworkspaces[previewWS]=' . $versionRecord[
't3ver_wsid'];
554 $languageField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
555 if ($versionRecord[$languageField] > 0) {
556 $additionalParameters .=
'&L=' . $versionRecord[$languageField];
561 if (isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'workspaces'][
'viewSingleRecord'])) {
565 'record' => $liveRecord,
566 'liveRecord' => $liveRecord,
567 'versionRecord' => $versionRecord,
569 $_funcRef =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'workspaces'][
'viewSingleRecord'];
587 if ($pageUid > 0 && $workspaceUid > 0) {
588 $pageRecord = BackendUtility::getRecord(
'pages', $pageUid);
610 $timeToLiveHours = $previewObject->getPreviewLinkLifetime();
611 $previewKeyword = $previewObject->compilePreviewKeyword(
'',
$GLOBALS[
'BE_USER']->user[
'uid'], $timeToLiveHours * 3600, $this->
getCurrentWorkspace());
613 'ADMCMD_prev' => $previewKeyword,
626 public function generateWorkspaceSplittedPreviewLink(
$uid, $addDomain = FALSE) {
632 $uriBuilder = $this->
getObjectManager()->get(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
636 $backPath =
'/' . TYPO3_mainDir;
637 $redirect = $backPath .
'index.php?redirect_url=';
641 $viewScript = $backPath . $uriBuilder->uriFor(
'index', array(),
'Preview',
'workspaces',
'web_workspacesworkspaces') .
'&id=';
643 if ($addDomain === TRUE) {
644 return BackendUtility::getViewDomain(
$uid) . $redirect . urlencode($viewScript) .
$uid;
658 $previewLanguages = $this->getAvailableLanguages(
$uid);
659 $previewLinks = array();
661 foreach ($previewLanguages as $languageUid => $language) {
662 $previewLinks[$language] = $previewUrl .
'&L=' . $languageUid;
665 return $previewLinks;
677 if (!isset($this->pageCache[
$uid])) {
678 $pageRecord = BackendUtility::getRecord(
'pages', $uid);
679 if (is_array($pageRecord)) {
680 $this->pageCache[
$uid] = $pageRecord[
't3ver_oid'] ? $pageRecord[
't3ver_oid'] :
$uid;
682 throw new \InvalidArgumentException(
'uid is supposed to point to an existing page - given value was:' . $uid, 1290628113);
685 return $this->pageCache[
$uid];
696 $workspace = (int)$workspace;
697 $pageId = (int)$pageId;
698 if ($workspace === 0) {
702 if (isset($this->versionsOnPageCache[$pageId][$workspace])) {
703 return $this->versionsOnPageCache[$pageId][$workspace];
706 if (!empty($this->versionsOnPageCache)) {
710 $this->versionsOnPageCache[$pageId][$workspace] = FALSE;
711 foreach (
$GLOBALS[
'TCA'] as $tableName => $tableConfiguration) {
712 if ($tableName ===
'pages' || empty($tableConfiguration[
'ctrl'][
'versioningWS'])) {
715 $joinStatement =
'A.t3ver_oid=B.uid';
719 $joinStatement =
'(A.t3ver_oid=B.uid AND A.t3ver_state<>' . $movePointer
720 .
' OR A.t3ver_oid=B.t3ver_move_id AND A.t3ver_state=' . $movePointer .
')';
725 'B.uid as live_uid, B.pid as live_pid, A.uid as offline_uid',
726 $tableName .
' A,' . $tableName .
' B',
727 'A.pid=-1 AND A.t3ver_wsid=' . $workspace .
' AND ' . $joinStatement .
732 if (!empty($records)) {
733 foreach ($records as $record) {
734 $this->versionsOnPageCache[$record[
'live_pid']][$workspace] = TRUE;
739 return $this->versionsOnPageCache[$pageId][$workspace];
753 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
762 public function getAvailableLanguages($pageId) {
763 $languageOptions = array();
765 $translationConfigurationProvider =
GeneralUtility::makeInstance(
'TYPO3\\CMS\\Backend\\Configuration\\TranslationConfigurationProvider');
766 $systemLanguages = $translationConfigurationProvider->getSystemLanguages($pageId);
768 if (
$GLOBALS[
'BE_USER']->checkLanguageAccess(0)) {
770 $languageOptions[0] = $systemLanguages[0][
'title'];
774 if (!is_array($pages)) {
775 return $languageOptions;
778 foreach ($pages as $page) {
779 $languageId = (int)$page[
'sys_language_uid'];
781 if (isset($systemLanguages[$languageId]) &&
$GLOBALS[
'BE_USER']->checkLanguageAccess($languageId)) {
782 $languageOptions[$page[
'sys_language_uid']] = $systemLanguages[$languageId][
'title'];
786 return $languageOptions;
static getWorkspaceTitle($wsId)
isLanguageAccessibleForCurrentUser($table, array $record)
static viewSingleRecord($table, $uid, array $liveRecord=NULL, array $versionRecord=NULL)
selectVersionsInWorkspace($wsid, $filter=0, $stage=-99, $pageId=-1, $recursionLevel=0, $selectionType='tables_select', $language=NULL)
const SELECT_ALL_WORKSPACES
static getRecordsByField($theTable, $theField, $theValue, $whereClause='', $groupBy='', $orderBy='', $limit='', $useDeleteClause=TRUE)
getMoveToPlaceHolderFromPages($table, $pageList, $wsid, $filter, $stage)
canCreatePreviewLink($pageUid, $workspaceUid)
filterPermittedElements($recs, $table)
static isNewPage($id, $language=0)
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=FALSE)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
static getMovePlaceholder($table, $uid, $fields=' *', $workspace=NULL)
getCmdArrayForFlushWS($wsid, $flush=TRUE, $pageId=0, $language=NULL)
static makeInstance($className)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
generateWorkspacePreviewLink($uid)
static _GETset($inputGet, $key='')
static viewOnClick($pageUid, $backPath='', $rootLine='', $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=TRUE)
static getLiveVersionIdOfRecord($table, $uid)
static isRootLevelRestrictionIgnored($table)
static isTableMovePlaceholderAware($table)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
hasPageRecordVersions($workspace, $pageId)
static isOldStyleWorkspaceUsed()
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=FALSE, $rawurlencodeParamName=FALSE)
selectAllVersionsFromPages($table, $pageList, $wsid, $filter, $stage, $language=NULL)
getCmdArrayForPublishWS($wsid, $doSwap, $pageId=0, $language=NULL)
static getLiveVersionOfRecord($table, $uid, $fields=' *')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
isPageAccessibleForCurrentUser($table, array $record)
static inList($list, $item)
generateWorkspacePreviewLinksForAllLanguages($uid)
static isTableLocalizable($table)
static deleteClause($table, $tableAlias='')