Ejemplo n.º 1
0
 /**
  * @param int $id Current Page id to select Workspace items from.
  * @return array
  */
 public function sendPageToNextStage($id)
 {
     $workspaceService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
     $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $stage = -99, $id, $recursionLevel = 0, $selectionType = 'tables_modify');
     list($currentStage, $nextStage) = $this->getStageService()->getNextStageForElementCollection($workspaceItemsArray);
     // get only the relevant items for processing
     $workspaceItemsArray = $workspaceService->selectVersionsInWorkspace($this->stageService->getWorkspaceId(), $filter = 1, $currentStage['uid'], $id, $recursionLevel = 0, $selectionType = 'tables_modify');
     return array('title' => 'Status message: Page send to next stage - ID: ' . $id . ' - Next stage title: ' . $nextStage['title'], 'items' => $this->getSentToStageWindow($nextStage['uid']), 'affects' => $workspaceItemsArray, 'stageId' => $nextStage['uid']);
 }
Ejemplo n.º 2
0
    /**
     * 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');
    }
 /**
  * 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);
     }
 }