/** * Sets the TYPO3 Backend context to a certain workspace, * called by the Backend toolbar menu * * @param array $parameters * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler * @return void */ public function setWorkspace($parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler) { $workspaceId = (int) GeneralUtility::_GP('workspaceId'); $pageId = (int) GeneralUtility::_GP('pageId'); $finalPageUid = 0; $originalPageId = $pageId; $this->getBackendUser()->setWorkspace($workspaceId); while ($pageId) { $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')'); if ($page) { if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) { break; } } else { $page = BackendUtility::getRecord('pages', $pageId); } $pageId = $page['pid']; } if (isset($page['uid'])) { $finalPageUid = (int) $page['uid']; } $response = array('title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? NULL : $finalPageUid); $ajaxRequestHandler->setContent($response); $ajaxRequestHandler->setContentFormat('json'); }
/** * Sets the TYPO3 Backend context to a certain workspace, * called by the Backend toolbar menu * * @param ServerRequestInterface $request * @param ResponseInterface $response * @return ResponseInterface */ public function switchWorkspaceAction(ServerRequestInterface $request, ResponseInterface $response) { $parsedBody = $request->getParsedBody(); $queryParams = $request->getQueryParams(); $workspaceId = (int) (isset($parsedBody['workspaceId']) ? $parsedBody['workspaceId'] : $queryParams['workspaceId']); $pageId = (int) (isset($parsedBody['pageId']) ? $parsedBody['pageId'] : $queryParams['pageId']); $finalPageUid = 0; $originalPageId = $pageId; $this->getBackendUser()->setWorkspace($workspaceId); while ($pageId) { $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')'); if ($page) { if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) { break; } } else { $page = BackendUtility::getRecord('pages', $pageId); } $pageId = $page['pid']; } if (isset($page['uid'])) { $finalPageUid = (int) $page['uid']; } $ajaxResponse = ['title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? null : $finalPageUid]; $response->getBody()->write(json_encode($ajaxResponse)); return $response; }
/** * Creates the selector for workspaces * * @return string workspace selector as HTML select */ public function render() { $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.workspace', TRUE); $this->addJavascriptToBackend(); $index = 0; $availableWorkspaces = \TYPO3\CMS\Workspaces\Service\WorkspaceService::getAvailableWorkspaces(); $activeWorkspace = (int) $GLOBALS['BE_USER']->workspace; $stateCheckedIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked'); $stateUncheckedIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('empty-empty', array('title' => $GLOBALS['LANG']->getLL('bookmark_inactive'))); $workspaceSections = array('top' => array(), 'items' => array()); foreach ($availableWorkspaces as $workspaceId => $label) { $workspaceId = (int) $workspaceId; $iconState = $workspaceId === $activeWorkspace ? $stateCheckedIcon : $stateUncheckedIcon; $classValue = $workspaceId === $activeWorkspace ? ' class="selected"' : ''; $sectionName = $index++ === 0 ? 'top' : 'items'; $workspaceSections[$sectionName][] = '<li' . $classValue . '>' . '<a href="backend.php?changeWorkspace=' . $workspaceId . '" id="ws-' . $workspaceId . '" class="ws">' . $iconState . ' ' . htmlspecialchars($label) . '</a></li>'; } if (count($workspaceSections['top']) > 0) { // Go to workspace module link if ($GLOBALS['BE_USER']->check('modules', 'web_WorkspacesWorkspaces')) { $workspaceSections['top'][] = '<li>' . '<a href="javascript:top.goToModule(\'web_WorkspacesWorkspaces\');" target="content" id="goToWsModule">' . $stateUncheckedIcon . ' ' . $GLOBALS['LANG']->getLL('bookmark_workspace', TRUE) . '</a></li>'; } $workspaceSections['top'][] = '<li class="divider"></li>'; } else { $workspaceSections['top'][] = '<li>' . $stateUncheckedIcon . ' ' . $GLOBALS['LANG']->getLL('bookmark_noWSfound', TRUE) . '</li>'; } $workspaceMenu = array('<a href="#" class="toolbar-item">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-toolbar-menu-workspace', array('title' => $title)) . '</a>', '<div class="toolbar-item-menu" style="display: none">', '<ul class="top">', implode(LF, $workspaceSections['top']), '</ul>', '<ul class="items">', implode(LF, $workspaceSections['items']), '</ul>', '</div>'); return implode(LF, $workspaceMenu); }
/** * Constructor */ public function __construct() { /** @var \TYPO3\CMS\Workspaces\Service\WorkspaceService $wsService */ $wsService = GeneralUtility::makeInstance(WorkspaceService::class); $this->availableWorkspaces = $wsService->getAvailableWorkspaces(); $pageRenderer = $this->getPageRenderer(); $pageRenderer->addInlineLanguageLabel('Workspaces.workspaceTitle', WorkspaceService::getWorkspaceTitle($this->getBackendUser()->workspace)); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Workspaces/Toolbar/WorkspacesMenu'); }
/** * constructor * * @param \TYPO3\CMS\Backend\Controller\BackendController TYPO3 backend object reference */ public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL) { $this->backendReference = $backendReference; $this->changeWorkspace = GeneralUtility::_GP('changeWorkspace'); $this->changeWorkspacePreview = GeneralUtility::_GP('changeWorkspacePreview'); $pageRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer'); $this->backendReference->addJavaScript('TYPO3.Workspaces = { workspaceTitle : \'' . addslashes(\TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($GLOBALS['BE_USER']->workspace)) . '\'}; '); }
/** * @param $parameter * @return array */ public function setWorkspace($parameter) { $workspaceId = (int) $parameter->workSpaceId; $pageId = (int) $parameter->pageId; $GLOBALS['BE_USER']->setWorkspace($workspaceId); while ($pageId) { $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')'); if ($page) { if ($GLOBALS['BE_USER']->doesUserHaveAccess($page, 1)) { break; } } else { $page = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $pageId); } $pageId = $page['pid']; } return array('title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'id' => $workspaceId, 'page' => isset($page['uid']) && $parameter->pageId == $page['uid'] ? NULL : (int) $page['uid']); }
/** * Renders the review module user dependent with all workspaces. * The module will show all records of one workspace. * * @return void */ public function indexAction() { $backendUser = $this->getBackendUser(); $moduleTemplate = $this->view->getModuleTemplate(); /** @var WorkspaceService $wsService */ $wsService = GeneralUtility::makeInstance(WorkspaceService::class); if (GeneralUtility::_GP('id')) { $pageRecord = BackendUtility::getRecord('pages', GeneralUtility::_GP('id')); if ($pageRecord) { $moduleTemplate->getDocHeaderComponent()->setMetaInformation($pageRecord); $this->view->assign('pageTitle', BackendUtility::getRecordTitle('pages', $pageRecord)); } } $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $backendUser->workspace; $performWorkspaceSwitch = false; // Only admins see multiple tabs, we decided to use it this // way for usability reasons. Regular users might be confused // by switching workspaces with the tabs in a module. if (!$backendUser->isAdmin()) { $wsCur = [$activeWorkspace => true]; $wsList = array_intersect_key($wsList, $wsCur); } else { if ((string) GeneralUtility::_GP('workspace') !== '') { $switchWs = (int) GeneralUtility::_GP('workspace'); if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) { $activeWorkspace = $switchWs; $backendUser->setWorkspace($activeWorkspace); $performWorkspaceSwitch = true; BackendUtility::setUpdateSignal('updatePageTree'); } elseif ($switchWs == WorkspaceService::SELECT_ALL_WORKSPACES) { $this->redirect('fullIndex'); } } } $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', (int) $backendUser->workspace === 0); $this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this->prepareWorkspaceTabs($wsList, $activeWorkspace)); $this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', $activeWorkspace); $this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit')); $workspaceIsAccessible = !($backendUser->workspace === 0 && !$backendUser->isAdmin()); $this->view->assignMultiple(['showGrid' => $workspaceIsAccessible, 'showLegend' => $workspaceIsAccessible, 'pageUid' => (int) GeneralUtility::_GP('id'), 'performWorkspaceSwitch' => $performWorkspaceSwitch, 'workspaceList' => $this->prepareWorkspaceTabs($wsList, $activeWorkspace), 'activeWorkspaceUid' => $activeWorkspace, 'activeWorkspaceTitle' => WorkspaceService::getWorkspaceTitle($activeWorkspace), 'showPreviewLink' => $wsService->canCreatePreviewLink(GeneralUtility::_GP('id'), $activeWorkspace)]); if ($wsService->canCreatePreviewLink(GeneralUtility::_GP('id'), $activeWorkspace)) { $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar(); $iconFactory = $moduleTemplate->getIconFactory(); $showButton = $buttonBar->makeLinkButton()->setHref('#')->setClasses('t3js-preview-link')->setTitle($this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:tooltip.generatePagePreview'))->setIcon($iconFactory->getIcon('module-workspaces-action-preview-link', Icon::SIZE_SMALL)); $buttonBar->addButton($showButton); } $backendUser->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace); }
/** * Basically makes sure that the workspace preview is rendered. * The preview itself consists of three frames, so there are * only the frames-urls we've to generate here * * @param integer $previewWS * @return void */ public function indexAction($previewWS = NULL) { // Get all the GET parameters to pass them on to the frames $queryParameters = GeneralUtility::_GET(); // Remove the GET parameters related to the workspaces module and the page id unset($queryParameters['tx_workspaces_web_workspacesworkspaces']); unset($queryParameters['M']); unset($queryParameters['id']); // Assemble a query string from the retrieved parameters $queryString = GeneralUtility::implodeArrayForUrl('', $queryParameters); // fetch the next and previous stage $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $stage = -99, $this->pageId, $recursionLevel = 0, $selectionType = 'tables_modify'); list(, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray); list(, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray); /** @var $wsService \TYPO3\CMS\Workspaces\Service\WorkspaceService */ $wsService = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService'); $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $GLOBALS['BE_USER']->workspace; if (!is_null($previewWS)) { if (in_array($previewWS, array_keys($wsList)) && $activeWorkspace != $previewWS) { $activeWorkspace = $previewWS; $GLOBALS['BE_USER']->setWorkspace($activeWorkspace); BackendUtility::setUpdateSignal('updatePageTree'); } } /** @var $uriBuilder \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder */ $uriBuilder = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder'); $wsSettingsPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3/'; $wsSettingsUri = $uriBuilder->uriFor('singleIndex', array(), 'TYPO3\\CMS\\Workspaces\\Controller\\ReviewController', 'workspaces', 'web_workspacesworkspaces'); $wsSettingsParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Review'; $wsSettingsUrl = $wsSettingsPath . $wsSettingsUri . $wsSettingsParams; $viewDomain = BackendUtility::getViewDomain($this->pageId); $wsBaseUrl = $viewDomain . '/index.php?id=' . $this->pageId . $queryString; // @todo - handle new pages here // branchpoints are not handled anymore because this feature is not supposed anymore if (\TYPO3\CMS\Workspaces\Service\WorkspaceService::isNewPage($this->pageId)) { $wsNewPageUri = $uriBuilder->uriFor('newPage', array(), 'TYPO3\\CMS\\Workspaces\\Controller\\PreviewController', 'workspaces', 'web_workspacesworkspaces'); $wsNewPageParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Preview'; $this->view->assign('liveUrl', $wsSettingsPath . $wsNewPageUri . $wsNewPageParams); } else { $this->view->assign('liveUrl', $wsBaseUrl . '&ADMCMD_noBeUser=1'); } $this->view->assign('wsUrl', $wsBaseUrl . '&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=' . $GLOBALS['BE_USER']->workspace); $this->view->assign('wsSettingsUrl', $wsSettingsUrl); $this->view->assign('backendDomain', GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')); $splitPreviewTsConfig = BackendUtility::getModTSconfig($this->pageId, 'workspaces.splitPreviewModes'); $splitPreviewModes = GeneralUtility::trimExplode(',', $splitPreviewTsConfig['value']); $allPreviewModes = array('slider', 'vbox', 'hbox'); if (!array_intersect($splitPreviewModes, $allPreviewModes)) { $splitPreviewModes = $allPreviewModes; } $this->pageRenderer->addInlineSetting('Workspaces', 'SplitPreviewModes', $splitPreviewModes); $GLOBALS['BE_USER']->setAndSaveSessionData('workspaces.backend_domain', GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')); $this->pageRenderer->addInlineSetting('Workspaces', 'disableNextStageButton', $this->isInvalidStage($nextStage)); $this->pageRenderer->addInlineSetting('Workspaces', 'disablePreviousStageButton', $this->isInvalidStage($previousStage)); $this->pageRenderer->addInlineSetting('Workspaces', 'disableDiscardStageButton', $this->isInvalidStage($nextStage) && $this->isInvalidStage($previousStage)); $resourcePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('lang') . 'Resources/Public/JavaScript/'; $this->pageRenderer->addJsFile($resourcePath . 'Typo3Lang.js'); $this->pageRenderer->addJsInlineCode('workspaces.preview.lll', ' TYPO3.lang = { visualPreview: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.visualPreview', TRUE)) . ', listView: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.listView', TRUE)) . ', livePreview: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.livePreview', TRUE)) . ', livePreviewDetail: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.livePreviewDetail', TRUE)) . ', workspacePreview: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.workspacePreview', TRUE)) . ', workspacePreviewDetail: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.workspacePreviewDetail', TRUE)) . ', modeSlider: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.modeSlider', TRUE)) . ', modeVbox: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.modeVbox', TRUE)) . ', modeHbox: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:preview.modeHbox', TRUE)) . ', discard: ' . Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:label_doaction_discard', TRUE)) . ', nextStage: ' . Utility\GeneralUtility::quoteJSvalue($nextStage['title']) . ', previousStage: ' . Utility\GeneralUtility::quoteJSvalue($previousStage['title']) . ' };TYPO3.l10n.initialize(); '); $resourcePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('workspaces') . 'Resources/Public/'; $this->pageRenderer->addJsFile($resourcePath . 'JavaScript/preview.js'); }
/** * Initializes the controller before invoking an action method. * * @return void */ protected function initializeAction() { parent::initializeAction(); $backendRelPath = ExtensionManagementUtility::extRelPath('backend'); $this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/ExtDirect.StateProvider.js'); if (WorkspaceService::isOldStyleWorkspaceUsed()) { $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:warning.oldStyleWorkspaceInUser'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } $this->pageRenderer->loadExtJS(); $states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States']; $this->pageRenderer->addInlineSetting('Workspaces', 'States', $states); // Load JavaScript: $this->pageRenderer->addExtDirectCode(array('TYPO3.Workspaces')); $this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/extjs/ux/Ext.grid.RowExpander.js'); $this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/extjs/ux/Ext.app.SearchField.js'); $this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/extjs/ux/Ext.ux.FitToParent.js'); $resourcePath = ExtensionManagementUtility::extRelPath('workspaces') . 'Resources/Public/JavaScript/'; // @todo Integrate additional stylesheet resources $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css'); $this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css'); $filters = array($resourcePath . 'gridfilters/menu/RangeMenu.js', $resourcePath . 'gridfilters/menu/ListMenu.js', $resourcePath . 'gridfilters/GridFilters.js', $resourcePath . 'gridfilters/filter/Filter.js', $resourcePath . 'gridfilters/filter/StringFilter.js', $resourcePath . 'gridfilters/filter/DateFilter.js', $resourcePath . 'gridfilters/filter/ListFilter.js', $resourcePath . 'gridfilters/filter/NumericFilter.js', $resourcePath . 'gridfilters/filter/BooleanFilter.js', $resourcePath . 'gridfilters/filter/BooleanFilter.js'); $custom = $this->getAdditionalResourceService()->getJavaScriptResources(); $resources = array($resourcePath . 'Component/RowDetailTemplate.js', $resourcePath . 'Component/RowExpander.js', $resourcePath . 'Component/TabPanel.js', $resourcePath . 'Store/mainstore.js', $resourcePath . 'configuration.js', $resourcePath . 'helpers.js', $resourcePath . 'actions.js', $resourcePath . 'component.js', $resourcePath . 'toolbar.js', $resourcePath . 'grid.js', $resourcePath . 'workspaces.js'); $javaScriptFiles = array_merge($filters, $custom, $resources); foreach ($javaScriptFiles as $javaScriptFile) { $this->pageRenderer->addJsFile($javaScriptFile); } foreach ($this->getAdditionalResourceService()->getLocalizationResources() as $localizationResource) { $this->pageRenderer->addInlineLanguageLabelFile($localizationResource); } $this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit')); $this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history')); }
/** * Generates grid list array from given versions. * * @param array $versions All available version records * @param string $filterTxt Text to be used to filter record result * @return void */ protected function generateDataArray(array $versions, $filterTxt) { $workspaceAccess = $GLOBALS['BE_USER']->checkWorkspace($GLOBALS['BE_USER']->workspace); $swapStage = $workspaceAccess['publish_access'] & 1 ? \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_PUBLISH_ID : 0; $swapAccess = $GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace) && $GLOBALS['BE_USER']->workspaceSwapAccess(); $this->initializeWorkspacesCachingFramework(); // check for dataArray in cache if ($this->getDataArrayFromCache($versions, $filterTxt) === FALSE) { /** @var $stagesObj \TYPO3\CMS\Workspaces\Service\StagesService */ $stagesObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Workspaces\\Service\\StagesService'); $defaultGridColumns = array(self::GridColumn_Collection => 0, self::GridColumn_CollectionLevel => 0, self::GridColumn_CollectionParent => '', self::GridColumn_CollectionCurrent => '', self::GridColumn_CollectionChildren => 0); foreach ($versions as $table => $records) { $hiddenField = $this->getTcaEnableColumnsFieldName($table, 'disabled'); $isRecordTypeAllowedToModify = $GLOBALS['BE_USER']->check('tables_modify', $table); foreach ($records as $record) { $origRecord = BackendUtility::getRecord($table, $record['t3ver_oid']); $versionRecord = BackendUtility::getRecord($table, $record['uid']); $combinedRecord = \TYPO3\CMS\Workspaces\Domain\Model\CombinedRecord::createFromArrays($table, $origRecord, $versionRecord); $this->getIntegrityService()->checkElement($combinedRecord); if ($hiddenField !== NULL) { $recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord[$hiddenField], $versionRecord[$hiddenField]); } else { $recordState = $this->workspaceState($versionRecord['t3ver_state']); } $isDeletedPage = $table == 'pages' && $recordState == 'deleted'; $viewUrl = \TYPO3\CMS\Workspaces\Service\WorkspaceService::viewSingleRecord($table, $record['uid'], $origRecord, $versionRecord); $versionArray = array(); $versionArray['table'] = $table; $versionArray['id'] = $table . ':' . $record['uid']; $versionArray['uid'] = $record['uid']; $versionArray['workspace'] = $versionRecord['t3ver_id']; $versionArray = array_merge($versionArray, $defaultGridColumns); $versionArray['label_Workspace'] = htmlspecialchars(BackendUtility::getRecordTitle($table, $versionRecord)); $versionArray['label_Live'] = htmlspecialchars(BackendUtility::getRecordTitle($table, $origRecord)); $versionArray['label_Stage'] = htmlspecialchars($stagesObj->getStageTitle($versionRecord['t3ver_stage'])); $tempStage = $stagesObj->getNextStage($versionRecord['t3ver_stage']); $versionArray['label_nextStage'] = htmlspecialchars($stagesObj->getStageTitle($tempStage['uid'])); $tempStage = $stagesObj->getPrevStage($versionRecord['t3ver_stage']); $versionArray['label_prevStage'] = htmlspecialchars($stagesObj->getStageTitle($tempStage['uid'])); $versionArray['path_Live'] = htmlspecialchars(BackendUtility::getRecordPath($record['livepid'], '', 999)); $versionArray['path_Workspace'] = htmlspecialchars(BackendUtility::getRecordPath($record['wspid'], '', 999)); $versionArray['workspace_Title'] = htmlspecialchars(\TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($versionRecord['t3ver_wsid'])); $versionArray['workspace_Tstamp'] = $versionRecord['tstamp']; $versionArray['workspace_Formated_Tstamp'] = BackendUtility::datetime($versionRecord['tstamp']); $versionArray['t3ver_wsid'] = $versionRecord['t3ver_wsid']; $versionArray['t3ver_oid'] = $record['t3ver_oid']; $versionArray['livepid'] = $record['livepid']; $versionArray['stage'] = $versionRecord['t3ver_stage']; $versionArray['icon_Live'] = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($table, $origRecord); $versionArray['icon_Workspace'] = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($table, $versionRecord); $languageValue = $this->getLanguageValue($table, $versionRecord); $versionArray['languageValue'] = $languageValue; $versionArray['language'] = array('cls' => \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses($this->getSystemLanguageValue($languageValue, 'flagIcon')), 'title' => htmlspecialchars($this->getSystemLanguageValue($languageValue, 'title'))); $versionArray['allowedAction_nextStage'] = $isRecordTypeAllowedToModify && $stagesObj->isNextStageAllowedForUser($versionRecord['t3ver_stage']); $versionArray['allowedAction_prevStage'] = $isRecordTypeAllowedToModify && $stagesObj->isPrevStageAllowedForUser($versionRecord['t3ver_stage']); if ($swapAccess && $swapStage != 0 && $versionRecord['t3ver_stage'] == $swapStage) { $versionArray['allowedAction_swap'] = $isRecordTypeAllowedToModify && $stagesObj->isNextStageAllowedForUser($swapStage); } elseif ($swapAccess && $swapStage == 0) { $versionArray['allowedAction_swap'] = $isRecordTypeAllowedToModify; } else { $versionArray['allowedAction_swap'] = FALSE; } $versionArray['allowedAction_delete'] = $isRecordTypeAllowedToModify; // preview and editing of a deleted page won't work ;) $versionArray['allowedAction_view'] = !$isDeletedPage && $viewUrl; $versionArray['allowedAction_edit'] = $isRecordTypeAllowedToModify && !$isDeletedPage; $versionArray['allowedAction_editVersionedPage'] = $isRecordTypeAllowedToModify && !$isDeletedPage; $versionArray['state_Workspace'] = $recordState; $versionArray = array_merge($versionArray, $this->getAdditionalColumnService()->getData($combinedRecord)); if ($filterTxt == '' || $this->isFilterTextInVisibleColumns($filterTxt, $versionArray)) { $versionIdentifier = $versionArray['id']; $this->dataArray[$versionIdentifier] = $versionArray; } } } // Suggested slot method: // methodName(\TYPO3\CMS\Workspaces\Service\GridDataService $gridData, array &$dataArray, array $versions) $this->emitSignal(self::SIGNAL_GenerateDataArray_BeforeCaching, $this->dataArray, $versions); // Enrich elements after everything has been processed: foreach ($this->dataArray as &$element) { $identifier = $element['table'] . ':' . $element['t3ver_oid']; $element['integrity'] = array('status' => $this->getIntegrityService()->getStatusRepresentation($identifier), 'messages' => htmlspecialchars($this->getIntegrityService()->getIssueMessages($identifier, TRUE))); } $this->setDataArrayIntoCache($versions, $filterTxt); } // Suggested slot method: // methodName(\TYPO3\CMS\Workspaces\Service\GridDataService $gridData, array &$dataArray, array $versions) $this->emitSignal(self::SIGNAL_GenerateDataArray_PostProcesss, $this->dataArray, $versions); $this->sortDataArray(); $this->resolveDataArrayDependencies(); }
/** * Generates a view link for a page. * * @param string $table * @param string $uid * @return string */ public function viewSingleRecord($table, $uid) { return \TYPO3\CMS\Workspaces\Service\WorkspaceService::viewSingleRecord($table, $uid); }
/** * Create the workspace information * * @return string HTML containing workspace info */ protected function getWorkspaceInfo() { if (ExtensionManagementUtility::isLoaded('workspaces') && ($this->getBackendUser()->workspace !== 0 || $this->getBackendUser()->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) { $wsTitle = htmlspecialchars(WorkspaceService::getWorkspaceTitle($this->getBackendUser()->workspace)); $workspaceInfo = '<div class="bgColor4 workspace-info"><span title="' . $wsTitle . '" onclick="top.goToModule(\'web_WorkspacesWorkspaces\');" style="cursor:pointer;">' . $this->iconFactory->getIcon('apps-toolbar-menu-workspace', Icon::SIZE_SMALL)->render() . '</span>' . $wsTitle . '</div>'; } else { $workspaceInfo = ''; } return $workspaceInfo; }
/** * Create the workspace information * * @return string HTML containing workspace info */ protected function getWorkspaceInfo() { if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace !== 0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) { $wsTitle = htmlspecialchars(\TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($GLOBALS['BE_USER']->workspace)); $workspaceInfo = ' <div class="bgColor4 workspace-info">' . IconUtility::getSpriteIcon('apps-toolbar-menu-workspace', array('title' => $wsTitle, 'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');', 'style' => 'cursor:pointer;')) . $wsTitle . '</div> '; } return $workspaceInfo; }
/** * Basically makes sure that the workspace preview is rendered. * The preview itself consists of three frames, so there are * only the frames-urls we've to generate here * * @param int $previewWS * @return void */ public function indexAction($previewWS = null) { $backendUser = $this->getBackendUser(); // Get all the GET parameters to pass them on to the frames $queryParameters = GeneralUtility::_GET(); // Remove the GET parameters related to the workspaces module and the page id unset($queryParameters['tx_workspaces_web_workspacesworkspaces']); unset($queryParameters['M']); unset($queryParameters['id']); // Assemble a query string from the retrieved parameters $queryString = GeneralUtility::implodeArrayForUrl('', $queryParameters); // fetch the next and previous stage $workspaceItemsArray = $this->workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $stage = -99, $this->pageId, $recursionLevel = 0, $selectionType = 'tables_modify'); list(, $nextStage) = $this->stageService->getNextStageForElementCollection($workspaceItemsArray); list(, $previousStage) = $this->stageService->getPreviousStageForElementCollection($workspaceItemsArray); /** @var $wsService WorkspaceService */ $wsService = GeneralUtility::makeInstance(WorkspaceService::class); $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $backendUser->workspace; if (!is_null($previewWS)) { if (in_array($previewWS, array_keys($wsList)) && $activeWorkspace != $previewWS) { $activeWorkspace = $previewWS; $backendUser->setWorkspace($activeWorkspace); BackendUtility::setUpdateSignal('updatePageTree'); } } /** @var $uriBuilder UriBuilder */ $uriBuilder = $this->objectManager->get(UriBuilder::class); $wsSettingsPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $wsSettingsUri = $uriBuilder->uriFor('singleIndex', array(), ReviewController::class, 'workspaces', 'web_workspacesworkspaces'); $wsSettingsParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Review'; $wsSettingsUrl = $wsSettingsPath . $wsSettingsUri . $wsSettingsParams; $viewDomain = BackendUtility::getViewDomain($this->pageId); $wsBaseUrl = $viewDomain . '/index.php?id=' . $this->pageId . $queryString; // @todo - handle new pages here // branchpoints are not handled anymore because this feature is not supposed anymore if (WorkspaceService::isNewPage($this->pageId)) { $wsNewPageUri = $uriBuilder->uriFor('newPage', array(), PreviewController::class, 'workspaces', 'web_workspacesworkspaces'); $wsNewPageParams = '&tx_workspaces_web_workspacesworkspaces[controller]=Preview'; $liveUrl = $wsSettingsPath . $wsNewPageUri . $wsNewPageParams . '&ADMCMD_prev=IGNORE'; } else { $liveUrl = $wsBaseUrl . '&ADMCMD_noBeUser=1&ADMCMD_prev=IGNORE'; } $wsUrl = $wsBaseUrl . '&ADMCMD_prev=IGNORE&ADMCMD_view=1&ADMCMD_editIcons=1&ADMCMD_previewWS=' . $backendUser->workspace; $backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); $splitPreviewTsConfig = BackendUtility::getModTSconfig($this->pageId, 'workspaces.splitPreviewModes'); $splitPreviewModes = GeneralUtility::trimExplode(',', $splitPreviewTsConfig['value']); $allPreviewModes = array('slider', 'vbox', 'hbox'); if (!array_intersect($splitPreviewModes, $allPreviewModes)) { $splitPreviewModes = $allPreviewModes; } $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $backendUser->workspace; $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Workspaces/Preview'); $this->pageRenderer->addInlineSetting('Workspaces', 'SplitPreviewModes', $splitPreviewModes); $this->pageRenderer->addInlineSetting('Workspaces', 'token', FormProtectionFactory::get('backend')->generateToken('extDirect')); $cssFile = 'EXT:workspaces/Resources/Public/Css/preview.css'; $cssFile = GeneralUtility::getFileAbsFileName($cssFile); $this->pageRenderer->addCssFile(PathUtility::getAbsoluteWebPath($cssFile)); $backendUser->setAndSaveSessionData('workspaces.backend_domain', GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')); $logoPath = GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Images/typo3-topbar@2x.png'); list($logoWidth, $logoHeight) = @getimagesize($logoPath); // High-resolution? $logoWidth = $logoWidth / 2; $logoHeight = $logoHeight / 2; $this->view->assignMultiple(['logoUrl' => PathUtility::getAbsoluteWebPath($logoPath), 'logoLink' => TYPO3_URL_GENERAL, 'logoWidth' => $logoWidth, 'logoHeight' => $logoHeight, 'liveUrl' => $liveUrl, 'wsUrl' => $wsUrl, 'wsSettingsUrl' => $wsSettingsUrl, 'backendDomain' => $backendDomain, 'activeWorkspace' => $wsList[$activeWorkspace], 'splitPreviewModes' => $splitPreviewModes, 'firstPreviewMode' => current($splitPreviewModes), 'enablePreviousStageButton' => !$this->isInvalidStage($previousStage), 'enableNextStageButton' => !$this->isInvalidStage($nextStage), 'enableDiscardStageButton' => !$this->isInvalidStage($nextStage) || !$this->isInvalidStage($previousStage), 'nextStage' => $nextStage['title'], 'nextStageId' => $nextStage['uid'], 'prevStage' => $previousStage['title'], 'prevStageId' => $previousStage['uid']]); foreach ($this->getAdditionalResourceService()->getLocalizationResources() as $localizationResource) { $this->pageRenderer->addInlineLanguageLabelFile($localizationResource); } }
/** * Constructor * * @param \TYPO3\CMS\Backend\Controller\BackendController $backendReference TYPO3 backend object reference */ public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL) { $this->backendReference = $backendReference; $this->backendReference->addJavaScript('TYPO3.Workspaces = { workspaceTitle : ' . GeneralUtility::quoteJSvalue(addslashes(\TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($GLOBALS['BE_USER']->workspace))) . '};'); }
/** * Generates a view link for a page. * * @param string $table * @param string $uid * @return string */ public function viewSingleRecord($table, $uid) { return WorkspaceService::viewSingleRecord($table, $uid); }