/** * @return string */ public function getHTML() { if ($this->pageInfo['doktype'] != 1 || $this->pageInfo['tx_csseo_no_index']) { return ''; } if ($this->pageInfo['sys_language_uid'] > 0) { $pid = $this->pageInfo['pid']; $params = 'id=' . $pid . '&L=' . $this->pageInfo['sys_language_uid']; } else { $pid = $this->pageInfo['uid']; $params = 'id=' . $pid; } $domain = BackendUtility::getViewDomain($pid); $url = $domain . '/index.php?' . $params; $report = []; $content = GeneralUtility::getUrl($url, 0, false, $report); return $report['error'] == 0 ? $content : ''; }
/** * 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'); }
/** * @param integer $id */ protected function processPreview($id) { $pagesTsConfig = BackendUtility::getPagesTSconfig($GLOBALS['_POST']['popViewId']); if (intval($pagesTsConfig['tx_t3extblog.']['singlePid'])) { $record = BackendUtility::getRecord('tx_t3blog_post', $id); $previewPageId = (int) $pagesTsConfig['tx_t3extblog.']['singlePid']; $parameters = array('tx_t3extblog_blogsystem[controller]' => 'Post', 'tx_t3extblog_blogsystem[action]' => 'preview', 'tx_t3extblog_blogsystem[previewPost]' => $record['uid'], 'no_cache' => 1); if ($record['sys_language_uid'] > 0) { if ($record['l18n_parent'] > 0) { $parameters['tx_t3extblog_blogsystem[previewPost]'] = $record['l18n_parent']; } $parameters['L'] = $record['sys_language_uid']; } $previewDomainRootline = BackendUtility::BEgetRootLine($previewPageId); $previewDomain = BackendUtility::getViewDomain($previewPageId, $previewDomainRootline); $queryString = GeneralUtility::implodeArrayForUrl('', $parameters, '', FALSE, TRUE); $GLOBALS['_POST']['viewUrl'] = $previewDomain . '/index.php?id=' . $previewPageId . $queryString; $GLOBALS['_POST']['popViewId_addParams'] = $queryString; $GLOBALS['_POST']['popViewId'] = $previewPageId; } }
/** * Generates a workspace splitted preview link. * * @param int $uid The ID of the record to be linked * @param bool $addDomain Parameter to decide if domain should be added to the generated link, FALSE per default * @return string the preview link without the trailing '/' */ public function generateWorkspaceSplittedPreviewLink($uid, $addDomain = false) { // In case a $pageUid is submitted we need to make sure it points to a live-page if ($uid > 0) { $uid = $this->getLivePageUid($uid); } /** @var $uriBuilder \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder */ $uriBuilder = $this->getObjectManager()->get(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class); $redirect = 'index.php?redirect_url='; // @todo this should maybe be changed so that the extbase URI Builder can deal with module names directly $originalM = GeneralUtility::_GET('M'); GeneralUtility::_GETset('web_WorkspacesWorkspaces', 'M'); $viewScript = $uriBuilder->uriFor('index', array(), 'Preview', 'workspaces', 'web_workspacesworkspaces') . '&id='; GeneralUtility::_GETset($originalM, 'M'); if ($addDomain === true) { return BackendUtility::getViewDomain($uid) . $redirect . urlencode($viewScript) . $uid; } else { return $viewScript; } }
/** * Generates a workspace splitted preview link. * * @param integer $uid The ID of the record to be linked * @param boolean $addDomain Parameter to decide if domain should be added to the generated link, FALSE per default * @return string the preview link without the trailing '/' */ public function generateWorkspaceSplittedPreviewLink($uid, $addDomain = FALSE) { // In case a $pageUid is submitted we need to make sure it points to a live-page if ($uid > 0) { $uid = $this->getLivePageUid($uid); } /** @var $uriBuilder \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder */ $uriBuilder = $this->getObjectManager()->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder'); // This seems to be very harsh to set this directly to "/typo3 but the viewOnClick also // has /index.php as fixed value here and dealing with the backPath is very error-prone // @todo make sure this would work in local extension installation too $backPath = '/' . TYPO3_mainDir; $redirect = $backPath . 'index.php?redirect_url='; // @todo this should maybe be changed so that the extbase URI Builder can deal with module names directly $originalM = GeneralUtility::_GET('M'); GeneralUtility::_GETset('web_WorkspacesWorkspaces', 'M'); $viewScript = $backPath . $uriBuilder->uriFor('index', array(), 'Preview', 'workspaces', 'web_workspacesworkspaces') . '&id='; GeneralUtility::_GETset($originalM, 'M'); if ($addDomain === TRUE) { return BackendUtility::getViewDomain($uid) . $redirect . urlencode($viewScript) . $uid; } else { return $viewScript; } }
/** * 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); } }
/** * This method is called by a hook in the TYPO3 core when a record is saved. * * We use the tx_linkhandler for backend "save & show" button to display records on the configured detail view page. * * @param string $status Type of database operation i.e. new/update. * @param string $table The table currently being processed. * @param integer $id The records id (if any). * @param array $fieldArray The field names and their values to be processed (passed by reference). * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj Reference to the parent object. */ public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $pObj) { if (isset($GLOBALS['_POST']['_savedokview_x'])) { $settingFound = FALSE; $currentPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($GLOBALS['_POST']['popViewId']); $rootPageData = $this->getRootPage($currentPageId); $defaultPageId = isset($rootPageData) && array_key_exists('uid', $rootPageData) ? $rootPageData['uid'] : $currentPageId; $pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($currentPageId); $handlerConfigurationStruct = $pagesTsConfig['mod.']['tx_linkhandler.']; // search for the current setting for given table foreach ($pagesTsConfig['mod.']['tx_linkhandler.'] as $key => $handler) { if (is_array($handler) && $handler['listTables'] === $table) { $settingFound = TRUE; $selectedConfiguration = $key; break; } } if ($settingFound) { $l18nPointer = array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl']) ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] : ''; if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) { $id = $pObj->substNEWwithIDs[$id]; } if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) { $recordArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id); } else { $recordArray = $fieldArray; } if (array_key_exists('previewPageId', $handlerConfigurationStruct[$selectedConfiguration]) && \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']) > 0) { $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']); } else { $previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($defaultPageId); } if ($GLOBALS['BE_USER']->workspace != 0) { $timeToLiveHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) ? intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) : 24 * 2; $wsPreviewValue = ';' . $GLOBALS['BE_USER']->workspace . ':' . $GLOBALS['BE_USER']->user['uid'] . ':' . 60 * 60 * $timeToLiveHours; // get record UID for if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) { $id = $recordArray[$l18nPointer]; } elseif (array_key_exists('t3ver_oid', $recordArray) && intval($recordArray['t3ver_oid']) > 0) { // this makes no sense because we already receive the UID of the WS-Placeholder which will be the real record in the LIVE-WS $id = $recordArray['t3ver_oid']; } } else { $wsPreviewValue = ''; if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) { $id = $recordArray[$l18nPointer]; } } $previewDomainRootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($previewPageId); $previewDomain = \TYPO3\CMS\Backend\Utility\BackendUtility::getViewDomain($previewPageId, $previewDomainRootline); $linkParamValue = 'record:' . $table . ':' . $id; $queryString = '&eID=linkhandlerPreview&linkParams=' . urlencode($linkParamValue . $wsPreviewValue); $languageParam = '&L=' . $recordArray['sys_language_uid']; $queryString .= $languageParam . '&authCode=' . \TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode($linkParamValue . $wsPreviewValue . intval($recordArray['sys_language_uid']), '', 32); $GLOBALS['_POST']['viewUrl'] = $previewDomain . '/index.php?id=' . $previewPageId . $queryString . '&y='; $GLOBALS['_POST']['popViewId_addParams'] = $queryString; } } }