/** * Renders the review module user dependent with all workspaces. * The module will show all records of one workspace. * * @return void */ public function indexAction() { $wsService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class); $this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin())); $this->view->assign('showAllWorkspaceTab', TRUE); $this->view->assign('pageUid', GeneralUtility::_GP('id')); if (GeneralUtility::_GP('id')) { $pageRecord = BackendUtility::getRecord('pages', GeneralUtility::_GP('id')); $this->view->assign('pageTitle', BackendUtility::getRecordTitle('pages', $pageRecord)); } $this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin())); $wsList = $wsService->getAvailableWorkspaces(); $activeWorkspace = $GLOBALS['BE_USER']->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 (!$GLOBALS['BE_USER']->isAdmin()) { $wsCur = array($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; $GLOBALS['BE_USER']->setWorkspace($activeWorkspace); $performWorkspaceSwitch = TRUE; BackendUtility::setUpdateSignal('updatePageTree'); } elseif ($switchWs == WorkspaceService::SELECT_ALL_WORKSPACES) { $this->redirect('fullIndex'); } } } $this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', (int) $GLOBALS['BE_USER']->workspace === 0 ? TRUE : FALSE); $this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this->prepareWorkspaceTabs($wsList, $activeWorkspace)); $this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', $activeWorkspace); $this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit')); $this->view->assign('performWorkspaceSwitch', $performWorkspaceSwitch); $this->view->assign('workspaceList', $wsList); $this->view->assign('activeWorkspaceUid', $activeWorkspace); $this->view->assign('activeWorkspaceTitle', WorkspaceService::getWorkspaceTitle($activeWorkspace)); $this->view->assign('showPreviewLink', $wsService->canCreatePreviewLink(GeneralUtility::_GP('id'), $activeWorkspace)); $GLOBALS['BE_USER']->setAndSaveSessionData('tx_workspace_activeWorkspace', $activeWorkspace); }
/** * Crafts a link to edit a database record or create a new one * * @param integer $pageId * @param string $returnUrl URL to return to * @param string $action * @param string $controller * @return string The <a> tag * @see \TYPO3\CMS\Backend\Utility::editOnClick() */ public function render($pageId, $returnUrl = '', $action = null, $controller = null) { if ($returnUrl == '') { $returnUrl = 'index.php?M=web_CadabraProductadministration&id=' . (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id') . '&moduleToken=' . \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->generateToken('moduleCall', 'web_CadabraProductadministration'); } $params = array('id' => $pageId, 'returnUrl' => $returnUrl); if ($action) { $params['tx_cadabra_web_cadabraproductadministration[action]'] = $action; } if ($controller) { $params['tx_cadabra_web_cadabraproductadministration[controller]'] = $controller; } \TYPO3\CMS\Backend\Utility\BackendUtility::openPageTree((int) $pageId, false); \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree'); $uri = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_CadabraProductadministration', $params); $this->tag->addAttribute('href', $uri); $this->tag->setContent($this->renderChildren()); $this->tag->forceClosingTag(true); return $this->tag->render(); }
/** * Commits the given command. * * @param int $uidClip Uid of clipboard item * @param int $uidTarget Uid of target * @param string $command Command */ protected function commitCommand($uidClip, $uidTarget, $command) { // First prepare user defined hooks $hooks = \CommerceTeam\Commerce\Factory\HookFactory::getHooks('Utility/DataHandlerUtility', 'commitCommand'); // Hook: beforeCommit foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'beforeCommit')) { $hookObj->beforeCommit($uidClip, $uidTarget, $command); } } // we got all info we need - commit command switch ($command) { case 'overwrite': BackendUtility::overwriteProduct($uidClip, $uidTarget, $this->locales); break; case 'pasteProduct': BackendUtility::copyProduct($uidClip, $uidTarget, false, $this->locales, $this->sorting); break; case 'pasteCategory': BackendUtility::copyCategory($uidClip, $uidTarget, $this->locales, $this->sorting); break; default: die('unknown command'); } // Hook: afterCommit foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'afterCommit')) { $hookObj->afterCommit($uidClip, $uidTarget, $command); } } // Update page tree? if ($this->uPT && (isset($this->data['tx_commerce_categories']) || isset($this->cmd['tx_commerce_categories'])) && (isset($this->data['tx_commerce_products']) || isset($this->cmd['tx_commerce_products']))) { \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updateFolderTree'); } }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj */ public function main() { $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); $this->getLanguageService()->includeLLFile('EXT:wizard_crpages/Resources/Private/Language/locallang.xlf'); $theCode = ''; $this->tsConfig = BackendUtility::getPagesTSconfig($this->pObj->id); $this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array(); // Create new pages here? $pageRecord = BackendUtility::getRecord('pages', $this->pObj->id, 'uid', ' AND ' . $this->getBackendUser()->getPagePermsClause(8)); $pageRepository = GeneralUtility::makeInstance(PageRepository::class); $menuItems = $pageRepository->getMenu($this->pObj->id, '*', 'sorting', '', false); if (is_array($pageRecord)) { $data = GeneralUtility::_GP('data'); if (is_array($data['pages'])) { if (GeneralUtility::_GP('createInListEnd')) { $endI = end($menuItems); $thePid = -(int) $endI['uid']; if (!$thePid) { $thePid = $this->pObj->id; } } else { $thePid = $this->pObj->id; } $firstRecord = true; $previousIdentifier = ''; foreach ($data['pages'] as $identifier => $dat) { if (!trim($dat['title'])) { unset($data['pages'][$identifier]); } else { $data['pages'][$identifier]['hidden'] = GeneralUtility::_GP('hidePages') ? 1 : 0; $data['pages'][$identifier]['nav_hide'] = GeneralUtility::_GP('hidePagesInMenus') ? 1 : 0; if ($firstRecord) { $firstRecord = false; $data['pages'][$identifier]['pid'] = $thePid; } else { $data['pages'][$identifier]['pid'] = '-' . $previousIdentifier; } $previousIdentifier = $identifier; } } if (!empty($data['pages'])) { reset($data); $dataHandler = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class); $dataHandler->stripslashes_values = 0; // set default TCA values specific for the user $TCAdefaultOverride = $this->getBackendUser()->getTSConfigProp('TCAdefaults'); if (is_array($TCAdefaultOverride)) { $dataHandler->setDefaultsFromUserTS($TCAdefaultOverride); } $dataHandler->start($data, array()); $dataHandler->process_datamap(); BackendUtility::setUpdateSignal('updatePageTree'); $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, '', $this->getLanguageService()->getLL('wiz_newPages_create')); } else { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, '', $this->getLanguageService()->getLL('wiz_newPages_noCreate'), FlashMessage::ERROR); } $theCode .= $flashMessage->render(); // Display result: $menuItems = $pageRepository->getMenu($this->pObj->id, '*', 'sorting', '', false); $lines = array(); foreach ($menuItems as $record) { BackendUtility::workspaceOL('pages', $record); if (is_array($record)) { $lines[] = '<span class="text-nowrap" title="' . BackendUtility::titleAttribForPages($record, '', false) . '">' . $this->iconFactory->getIconForRecord('pages', $record, Icon::SIZE_SMALL)->render() . htmlspecialchars(GeneralUtility::fixed_lgd_cs($record['title'], $this->getBackendUser()->uc['titleLen'])) . '</span>'; } } $theCode .= '<h4>' . $this->getLanguageService()->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines); } else { // Display create form $this->typeSelectHtml = $this->getTypeSelectHtml(); $tableData = array(); for ($a = 0; $a < 5; $a++) { $tableData[] = $this->getFormLine($a); } $theCode .= ' <h4>' . $this->getLanguageService()->getLL('wiz_newPages') . ':</h4> <div class="form-group t3js-wizardcrpages-container"> ' . implode(LF, $tableData) . ' </div> <div class="form-group"> <input class="btn btn-default t3js-wizardcrpages-createnewfields" type="button" value="' . $this->getLanguageService()->getLL('wiz_newPages_addMoreLines') . '" /> </div> <div class="form-group"> <div class="checkbox"> <label for="createInListEnd"> <input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> ' . $this->getLanguageService()->getLL('wiz_newPages_listEnd') . ' </label> </div> <div class="checkbox"> <label for="hidePages"> <input type="checkbox" name="hidePages" id="hidePages" value="1" /> ' . $this->getLanguageService()->getLL('wiz_newPages_hidePages') . ' </label> </div> <div class="checkbox"> <label for="hidePagesInMenus"> <input type="checkbox" name="hidePagesInMenus" id="hidePagesInMenus" value="1" /> ' . $this->getLanguageService()->getLL('wiz_newPages_hidePagesInMenus') . ' </label> </div> </div> <div class="form-group"> <input class="btn btn-default" type="submit" name="create" value="' . $this->getLanguageService()->getLL('wiz_newPages_lCreate') . '" /> <input class="btn btn-default" type="reset" value="' . $this->getLanguageService()->getLL('wiz_newPages_lReset') . '" /> </div>'; $this->getPageRenderer()->loadJquery(); $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/WizardCrpages/WizardCreatePages'); // Add inline code $inlineJavaScriptCode = 'var tpl = "' . addslashes(str_replace(array(LF, TAB), array('', ''), $this->getFormLine('#'))) . '", i, line, div, bg, label;'; $this->getPageRenderer()->addJsInlineCode('wizard_crpages', $inlineJavaScriptCode); } } else { $theCode .= GeneralUtility::makeInstance(FlashMessage::class, '', $this->getLanguageService()->getLL('wiz_newPages_errorMsg1'), FlashMessage::ERROR)->render(); } // CSH $theCode .= BackendUtility::cshItem('_MOD_web_func', 'tx_wizardcrpages', null, '<div class="t3-help">|</div>'); $out = $this->pObj->doc->header($this->getLanguageService()->getLL('wiz_crMany')); $out .= $this->pObj->doc->section('', $theCode, false, true); return $out; }
/** * 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'); }
/** * Redirecting the user after the processing has been done. * Might also display error messages directly, if any. * * @return void */ public function finish() { // Prints errors, if there are any $this->fileProcessor->printLogErrorMessages($this->redirect); \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updateFolderTree'); if ($this->redirect) { \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->redirect); } }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj */ public function main() { $lang = $this->getLanguageService(); $lang->includeLLFile('EXT:wizard_sortpages/Resources/Private/Language/locallang.xlf'); $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal'); $out = '<h1>' . htmlspecialchars($lang->getLL('wiz_sort')) . '</h1>'; if ($this->getBackendUser()->workspace === 0) { $theCode = ''; // Check if user has modify permissions to $sys_pages = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class); $sortByField = GeneralUtility::_GP('sortByField'); if ($sortByField) { $menuItems = array(); if ($sortByField === 'title' || $sortByField === 'subtitle' || $sortByField === 'crdate' || $sortByField === 'tstamp') { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', $sortByField, '', false); } elseif ($sortByField === 'REV') { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', 'sorting', '', false); $menuItems = array_reverse($menuItems); } if (!empty($menuItems)) { $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class); $menuItems = array_reverse($menuItems); $cmd = array(); foreach ($menuItems as $r) { $cmd['pages'][$r['uid']]['move'] = $this->pObj->id; } $tce->start(array(), $cmd); $tce->process_cmdmap(); BackendUtility::setUpdateSignal('updatePageTree'); } } $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', false); if (!empty($menuItems)) { $lines = array(); $lines[] = '<thead><tr>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_title') . '</th>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_subtitle') . '</th>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_tChange') . '</th>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_tCreate') . '</th>'; $lines[] = '</tr></thead>'; $iconFactory = GeneralUtility::makeInstance(IconFactory::class); foreach ($menuItems as $rec) { $m_perms_clause = $this->getBackendUser()->getPagePermsClause(2); // edit permissions for that page! $pRec = BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause); $lines[] = '<tr><td nowrap="nowrap">' . $iconFactory->getIconForRecord('pages', $rec, Icon::SIZE_SMALL)->render() . (!is_array($pRec) ? '<strong class="text-danger">' . $lang->getLL('wiz_W', true) . '</strong></span> ' : '') . htmlspecialchars(GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</td> <td nowrap="nowrap">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($rec['subtitle'], $this->getBackendUser()->uc['titleLen'])) . '</td> <td nowrap="nowrap">' . BackendUtility::datetime($rec['tstamp']) . '</td> <td nowrap="nowrap">' . BackendUtility::datetime($rec['crdate']) . '</td> </tr>'; } $theCode .= '<h2>' . $lang->getLL('wiz_currentPageOrder', true) . '</h2>'; $theCode .= '<div class="table-fit"><table class="table table-striped table-hover">' . implode('', $lines) . '</table></div>'; // Menu: $lines = array(); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_title'), 'title'); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_subtitle'), 'subtitle'); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_tChange'), 'tstamp'); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_tCreate'), 'crdate'); $lines[] = ''; $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_REVERSE'), 'REV'); $theCode .= '<h4>' . $lang->getLL('wiz_changeOrder') . '</h4><p>' . implode(' ', $lines) . '</p>'; } else { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('no_subpages'), '', FlashMessage::NOTICE); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } // CSH: $theCode .= BackendUtility::cshItem('_MOD_web_func', 'tx_wizardsortpages', null, '<span class="btn btn-default btn-sm">|</span>'); $out .= '<div>' . $theCode . '</div>'; } else { $out .= '<div>Sorry, this function is not available in the current draft workspace!</div>'; } return $out; }
/** * Handling the closing of a document * * @param int $code Close code: 0/1 will redirect to $this->retUrl, 3 will clear the docHandler (thus closing all * documents) and other values will call setDocument with ->retUrl * @return void */ public function closeDocument($code = 0) { // If current document is found in docHandler, // then unset it, possibly unset it ALL and finally, write it to the session data if (isset($this->docHandler[$this->storeUrlMd5])) { // add the closing document to the recent documents $recentDocs = $this->getBackendUser()->getModuleData('opendocs::recent'); if (!is_array($recentDocs)) { $recentDocs = array(); } $closedDoc = $this->docHandler[$this->storeUrlMd5]; $recentDocs = array_merge(array($this->storeUrlMd5 => $closedDoc), $recentDocs); if (count($recentDocs) > 8) { $recentDocs = array_slice($recentDocs, 0, 8); } // remove it from the list of the open documents unset($this->docHandler[$this->storeUrlMd5]); if ($code == '3') { $recentDocs = array_merge($this->docHandler, $recentDocs); $this->docHandler = array(); } $this->getBackendUser()->pushModuleData('opendocs::recent', $recentDocs); $this->getBackendUser()->pushModuleData('FormEngine', array($this->docHandler, $this->docDat[1])); BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler)); } // If ->returnEditConf is set, then add the current content of editconf to the ->retUrl variable: (used by // other scripts, like wizard_add, to know which records was created or so...) if ($this->returnEditConf && $this->retUrl != BackendUtility::getModuleUrl('dummy')) { $this->retUrl .= '&returnEditConf=' . rawurlencode(json_encode($this->editconf)); } // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl if (!$code || $code == 1) { HttpUtility::redirect($this->retUrl); } else { $this->setDocument('', $this->retUrl); } }
/** * Generate the main settings form: * * @return void */ public function main() { $this->content .= '<form action="' . BackendUtility::getModuleUrl('user_setup') . '" method="post" id="SetupModuleController" name="usersetup" enctype="multipart/form-data">'; if ($this->languageUpdate) { $this->moduleTemplate->addJavaScriptCode('languageUpdate', ' if (top && top.TYPO3.ModuleMenu.App) { top.TYPO3.ModuleMenu.App.refreshMenu(); } '); } if ($this->pagetreeNeedsRefresh) { BackendUtility::setUpdateSignal('updatePageTree'); } // Start page: $this->moduleTemplate->getPageRenderer()->addJsFile('EXT:backend/Resources/Public/JavaScript/md5.js'); // Use a wrapper div $this->content .= '<div id="user-setup-wrapper">'; // Load available backend modules $this->loadModules = GeneralUtility::makeInstance(ModuleLoader::class); $this->loadModules->observeWorkspaces = true; $this->loadModules->load($GLOBALS['TBE_MODULES']); $this->content .= $this->moduleTemplate->header($this->getLanguageService()->getLL('UserSettings')); $this->addFlashMessages(); // Render user switch $this->content .= $this->renderSimulateUserSelectAndLabel(); // Render the menu items $menuItems = $this->renderUserSetup(); $this->content .= $this->moduleTemplate->getDynamicTabMenu($menuItems, 'user-setup', 1, false, false); $formToken = $this->formProtection->generateToken('BE user setup', 'edit'); $this->content .= '<div>'; $this->content .= '<input type="hidden" name="simUser" value="' . (int) $this->simUser . '" /> <input type="hidden" name="formToken" value="' . htmlspecialchars($formToken) . '" /> <input type="hidden" value="1" name="data[save]" /> <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />'; $this->content .= '</div>'; // End of wrapper div $this->content .= '</div>'; // Setting up the buttons and markers for docheader $this->getButtons(); // Build the <body> for the module // Renders the module page $this->moduleTemplate->setContent($this->content); $this->content .= '</form>'; }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj * @todo Define visibility */ public function main() { global $SOBE, $LANG; $out = $this->pObj->doc->header($LANG->getLL('wiz_sort')); if ($GLOBALS['BE_USER']->workspace === 0) { $theCode = ''; // Check if user has modify permissions to $sys_pages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $sortByField = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sortByField'); if ($sortByField) { $menuItems = array(); if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('title,subtitle,crdate,tstamp', $sortByField)) { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', $sortByField, '', 0); } elseif ($sortByField == 'REV') { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', 'sorting', '', 0); $menuItems = array_reverse($menuItems); } if (count($menuItems)) { $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandler\\DataHandler'); $tce->stripslashes_values = 0; $menuItems = array_reverse($menuItems); $cmd = array(); foreach ($menuItems as $r) { $cmd['pages'][$r['uid']]['move'] = $this->pObj->id; } $tce->start(array(), $cmd); $tce->process_cmdmap(); \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree'); } } $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0); $lines = array(); $lines[] = '<tr class="t3-row-header"> <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title') . '</td> ' . (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('cms') ? '<td> ' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle') . '</td>' : '') . ' <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp') . '</td> <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate') . '</td> </tr>'; foreach ($menuItems as $rec) { $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2); // edit permissions for that page! $pRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause); $lines[] = '<tr><td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec) . (!is_array($pRec) ? $GLOBALS['TBE_TEMPLATE']->rfw('<strong>' . $LANG->getLL('wiz_W', 1) . '</strong> ') : '') . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . ' </td> ' . (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('cms') ? '<td nowrap="nowrap">' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['subtitle'], $GLOBALS['BE_USER']->uc['titleLen'])) . ' </td>' : '') . ' <td nowrap="nowrap">' . \t3lib_Befunc::datetime($rec['tstamp']) . ' </td> <td nowrap="nowrap">' . \t3lib_Befunc::datetime($rec['crdate']) . ' </td> </tr>'; } $theCode .= '<h4>' . $LANG->getLL('wiz_currentPageOrder', TRUE) . '</h4> <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">' . implode('', $lines) . '</table><br />'; if (count($menuItems)) { // Menu: $lines = array(); $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title'); if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('cms')) { $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle'); } $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp'); $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate'); $lines[] = ''; $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'), 'REV'); $theCode .= '<h4>' . $LANG->getLL('wiz_changeOrder') . '</h4>' . implode('<br />', $lines); } // CSH: $theCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_web_func', 'tx_wizardsortpages', $GLOBALS['BACK_PATH'], '<br />|'); $out .= $this->pObj->doc->section('', $theCode, 0, 1); } else { $out .= $this->pObj->doc->section('', 'Sorry, this function is not available in the current draft workspace!', 0, 1, 1); } return $out; }
/** * Generate the main settings form: * * @return void */ public function main() { if ($this->languageUpdate) { $this->doc->JScodeArray['languageUpdate'] .= ' if (top.refreshMenu) { top.refreshMenu(); } else { top.TYPO3ModuleMenu.refreshMenu(); } '; } if ($this->pagetreeNeedsRefresh) { BackendUtility::setUpdateSignal('updatePageTree'); } // Start page: $this->doc->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js'); // Use a wrapper div $this->content .= '<div id="user-setup-wrapper">'; // Load available backend modules $this->loadModules = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Module\ModuleLoader::class); $this->loadModules->observeWorkspaces = TRUE; $this->loadModules->load($GLOBALS['TBE_MODULES']); $this->content .= $this->doc->header($this->getLanguageService()->getLL('UserSettings')); // Show if setup was saved if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('setupWasUpdated'), $this->getLanguageService()->getLL('UserSettings')); $this->content .= $flashMessage->render(); } // Show if temporary data was cleared if ($this->tempDataIsCleared) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('tempDataClearedFlashMessage'), $this->getLanguageService()->getLL('tempDataCleared')); $this->content .= $flashMessage->render(); } // Show if temporary data was cleared if ($this->settingsAreResetToDefault) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('settingsAreReset'), $this->getLanguageService()->getLL('resetConfiguration')); $this->content .= $flashMessage->render(); } // Notice if ($this->setupIsUpdated || $this->settingsAreResetToDefault) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('activateChanges'), '', FlashMessage::INFO); $this->content .= $flashMessage->render(); } // If password is updated, output whether it failed or was OK. if ($this->passwordIsSubmitted) { $flashMessage = NULL; switch ($this->passwordIsUpdated) { case self::PASSWORD_OLD_WRONG: $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('oldPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR); break; case self::PASSWORD_NOT_THE_SAME: $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR); break; case self::PASSWORD_UPDATED: $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_ok'), $this->getLanguageService()->getLL('newPassword')); break; } if ($flashMessage) { $this->content .= $flashMessage->render(); } } // Render user switch $this->content .= $this->renderSimulateUserSelectAndLabel(); // Render the menu items $menuItems = $this->renderUserSetup(); $this->content .= $this->doc->getDynamicTabMenu($menuItems, 'user-setup', 1, FALSE, FALSE); $formToken = $this->formProtection->generateToken('BE user setup', 'edit'); $this->content .= $this->doc->section('', '<input type="hidden" name="simUser" value="' . $this->simUser . '" /> <input type="hidden" name="formToken" value="' . $formToken . '" /> <input type="hidden" value="1" name="data[save]" /> <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" /> <input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />'); // End of wrapper div $this->content .= '</div>'; // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers['CSH'] = $docHeaderButtons['csh']; $markers['CONTENT'] = $this->content; // Build the <body> for the module $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); // Renders the module page $this->content = $this->doc->render($this->getLanguageService()->getLL('UserSettings'), $this->content); }
/** * Commits the given command * * @param int $uidClip Uid of clipboard item * @param int $uidTarget Uid of target * @param string $command Command * * @return void */ protected function commitCommand($uidClip, $uidTarget, $command) { // First prepare user defined objects (if any) // for hooks which extend this function: $hookObjectsArr = array(); if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['commitCommandClass'])) { \TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(' hook $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/mod_cce/class.tx_commerce_cce_db.php\'][\'storeDataToDatabase\'] is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Utility/DataHandlerUtility.php\'][\'commitCommand\'] '); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/mod_cce/class.tx_commerce_cce_db.php']['commitCommandClass'] as $classRef) { $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['commitCommand'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Utility/DataHandlerUtility.php']['commitCommand'] as $classRef) { $hookObjectsArr[] = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); } } // Hook: beforeCommit foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'beforeCommit')) { $hookObj->beforeCommit($uidClip, $uidTarget, $command); } } // we got all info we need - commit command switch ($command) { case 'overwrite': Tx_Commerce_Utility_BackendUtility::overwriteProduct($uidClip, $uidTarget, $this->locales); break; case 'pasteProduct': Tx_Commerce_Utility_BackendUtility::copyProduct($uidClip, $uidTarget, FALSE, $this->locales, $this->sorting); break; case 'pasteCategory': Tx_Commerce_Utility_BackendUtility::copyCategory($uidClip, $uidTarget, $this->locales, $this->sorting); break; default: die('unknown command'); } // Hook: afterCommit foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'afterCommit')) { $hookObj->afterCommit($uidClip, $uidTarget, $command); } } // Update page tree? if ($this->uPT && (isset($this->data['tx_commerce_categories']) || isset($this->cmd['tx_commerce_categories'])) && (isset($this->data['tx_commerce_products']) || isset($this->cmd['tx_commerce_products']))) { \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updateFolderTree'); } }
/** * 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); } }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj */ public function main() { $assigns = []; $assigns['LLPrefix'] = 'LLL:EXT:wizard_sortpages/Resources/Private/Language/locallang.xlf:'; $assigns['workspace'] = $this->getBackendUser()->workspace; if ($this->getBackendUser()->workspace === 0) { // Check if user has modify permissions to $sys_pages = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class); $sortByField = GeneralUtility::_GP('sortByField'); if ($sortByField) { $menuItems = []; if ($sortByField === 'title' || $sortByField === 'subtitle' || $sortByField === 'crdate' || $sortByField === 'tstamp') { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', $sortByField, '', false); } elseif ($sortByField === 'REV') { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', 'sorting', '', false); $menuItems = array_reverse($menuItems); } if (!empty($menuItems)) { $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class); $menuItems = array_reverse($menuItems); $cmd = []; foreach ($menuItems as $r) { $cmd['pages'][$r['uid']]['move'] = $this->pObj->id; } $tce->start([], $cmd); $tce->process_cmdmap(); BackendUtility::setUpdateSignal('updatePageTree'); } } $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', false); $assigns['menuItems'] = $menuItems; if (!empty($menuItems)) { $dataLines = []; foreach ($menuItems as $rec) { $m_perms_clause = $this->getBackendUser()->getPagePermsClause(2); // edit permissions for that page! $pRec = BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause); $line = []; $line['rec'] = $rec; $line['danger'] = !is_array($pRec); $line['title'] = GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen']); $line['subtitle'] = GeneralUtility::fixed_lgd_cs($rec['subtitle'], $this->getBackendUser()->uc['titleLen']); $line['tstamp'] = BackendUtility::datetime($rec['tstamp']); $line['crdate'] = BackendUtility::datetime($rec['crdate']); $dataLines[] = $line; } $assigns['lines'] = $dataLines; // Menu: $dataLines = []; $line = []; $line['title'] = 'wiz_changeOrder_title'; $line['href'] = BackendUtility::getModuleUrl('web_func', ['id' => $GLOBALS['SOBE']->id, 'sortByField' => 'title']); $dataLines[] = $line; $line['title'] = 'wiz_changeOrder_subtitle'; $line['href'] = BackendUtility::getModuleUrl('web_func', ['id' => $GLOBALS['SOBE']->id, 'sortByField' => 'subtitle']); $dataLines[] = $line; $line['title'] = 'wiz_changeOrder_tChange'; $line['href'] = BackendUtility::getModuleUrl('web_func', ['id' => $GLOBALS['SOBE']->id, 'sortByField' => 'tstamp']); $dataLines[] = $line; $line['title'] = 'wiz_changeOrder_tCreate'; $line['href'] = BackendUtility::getModuleUrl('web_func', ['id' => $GLOBALS['SOBE']->id, 'sortByField' => 'crdate']); $dataLines[] = $line; $line['title'] = 'wiz_changeOrder_REVERSE'; $line['href'] = BackendUtility::getModuleUrl('web_func', ['id' => $GLOBALS['SOBE']->id, 'sortByField' => 'REV']); $dataLines[] = $line; $assigns['buttons'] = $dataLines; } else { $lang = $this->getLanguageService(); $lang->includeLLFile('EXT:wizard_sortpages/Resources/Private/Language/locallang.xlf'); $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('no_subpages'), '', FlashMessage::NOTICE); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } // CSH: $assigns['cshItem'] = BackendUtility::cshItem('_MOD_web_func', 'tx_wizardsortpages'); } // Rendering of the output via fluid $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:wizard_sortpages/Resources/Private/Templates/SortPagesWizard.html')); $view->assignMultiple($assigns); return $view->render(); }
/** * Executing the posted actions ... * * @return void * @todo Define visibility */ public function main() { // LOAD TCEmain with data and cmd arrays: $this->tce->start($this->data, $this->cmd); if (is_array($this->mirror)) { $this->tce->setMirror($this->mirror); } // Checking referer / executing $refInfo = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_REFERER')); $httpHost = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); if ($httpHost != $refInfo['host'] && $this->vC != $GLOBALS['BE_USER']->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) { $this->tce->log('', 0, 0, 0, 1, 'Referer host "%s" and server host "%s" did not match and veriCode was not valid either!', 1, array($refInfo['host'], $httpHost)); } else { // Register uploaded files $this->tce->process_uploads($_FILES); // Execute actions: $this->tce->process_datamap(); $this->tce->process_cmdmap(); // Clearing cache: $this->tce->clear_cacheCmd($this->cacheCmd); // Update page tree? if ($this->uPT && (isset($this->data['pages']) || isset($this->cmd['pages']))) { \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree'); } } }
/** * Injects the request object for the current request or subrequest * As this controller goes only through the main() method, it just redirects to the given URL afterwards. * * @param ServerRequestInterface $request the current request * @param ResponseInterface $response * @return ResponseInterface the response with the content */ public function mainAction(ServerRequestInterface $request, ResponseInterface $response) { $this->main(); // Push errors to flash message queue, if there are any $this->fileProcessor->pushErrorMessagesToFlashMessageQueue(); BackendUtility::setUpdateSignal('updateFolderTree'); if ($this->redirect) { return $response->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect))->withStatus(303); } else { // empty response return $response; } }
/** * Import part of module * * @param array $inData Content of POST VAR tx_impexp[].. * @return void Setting content in $this->content * @todo Define visibility */ public function importData($inData) { global $LANG; $access = is_array($this->pageinfo) ? 1 : 0; if ($this->id && $access || $GLOBALS['BE_USER']->user['admin'] && !$this->id) { if ($GLOBALS['BE_USER']->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } if ($inData['new_import']) { unset($inData['import_mode']); } /** @var $import \TYPO3\CMS\Impexp\ImportExport */ $import = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport'); $import->init(0, 'import'); $import->update = $inData['do_update']; $import->import_mode = $inData['import_mode']; $import->enableLogging = $inData['enableLogging']; $import->global_ignore_pid = $inData['global_ignore_pid']; $import->force_all_UIDS = $inData['force_all_UIDS']; $import->showDiff = !$inData['notShowDiff']; $import->allowPHPScripts = $inData['allowPHPScripts']; $import->softrefInputValues = $inData['softrefInputValues']; // OUTPUT creation: $menuItems = array(); // Make input selector: // must have trailing slash. $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; $filesInDir = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir(PATH_site . $path, 't3d,xml', 1, 1); $userPath = $this->userSaveFolder(); //Files from User-Dir $filesInUserDir = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($userPath, 't3d,xml', 1, 1); $filesInDir = array_merge($filesInUserDir, $filesInDir); if (is_dir(PATH_site . $path . 'export/')) { $filesInDir = array_merge($filesInDir, \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1)); } $tempFolder = $this->userTempFolder(); if ($tempFolder) { $temp_filesInDir = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($tempFolder, 't3d,xml', 1, 1); $filesInDir = array_merge($filesInDir, $temp_filesInDir); } // Configuration $row = array(); $opt = array(''); foreach ($filesInDir as $file) { $opt[$file] = substr($file, strlen(PATH_site)); } $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_file', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'], '') . '</td> <td>' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $opt) . '<br />' . sprintf($LANG->getLL('importdata_fromPathS', 1), $path) . (!$import->compress ? '<br /><span class="typo3-red">' . $LANG->getLL('importdata_noteNoDecompressorAvailable', 1) . '</span>' : '') . '</td> </tr>'; $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_importOptions', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_update', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' /> <label for="checkDo_update">' . $LANG->getLL('importdata_updateRecords', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_thisOptionRequiresThat', 1) . ')</em>' . ($inData['do_update'] ? ' <hr/> <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' /> <label for="checkGlobal_ignore_pid">' . $LANG->getLL('importdata_ignorePidDifferencesGlobally', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_ifYouSetThis', 1) . ')</em> ' : '') . '</td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_options', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' /> <label for="checkNotShowDiff">' . $LANG->getLL('importdata_doNotShowDifferences', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_greenValuesAreFrom', 1) . ')</em> <br/><br/> ' . ($GLOBALS['BE_USER']->isAdmin() ? ' <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' /> <label for="checkAllowPHPScripts">' . $LANG->getLL('importdata_allowToWriteBanned', 1) . '</label><br/>' : '') . (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? ' <br/> <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' /> <label for="checkForce_all_UIDS"><span class="typo3-red">' . $LANG->getLL('importdata_force_all_UIDS', 1) . '</span></label><br/> <em>(' . $LANG->getLL('importdata_force_all_UIDS_descr', 1) . ')</em>' : '') . ' </td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_action', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'], '') . '</td> <td>' . (!$inData['import_file'] ? '<input type="submit" value="' . $LANG->getLL('importdata_preview', 1) . '" />' . ($inData['file'] ? ' - <input type="submit" value="' . ($inData['do_update'] ? $LANG->getLL('importdata_update_299e', 1) : $LANG->getLL('importdata_import', 1)) . '" name="tx_impexp[import_file]" onclick="return confirm(\'' . $LANG->getLL('importdata_areYouSure', 1) . '\');" />' : '') : '<input type="submit" name="tx_impexp[new_import]" value="' . $LANG->getLL('importdata_newImport', 1) . '" />') . ' <input type="hidden" name="tx_impexp[action]" value="import" /></td> </tr>'; $row[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_enableLogging', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' /> <label for="checkEnableLogging">' . $LANG->getLL('importdata_writeIndividualDbActions', 1) . '</label><br/> <em>(' . $LANG->getLL('importdata_thisIsDisabledBy', 1) . ')</em> </td> </tr>'; $menuItems[] = array('label' => $LANG->getLL('importdata_import', 1), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // Upload file: $tempFolder = $this->userTempFolder(); if ($tempFolder) { $row = array(); $row[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_uploadFileFromLocal', 1) . '</strong></td> </tr>'; $row[] = '<tr class="bgColor4"> <td>' . $LANG->getLL('importdata_browse', 1) . \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'], '') . '</td> <td> <input type="file" name="upload_1"' . $this->doc->formWidth(35) . ' size="40" /> <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder) . '" /> <input type="hidden" name="file[upload][1][data]" value="1" /><br /> <input type="submit" name="_upload" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" /> <input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles', 1) . '</label> </td> </tr>'; if (\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_upload')) { $row[] = '<tr class="bgColor4"> <td>' . $LANG->getLL('importdata_uploadStatus', 1) . '</td> <td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', 1) . ' ' . substr($this->fileProcessor->internalUploadMap[1], strlen(PATH_site)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', 1) . '</span>') . '</td> </tr>'; } $menuItems[] = array('label' => $LANG->getLL('importdata_upload'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); } // Perform import or preview depending: $overviewContent = ''; $extensionInstallationMessage = ''; $emURL = ''; $inFile = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($inData['file']); if ($inFile && @is_file($inFile)) { $trow = array(); if ($import->loadFile($inFile, 1)) { // Check extension dependencies: $extKeysToInstall = array(); if (is_array($import->dat['header']['extensionDependencies'])) { foreach ($import->dat['header']['extensionDependencies'] as $extKey) { if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) { $extKeysToInstall[] = $extKey; } } } if (count($extKeysToInstall)) { $passParams = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tx_impexp'); unset($passParams['import_mode']); unset($passParams['import_file']); $thisScriptUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI') . '?M=xMOD_tximpexp&id=' . $this->id . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('tx_impexp', $passParams); $emURL = $this->doc->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('em') . 'classes/index.php?CMD[requestInstallExtensions]=' . implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl); $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '". Clicking Import will first take you to the Extension Manager so these dependencies can be resolved.'; } if ($inData['import_file']) { if (!count($extKeysToInstall)) { $import->importData($this->id); \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree'); } else { \TYPO3\CMS\Core\Utility\HttpUtility::redirect($emURL); } } $import->display_import_pid_record = $this->pageinfo; $overviewContent = $import->displayContentOverview(); } // Meta data output: $trow[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $LANG->getLL('importdata_metaData', 1) . '</strong></td> </tr>'; $opt = array(''); foreach ($filesInDir as $file) { $opt[$file] = substr($file, strlen(PATH_site)); } $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_title', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_description', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_notes', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_packager', 1) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/> ' . $LANG->getLL('importdata_email', 1) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td> </tr>'; // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension']; \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $LANG->getLL('importdata_icon', 1) . '</strong></td> <td>' . $iconTag . '</td> </tr>'; } else { \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($fileName); } } } $menuItems[] = array('label' => $LANG->getLL('importdata_metaData_1387'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $trow) . ' </table> '); } // Print errors that might be: $errors = $import->printErrorLog(); $menuItems[] = array('label' => $LANG->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0); // Output tabs: $content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_import', -1); if ($extensionInstallationMessage) { $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->doc->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content; } $this->content .= $this->doc->section('', $content, 0, 1); // Print overview: if ($overviewContent) { $this->content .= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported', 1) : $LANG->getLL('filterpage_structureToBeImported', 1), $overviewContent, 0, 1); } } }
/** * Import part of module * * @param array $inData Content of POST VAR tx_impexp[].. * @throws \BadFunctionCallException * @throws \InvalidArgumentException * @throws \RuntimeException * @return void Setting content in $this->content */ public function importData($inData) { $access = is_array($this->pageinfo) ? 1 : 0; $beUser = $this->getBackendUser(); if ($this->id && $access || $beUser->user['admin'] && !$this->id) { if ($beUser->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } if ($inData['new_import']) { unset($inData['import_mode']); } /** @var $import Import */ $import = GeneralUtility::makeInstance(Import::class); $import->init(); $import->update = $inData['do_update']; $import->import_mode = $inData['import_mode']; $import->enableLogging = $inData['enableLogging']; $import->global_ignore_pid = $inData['global_ignore_pid']; $import->force_all_UIDS = $inData['force_all_UIDS']; $import->showDiff = !$inData['notShowDiff']; $import->allowPHPScripts = $inData['allowPHPScripts']; $import->softrefInputValues = $inData['softrefInputValues']; // OUTPUT creation: // Make input selector: // must have trailing slash. $path = $this->getDefaultImportExportFolder(); $exportFiles = $this->getExportFiles(); $this->shortcutName .= ' (' . $this->pageinfo['title'] . ')'; // Configuration $selectOptions = array(''); foreach ($exportFiles as $file) { $selectOptions[$file->getCombinedIdentifier()] = $file->getPublicUrl(); } $this->standaloneView->assign('import', $import); $this->standaloneView->assign('inData', $inData); $this->standaloneView->assign('fileSelectOptions', $selectOptions); if ($path) { $this->standaloneView->assign('importPath', sprintf($this->lang->getLL('importdata_fromPathS', true), $path->getCombinedIdentifier())); } else { $this->standaloneView->assign('importPath', $this->lang->getLL('importdata_no_default_upload_folder', true)); } $this->standaloneView->assign('isAdmin', $beUser->isAdmin()); // Upload file: $tempFolder = $this->getDefaultImportExportFolder(); if ($tempFolder) { $this->standaloneView->assign('tempFolder', $tempFolder->getCombinedIdentifier()); $this->standaloneView->assign('hasTempUploadFolder', true); if (GeneralUtility::_POST('_upload')) { $this->standaloneView->assign('submitted', GeneralUtility::_POST('_upload')); $this->standaloneView->assign('noFileUploaded', $this->fileProcessor->internalUploadMap[1]); if ($this->uploadedFiles[0]) { $this->standaloneView->assign('uploadedFile', $this->uploadedFiles[0]->getName()); } } } // Perform import or preview depending: $inFile = $this->getFile($inData['file']); if ($inFile !== null && $inFile->exists()) { $this->standaloneView->assign('metaDataInFileExists', true); $importInhibitedMessages = array(); if ($import->loadFile($inFile->getForLocalProcessing(false), 1)) { $importInhibitedMessages = $import->checkImportPrerequisites(); if ($inData['import_file']) { if (empty($importInhibitedMessages)) { $import->importData($this->id); BackendUtility::setUpdateSignal('updatePageTree'); } } $import->display_import_pid_record = $this->pageinfo; $this->standaloneView->assign('contentOverview', $import->displayContentOverview()); } // Compile messages which are inhibiting a proper import and add them to output. if (!empty($importInhibitedMessages)) { $flashMessageQueue = GeneralUtility::makeInstance(FlashMessageService::class)->getMessageQueueByIdentifier('impexp.errors'); foreach ($importInhibitedMessages as $message) { $flashMessageQueue->addMessage(GeneralUtility::makeInstance(FlashMessage::class, $message, '', FlashMessage::ERROR)); } } } // Print errors that might be: $errors = $import->printErrorLog(); $this->standaloneView->assign('errors', trim($errors)); } }
/** * Main function, starting the rendering of the list. * * @return void */ public function main() { $backendUser = $this->getBackendUserAuthentication(); $lang = $this->getLanguageService(); // Loading current page record and checking access: $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); $access = is_array($this->pageinfo) ? 1 : 0; // Start document template object: // We need to keep this due to deeply nested dependencies $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class); $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler'); $calcPerms = $backendUser->calcPerms($this->pageinfo); $userCanEditPage = $calcPerms & Permission::PAGE_EDIT && !empty($this->id) && ($backendUser->isAdmin() || (int) $this->pageinfo['editlock'] === 0); if ($userCanEditPage) { $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', 'function(PageActions) { PageActions.setPageId(' . (int) $this->id . '); PageActions.initializePageTitleRenaming(); }'); } $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Tooltip'); // Apply predefined values for hidden checkboxes // Set predefined value for DisplayBigControlPanel: if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') { $this->MOD_SETTINGS['bigControlPanel'] = true; } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') { $this->MOD_SETTINGS['bigControlPanel'] = false; } // Set predefined value for Clipboard: if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') { $this->MOD_SETTINGS['clipBoard'] = true; } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') { $this->MOD_SETTINGS['clipBoard'] = false; } else { if ($this->MOD_SETTINGS['clipBoard'] === null) { $this->MOD_SETTINGS['clipBoard'] = true; } } // Set predefined value for LocalizationView: if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') { $this->MOD_SETTINGS['localization'] = true; } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') { $this->MOD_SETTINGS['localization'] = false; } // Initialize the dblist object: /** @var $dblist RecordList\DatabaseRecordList */ $dblist = GeneralUtility::makeInstance(RecordList\DatabaseRecordList::class); $dblist->script = BackendUtility::getModuleUrl('web_list'); $dblist->calcPerms = $calcPerms; $dblist->thumbs = $backendUser->uc['thumbnailsByDefault']; $dblist->returnUrl = $this->returnUrl; $dblist->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0; $dblist->localizationView = $this->MOD_SETTINGS['localization']; $dblist->showClipboard = 1; $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView']; $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView']; $dblist->hideTables = $this->modTSconfig['properties']['hideTables']; $dblist->hideTranslations = $this->modTSconfig['properties']['hideTranslations']; $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.']; $dblist->allowedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], true); $dblist->deniedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], true); $dblist->newWizards = $this->modTSconfig['properties']['newWizards'] ? 1 : 0; $dblist->pageRow = $this->pageinfo; $dblist->counter++; $dblist->MOD_MENU = ['bigControlPanel' => '', 'clipBoard' => '', 'localization' => '']; $dblist->modTSconfig = $this->modTSconfig; $clickTitleMode = trim($this->modTSconfig['properties']['clickTitleMode']); $dblist->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode; if (isset($this->modTSconfig['properties']['tableDisplayOrder.'])) { $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class); $dblist->setTableDisplayOrder($typoScriptService->convertTypoScriptArrayToPlainArray($this->modTSconfig['properties']['tableDisplayOrder.'])); } // Clipboard is initialized: // Start clipboard $dblist->clipObj = GeneralUtility::makeInstance(Clipboard::class); // Initialize - reads the clipboard content from the user session $dblist->clipObj->initializeClipboard(); // Clipboard actions are handled: // CB is the clipboard command array $CB = GeneralUtility::_GET('CB'); if ($this->cmd == 'setCB') { // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked. // By merging we get a full array of checked/unchecked elements // This is set to the 'el' array of the CB after being parsed so only the table in question is registered. $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array) GeneralUtility::_POST('CBC')), $this->cmd_table); } if (!$this->MOD_SETTINGS['clipBoard']) { // If the clipboard is NOT shown, set the pad to 'normal'. $CB['setP'] = 'normal'; } // Execute commands. $dblist->clipObj->setCmd($CB); // Clean up pad $dblist->clipObj->cleanCurrent(); // Save the clipboard content $dblist->clipObj->endClipboard(); // This flag will prevent the clipboard panel in being shown. // It is set, if the clickmenu-layer is active AND the extended view is not enabled. $dblist->dontShowClipControlPanels = $dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers']; // If there is access to the page or root page is used for searching, then render the list contents and set up the document template object: if ($access || $this->id === 0 && $this->search_levels !== 0 && $this->search_field !== '') { // Deleting records...: // Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table. if ($this->cmd == 'delete') { $items = $dblist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), $this->cmd_table, 1); if (!empty($items)) { $cmd = []; foreach ($items as $iK => $value) { $iKParts = explode('|', $iK); $cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1; } $tce = GeneralUtility::makeInstance(DataHandler::class); $tce->start([], $cmd); $tce->process_cmdmap(); if (isset($cmd['pages'])) { BackendUtility::setUpdateSignal('updatePageTree'); } $tce->printLogErrorMessages(GeneralUtility::getIndpEnv('REQUEST_URI')); } } // Initialize the listing object, dblist, for rendering the list: $this->pointer = max(0, (int) $this->pointer); $dblist->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit); $dblist->setDispFields(); // Render versioning selector: if (ExtensionManagementUtility::isLoaded('version')) { $dblist->HTMLcode .= $this->moduleTemplate->getVersionSelector($this->id); } // Render the list of tables: $dblist->generateList(); $listUrl = $dblist->listURL(); // Add JavaScript functions to the page: $this->moduleTemplate->addJavaScriptCode('RecordListInlineJS', ' function jumpExt(URL,anchor) { // var anc = anchor?anchor:""; window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc; return false; } function jumpSelf(URL) { // window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:""); return false; } function jumpToUrl(URL) { window.location.href = URL; return false; } function setHighlight(id) { // top.fsMod.recentIds["web"]=id; top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting if (top.nav_frame && top.nav_frame.refresh_nav) { top.nav_frame.refresh_nav(); } } ' . $this->moduleTemplate->redirectUrls($listUrl) . ' ' . $dblist->CBfunctions() . ' function editRecords(table,idList,addParams,CBflag) { // window.location.href="' . BackendUtility::getModuleUrl('record_edit', ['returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]) . '&edit["+table+"]["+idList+"]=edit"+addParams; } function editList(table,idList) { // var list=""; // Checking how many is checked, how many is not var pointer=0; var pos = idList.indexOf(","); while (pos!=-1) { if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) { list+=idList.substr(pointer,pos-pointer)+","; } pointer=pos+1; pos = idList.indexOf(",",pointer); } if (cbValue(table+"|"+idList.substr(pointer))) { list+=idList.substr(pointer)+","; } return list ? list : idList; } if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . '; '); // Setting up the context sensitive menu: $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); } // access // Begin to compile the whole page, starting out with page header: if (!$this->id) { $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } else { $title = $this->pageinfo['title']; } $this->body = $this->moduleTemplate->header($title); $this->moduleTemplate->setTitle($title); if (!empty($dblist->HTMLcode)) { $output = $dblist->HTMLcode; } else { $output = ''; $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('noRecordsOnThisPage'), '', FlashMessage::INFO); /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); } $this->body .= '<form action="' . htmlspecialchars($dblist->listURL()) . '" method="post" name="dblistForm">'; $this->body .= $output; $this->body .= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>'; // If a listing was produced, create the page footer with search form etc: if ($dblist->HTMLcode) { // Making field select box (when extended view for a single table is enabled): if ($dblist->table) { $this->body .= $dblist->fieldSelectBox($dblist->table); } // Adding checkbox options for extended listing and clipboard display: $this->body .= ' <!-- Listing options for extended view, clipboard and localization view --> <div class="typo3-listOptions"> <form action="" method="post">'; // Add "display bigControlPanel" checkbox: if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') { $this->body .= '<div class="checkbox">' . '<label for="checkLargeControl">' . BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"') . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', htmlspecialchars($lang->getLL('largeControl'))) . '</label>' . '</div>'; } // Add "clipboard" checkbox: if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') { if ($dblist->showClipboard) { $this->body .= '<div class="checkbox">' . '<label for="checkShowClipBoard">' . BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"') . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', htmlspecialchars($lang->getLL('showClipBoard'))) . '</label>' . '</div>'; } } // Add "localization view" checkbox: if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') { $this->body .= '<div class="checkbox">' . '<label for="checkLocalization">' . BackendUtility::getFuncCheck($this->id, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"') . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', htmlspecialchars($lang->getLL('localization'))) . '</label>' . '</div>'; } $this->body .= ' </form> </div>'; } // Printing clipboard if enabled if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard && ($dblist->HTMLcode || $dblist->clipObj->hasElements())) { $this->body .= '<div class="db_list-dashboard">' . $dblist->clipObj->printClipboard() . '</div>'; } // Additional footer content $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/Modules/Recordlist/index.php']['drawFooterHook']; if (is_array($footerContentHook)) { foreach ($footerContentHook as $hook) { $params = []; $this->body .= GeneralUtility::callUserFunction($hook, $params, $this); } } // Setting up the buttons for docheader $dblist->getDocHeaderButtons($this->moduleTemplate); // searchbox toolbar if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || !empty($dblist->searchString))) { $this->content = $dblist->getSearchBox(); $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox'); $searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton(); $searchButton->setHref('#')->setClasses('t3js-toggle-search-toolbox')->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon'))->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL)); $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($searchButton, ButtonBar::BUTTON_POSITION_LEFT, 90); } if ($this->pageinfo) { $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo); } // Build the <body> for the module $this->content .= $this->body; }
/** * Import part of module * * @param array $inData Content of POST VAR tx_impexp[].. * @throws \BadFunctionCallException * @throws \InvalidArgumentException * @throws \RuntimeException * @return void Setting content in $this->content */ public function importData($inData) { $access = is_array($this->pageinfo) ? 1 : 0; $beUser = $this->getBackendUser(); if ($this->id && $access || $beUser->user['admin'] && !$this->id) { if ($beUser->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } if ($inData['new_import']) { unset($inData['import_mode']); } /** @var $import \TYPO3\CMS\Impexp\ImportExport */ $import = GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\ImportExport::class); $import->init(0, 'import'); $import->update = $inData['do_update']; $import->import_mode = $inData['import_mode']; $import->enableLogging = $inData['enableLogging']; $import->global_ignore_pid = $inData['global_ignore_pid']; $import->force_all_UIDS = $inData['force_all_UIDS']; $import->showDiff = !$inData['notShowDiff']; $import->allowPHPScripts = $inData['allowPHPScripts']; $import->softrefInputValues = $inData['softrefInputValues']; // OUTPUT creation: $menuItems = array(); // Make input selector: // must have trailing slash. $path = $this->getDefaultImportExportFolder(); $exportFiles = $this->getExportFiles(); $this->shortcutName .= ' (' . $this->pageinfo['title'] . ')'; // Configuration $row = array(); $selectOptions = array(''); foreach ($exportFiles as $file) { $selectOptions[$file->getCombinedIdentifier()] = $file->getPublicUrl(); } $row[] = ' <tr> <th colspan="2">' . $this->lang->getLL('importdata_selectFileToImport', true) . '</th> </tr>'; $noCompressorAvailable = !$import->compress ? '<br /><span class="text-danger">' . $this->lang->getLL('importdata_noteNoDecompressorAvailable', true) . '</span>' : ''; $row[] = ' <tr> <td valign="top"> ' . $this->lang->getLL('importdata_file', true) . '' . BackendUtility::cshItem('xMOD_tx_impexp', 'importFile') . ' </td> <td> ' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $selectOptions) . '<br />' . sprintf($this->lang->getLL('importdata_fromPathS', true), $path ? $path->getCombinedIdentifier() : $this->lang->getLL('importdata_no_accessible_file_mount', true)) . $noCompressorAvailable . ' </td> </tr>'; $row[] = ' <tr> <th colspan="2"> ' . $this->lang->getLL('importdata_importOptions', true) . ' </th> </tr>'; $row[] = ' <tr> <td valign="top"> ' . $this->lang->getLL('importdata_update', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'update') . ' </td> <td> <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' /> <label for="checkDo_update">' . $this->lang->getLL('importdata_updateRecords', true) . '</label> <br/> <em>(' . $this->lang->getLL('importdata_thisOptionRequiresThat', true) . ')</em>' . ($inData['do_update'] ? ' <hr/> <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' /> <label for="checkGlobal_ignore_pid">' . $this->lang->getLL('importdata_ignorePidDifferencesGlobally', true) . '</label><br/> <em>(' . $this->lang->getLL('importdata_ifYouSetThis', true) . ')</em> ' : '') . ' </td> </tr>'; $allowPhpScripts = $beUser->isAdmin() ? ' <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' /> <label for="checkAllowPHPScripts">' . $this->lang->getLL('importdata_allowToWriteBanned', true) . '</label><br/>' : ''; $doUpdate = !$inData['do_update'] && $beUser->isAdmin() ? ' <br/> <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' /> <label for="checkForce_all_UIDS"><span class="text-danger">' . $this->lang->getLL('importdata_force_all_UIDS', true) . '</span></label><br/> <em>(' . $this->lang->getLL('importdata_force_all_UIDS_descr', true) . ')</em>' : ''; $row[] = '<tr> <td valign="top"> ' . $this->lang->getLL('importdata_options', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'options') . ' </td> <td> <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' /> <label for="checkNotShowDiff">' . $this->lang->getLL('importdata_doNotShowDifferences', true) . '</label><br/> <em>(' . $this->lang->getLL('importdata_greenValuesAreFrom', true) . ')</em> <br/><br/> ' . $allowPhpScripts . $doUpdate . ' </td> </tr>'; $newImport = !$inData['import_file'] ? '<input class="btn btn-default" type="submit" value="' . $this->lang->getLL('importdata_preview', true) . '" />' . ($inData['file'] ? ' - <input type="hidden" name="not-set" value="1" id="t3js-submit-field" /><input class="btn btn-default t3js-confirm-trigger" type="button" value="' . ($inData['do_update'] ? $this->lang->getLL('importdata_update_299e', true) : $this->lang->getLL('importdata_import', true)) . '" name="tx_impexp[import_file]" data-title="' . $this->lang->getLL('pleaseConfirm', true) . '" data-message="' . $this->lang->getLL('importdata_areYouSure', true) . '" />' : '') : '<input class="btn btn-default" type="submit" name="tx_impexp[new_import]" value="' . $this->lang->getLL('importdata_newImport', true) . '" />'; $row[] = '<tr> <td valign="top"> ' . $this->lang->getLL('importdata_action', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'action') . ' </td> <td> ' . $newImport . ' <input type="hidden" name="tx_impexp[action]" value="import" /> </td> </tr>'; $row[] = '<tr> <td valign="top"> ' . $this->lang->getLL('importdata_enableLogging', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'enableLogging') . ' </td> <td> <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' /> <label for="checkEnableLogging">' . $this->lang->getLL('importdata_writeIndividualDbActions', true) . '</label><br/> <em>(' . $this->lang->getLL('importdata_thisIsDisabledBy', true) . ')</em> </td> </tr>'; $menuItems[] = array('label' => $this->lang->getLL('importdata_import', true), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); // Upload file: $tempFolder = $this->getDefaultImportExportFolder(); if ($tempFolder) { $row = array(); $row[] = ' <tr> <th colspan="2">' . $this->lang->getLL('importdata_uploadFileFromLocal', true) . '</th> </tr>'; $row[] = ' <tr> <td valign="top"> ' . $this->lang->getLL('importdata_browse', true) . BackendUtility::cshItem('xMOD_tx_impexp', 'upload') . ' </td> <td> <input type="file" name="upload_1" size="40" /> <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder->getCombinedIdentifier()) . '" /> <input type="hidden" name="file[upload][1][data]" value="1" /> <br /> <input class="btn btn-default" type="submit" name="_upload" value="' . $this->lang->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', true) . '" /> <input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $this->lang->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', true) . '</label> </td> </tr>'; if (GeneralUtility::_POST('_upload')) { $noFileUploaded = $this->fileProcessor->internalUploadMap[1] ? $this->lang->getLL('importdata_success', true) . ' ' . $this->uploadedFiles[0]->getName() : '<span class="text-danger">' . $this->lang->getLL('importdata_failureNoFileUploaded', true) . '</span>'; $row[] = '<tr class="bgColor4"> <td>' . $this->lang->getLL('importdata_uploadStatus', true) . '</td> <td>' . $noFileUploaded . '</td> </tr>'; } $menuItems[] = array('label' => $this->lang->getLL('importdata_upload'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $row) . ' </table> '); } // Perform import or preview depending: $overviewContent = ''; $extensionInstallationMessage = ''; $inFile = $this->getFile($inData['file']); if ($inFile !== null && $inFile->exists()) { $trow = array(); if ($import->loadFile($inFile->getForLocalProcessing(false), 1)) { // Check extension dependencies: $extKeysToInstall = array(); if (is_array($import->dat['header']['extensionDependencies'])) { foreach ($import->dat['header']['extensionDependencies'] as $extKey) { if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) { $extKeysToInstall[] = $extKey; } } } if (!empty($extKeysToInstall)) { $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '".'; } if ($inData['import_file']) { if (empty($extKeysToInstall)) { $import->importData($this->id); BackendUtility::setUpdateSignal('updatePageTree'); } } $import->display_import_pid_record = $this->pageinfo; $overviewContent = $import->displayContentOverview(); } // Meta data output: $trow[] = '<tr class="bgColor5"> <td colspan="2"><strong>' . $this->lang->getLL('importdata_metaData', true) . '</strong></td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_title', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_description', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_notes', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td> </tr>'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_packager', true) . '</strong></td> <td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/> ' . $this->lang->getLL('importdata_email', true) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td> </tr>'; // Thumbnail icon: if (is_array($import->dat['header']['thumbnail'])) { $pI = pathinfo($import->dat['header']['thumbnail']['filename']); if (GeneralUtility::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) { // Construct filename and write it: $fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension']; GeneralUtility::writeFile($fileName, $import->dat['header']['thumbnail']['content']); // Check that the image really is an image and not a malicious PHP script... if (getimagesize($fileName)) { // Create icon tag: $iconTag = '<img src="../' . PathUtility::stripPathSitePrefix($fileName) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />'; $trow[] = '<tr class="bgColor4"> <td><strong>' . $this->lang->getLL('importdata_icon', true) . '</strong></td> <td>' . $iconTag . '</td> </tr>'; } else { GeneralUtility::unlink_tempfile($fileName); } } } $menuItems[] = array('label' => $this->lang->getLL('importdata_metaData_1387'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> ' . implode(' ', $trow) . ' </table> '); } // Print errors that might be: $errors = $import->printErrorLog(); $menuItems[] = array('label' => $this->lang->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0); // Output tabs: $content = $this->moduleTemplate->getDynamicTabMenu($menuItems, 'tx_impexp_import', 1, false, true, false); if ($extensionInstallationMessage) { $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->moduleTemplate->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content; } $this->content .= $this->moduleTemplate->section('', $content, 0, 1); // Print overview: if ($overviewContent) { $this->content .= $this->moduleTemplate->section($inData['import_file'] ? $this->lang->getLL('importdata_structureHasBeenImported', true) : $this->lang->getLL('filterpage_structureToBeImported', true), $overviewContent, 0, 1); } } }
/** * Generate the main settings form: * * @return void */ public function main() { $this->content .= '<form action="' . BackendUtility::getModuleUrl('user_setup') . '" method="post" id="SetupModuleController" name="usersetup" enctype="multipart/form-data">'; if ($this->languageUpdate) { $this->moduleTemplate->addJavaScriptCode('languageUpdate', ' if (top && top.TYPO3.ModuleMenu.App) { top.TYPO3.ModuleMenu.App.refreshMenu(); } '); } if ($this->pagetreeNeedsRefresh) { BackendUtility::setUpdateSignal('updatePageTree'); } // Start page: $this->moduleTemplate->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/md5.js'); // Use a wrapper div $this->content .= '<div id="user-setup-wrapper">'; // Load available backend modules $this->loadModules = GeneralUtility::makeInstance(ModuleLoader::class); $this->loadModules->observeWorkspaces = true; $this->loadModules->load($GLOBALS['TBE_MODULES']); $this->content .= $this->doc->header($this->getLanguageService()->getLL('UserSettings')); // Show if setup was saved if ($this->setupIsUpdated && !$this->settingsAreResetToDefault) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('setupWasUpdated'), $this->getLanguageService()->getLL('UserSettings')); $this->content .= $flashMessage->render(); } // Show if temporary data was cleared if ($this->settingsAreResetToDefault) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('settingsAreReset'), $this->getLanguageService()->getLL('resetConfiguration')); $this->content .= $flashMessage->render(); } // Notice if ($this->setupIsUpdated || $this->settingsAreResetToDefault) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('activateChanges'), '', FlashMessage::INFO); $this->content .= $flashMessage->render(); } // If password is updated, output whether it failed or was OK. if ($this->passwordIsSubmitted) { $flashMessage = null; switch ($this->passwordIsUpdated) { case self::PASSWORD_OLD_WRONG: $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('oldPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR); break; case self::PASSWORD_NOT_THE_SAME: $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_failed'), $this->getLanguageService()->getLL('newPassword'), FlashMessage::ERROR); break; case self::PASSWORD_UPDATED: $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('newPassword_ok'), $this->getLanguageService()->getLL('newPassword')); break; } if ($flashMessage) { $this->content .= $flashMessage->render(); } } // Render user switch $this->content .= $this->renderSimulateUserSelectAndLabel(); // Render the menu items $menuItems = $this->renderUserSetup(); $this->content .= $this->moduleTemplate->getDynamicTabMenu($menuItems, 'user-setup', 1, false, false); $formToken = $this->formProtection->generateToken('BE user setup', 'edit'); $this->content .= '<div>'; $this->content .= '<input type="hidden" name="simUser" value="' . $this->simUser . '" /> <input type="hidden" name="formToken" value="' . $formToken . '" /> <input type="hidden" value="1" name="data[save]" /> <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />'; $this->content .= '</div>'; // End of wrapper div $this->content .= '</div>'; // Setting up the buttons and markers for docheader $this->getButtons(); // Build the <body> for the module // Renders the module page $this->moduleTemplate->setContent($this->content); $this->content .= '</form>'; }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj * @todo Define visibility */ public function main() { global $SOBE, $LANG; $theCode = ''; $this->tsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($this->pObj->id); $this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array(); // Create loremIpsum code: if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('lorem_ipsum')) { $this->loremIpsumObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz'); } // Create new pages here? $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(8); $pRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $this->pObj->id, 'uid', ' AND ' . $m_perms_clause); $sys_pages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0); if (is_array($pRec)) { $data = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data'); if (is_array($data['pages'])) { if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('createInListEnd')) { $endI = end($menuItems); $thePid = -intval($endI['uid']); if (!$thePid) { $thePid = $this->pObj->id; } } else { $thePid = $this->pObj->id; } $firstRecord = TRUE; $previousIdentifier = ''; foreach ($data['pages'] as $identifier => $dat) { if (!trim($dat['title'])) { unset($data['pages'][$identifier]); } else { $data['pages'][$identifier]['hidden'] = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hidePages') ? 1 : 0; if ($firstRecord) { $firstRecord = FALSE; $data['pages'][$identifier]['pid'] = $thePid; } else { $data['pages'][$identifier]['pid'] = '-' . $previousIdentifier; } $previousIdentifier = $identifier; } } if (count($data['pages'])) { reset($data); $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandler\\DataHandler'); $tce->stripslashes_values = 0; // set default TCA values specific for the user $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults'); if (is_array($TCAdefaultOverride)) { $tce->setDefaultsFromUserTS($TCAdefaultOverride); } $tce->start($data, array()); $tce->process_datamap(); \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree'); $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_create')); } else { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_noCreate'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } $theCode .= $flashMessage->render(); // Display result: $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0); $lines = array(); foreach ($menuItems as $rec) { \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('pages', $rec); if (is_array($rec)) { $lines[] = '<nobr>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec, array('title' => \TYPO3\CMS\Backend\Utility\BackendUtility::titleAttribForPages($rec, '', FALSE))) . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</nobr>'; } } $theCode .= '<h4>' . $LANG->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines); } else { // Display create form $lines = array(); for ($a = 0; $a < 9; $a++) { $lines[] = $this->getFormLine($a); } $theCode .= '<h4>' . $LANG->getLL('wiz_newPages') . ':</h4>' . '<div id="formFieldContainer">' . implode('', $lines) . '</div>' . '<br class="clearLeft" />' . '<input type="button" id="createNewFormFields" value="' . $LANG->getLL('wiz_newPages_addMoreLines') . '" />' . '<br /><br /> <input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" /> <label for="createInListEnd">' . $LANG->getLL('wiz_newPages_listEnd') . '</label><br /> <input type="checkbox" name="hidePages" id="hidePages" value="1" /> <label for="hidePages">' . $LANG->getLL('wiz_newPages_hidePages') . '</label><br /><br /> <input type="submit" name="create" value="' . $LANG->getLL('wiz_newPages_lCreate') . '" /> <input type="reset" value="' . $LANG->getLL('wiz_newPages_lReset') . '" /><br />'; // Add ExtJS inline code $extCode = ' var tpl = "' . addslashes(str_replace(array(LF, TAB), array('', ''), $this->getFormLine('#'))) . '", i, line, div, bg, label; var lineCounter = 9; Ext.get("createNewFormFields").on("click", function() { div = Ext.get("formFieldContainer"); for (i = 0; i < 5; i++) { label = lineCounter + i + 1; bg = label % 2 === 0 ? 6 : 4; line = String.format(tpl, (lineCounter + i), label, bg); div.insertHtml("beforeEnd", line); } lineCounter += 5; }); '; /** @var t3lib_pageRenderer * */ $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer(); $pageRenderer->loadExtJS(); $pageRenderer->addExtOnReadyCode($extCode); $pageRenderer->addCssInlineBlock('TYPO3\\CMS\\WizardCrpages\\Controller\\CreatePagesWizardModuleFunctionController', ' #formFieldContainer {float: left; margin: 0 0 10px 0;} .clearLeft {clear: left;} #formFieldContainer label {width: 70px; display: inline-block;} #formFieldContainer input {margin:4px 2px; padding:1px; vertical-align:middle} #formFieldContainer span {padding: 0 3px;} '); } } else { $theCode .= $GLOBALS['TBE_TEMPLATE']->rfw($LANG->getLL('wiz_newPages_errorMsg1')); } // CSH $theCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('_MOD_web_func', 'tx_wizardcrpages', $GLOBALS['BACK_PATH'], '<br />|'); $out = $this->pObj->doc->header($LANG->getLL('wiz_crMany')); $out .= $this->pObj->doc->section('', $theCode, 0, 1); return $out; }
/** * Main function, starting the rendering of the list. * * @return void * @todo Define visibility */ public function main() { // Start document template object: $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('EXT:recordlist/Resources/Private/Templates/db_list.html'); // Loading current page record and checking access: $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); $access = is_array($this->pageinfo) ? 1 : 0; // Apply predefined values for hidden checkboxes // Set predefined value for DisplayBigControlPanel: if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'activated') { $this->MOD_SETTINGS['bigControlPanel'] = TRUE; } elseif ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'deactivated') { $this->MOD_SETTINGS['bigControlPanel'] = FALSE; } // Set predefined value for Clipboard: if ($this->modTSconfig['properties']['enableClipBoard'] === 'activated') { $this->MOD_SETTINGS['clipBoard'] = TRUE; } elseif ($this->modTSconfig['properties']['enableClipBoard'] === 'deactivated') { $this->MOD_SETTINGS['clipBoard'] = FALSE; } // Set predefined value for LocalizationView: if ($this->modTSconfig['properties']['enableLocalizationView'] === 'activated') { $this->MOD_SETTINGS['localization'] = TRUE; } elseif ($this->modTSconfig['properties']['enableLocalizationView'] === 'deactivated') { $this->MOD_SETTINGS['localization'] = FALSE; } // Initialize the dblist object: /** @var $dblist \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList */ $dblist = GeneralUtility::makeInstance('TYPO3\\CMS\\Recordlist\\RecordList\\DatabaseRecordList'); $dblist->backPath = $GLOBALS['BACK_PATH']; $dblist->script = BackendUtility::getModuleUrl('web_list', array(), ''); $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo); $dblist->thumbs = $GLOBALS['BE_USER']->uc['thumbnailsByDefault']; $dblist->returnUrl = $this->returnUrl; $dblist->allFields = $this->MOD_SETTINGS['bigControlPanel'] || $this->table ? 1 : 0; $dblist->localizationView = $this->MOD_SETTINGS['localization']; $dblist->showClipboard = 1; $dblist->disableSingleTableView = $this->modTSconfig['properties']['disableSingleTableView']; $dblist->listOnlyInSingleTableMode = $this->modTSconfig['properties']['listOnlyInSingleTableView']; $dblist->hideTables = $this->modTSconfig['properties']['hideTables']; $dblist->hideTranslations = $this->modTSconfig['properties']['hideTranslations']; $dblist->tableTSconfigOverTCA = $this->modTSconfig['properties']['table.']; $dblist->alternateBgColors = $this->modTSconfig['properties']['alternateBgColors'] ? 1 : 0; $dblist->allowedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], TRUE); $dblist->deniedNewTables = GeneralUtility::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], TRUE); $dblist->newWizards = $this->modTSconfig['properties']['newWizards'] ? 1 : 0; $dblist->pageRow = $this->pageinfo; $dblist->counter++; $dblist->MOD_MENU = array('bigControlPanel' => '', 'clipBoard' => '', 'localization' => ''); $dblist->modTSconfig = $this->modTSconfig; $clickTitleMode = trim($this->modTSconfig['properties']['clickTitleMode']); $dblist->clickTitleMode = $clickTitleMode === '' ? 'edit' : $clickTitleMode; // Clipboard is initialized: // Start clipboard $dblist->clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard'); // Initialize - reads the clipboard content from the user session $dblist->clipObj->initializeClipboard(); // Clipboard actions are handled: // CB is the clipboard command array $CB = GeneralUtility::_GET('CB'); if ($this->cmd == 'setCB') { // CBH is all the fields selected for the clipboard, CBC is the checkbox fields which were checked. // By merging we get a full array of checked/unchecked elements // This is set to the 'el' array of the CB after being parsed so only the table in question is registered. $CB['el'] = $dblist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array) GeneralUtility::_POST('CBC')), $this->cmd_table); } if (!$this->MOD_SETTINGS['clipBoard']) { // If the clipboard is NOT shown, set the pad to 'normal'. $CB['setP'] = 'normal'; } // Execute commands. $dblist->clipObj->setCmd($CB); // Clean up pad $dblist->clipObj->cleanCurrent(); // Save the clipboard content $dblist->clipObj->endClipboard(); // This flag will prevent the clipboard panel in being shown. // It is set, if the clickmenu-layer is active AND the extended view is not enabled. $dblist->dontShowClipControlPanels = !$this->MOD_SETTINGS['bigControlPanel'] && $dblist->clipObj->current == 'normal' && !$this->modTSconfig['properties']['showClipControlPanelsDespiteOfCMlayers']; // If there is access to the page or root page is used for searching, then render the list contents and set up the document template object: if ($access || $this->id === 0 && $this->search_levels > 0 && strlen($this->search_field) > 0) { // Deleting records...: // Has not to do with the clipboard but is simply the delete action. The clipboard object is used to clean up the submitted entries to only the selected table. if ($this->cmd == 'delete') { $items = $dblist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), $this->cmd_table, 1); if (count($items)) { $cmd = array(); foreach ($items as $iK => $value) { $iKParts = explode('|', $iK); $cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1; } $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; $tce->start(array(), $cmd); $tce->process_cmdmap(); if (isset($cmd['pages'])) { BackendUtility::setUpdateSignal('updatePageTree'); } $tce->printLogErrorMessages(GeneralUtility::getIndpEnv('REQUEST_URI')); } } // Initialize the listing object, dblist, for rendering the list: $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000); $dblist->start($this->id, $this->table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit); $dblist->setDispFields(); // Render versioning selector: if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('version')) { $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id); } // Render the list of tables: $dblist->generateList(); $listUrl = substr($dblist->listURL(), strlen($GLOBALS['BACK_PATH'])); // Add JavaScript functions to the page: $this->doc->JScode = $this->doc->wrapScriptTags(' function jumpExt(URL,anchor) { // var anc = anchor?anchor:""; window.location.href = URL+(T3_THIS_LOCATION?"&returnUrl="+T3_THIS_LOCATION:"")+anc; return false; } function jumpSelf(URL) { // window.location.href = URL+(T3_RETURN_URL?"&returnUrl="+T3_RETURN_URL:""); return false; } function setHighlight(id) { // top.fsMod.recentIds["web"]=id; top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_"+top.fsMod.currentBank; // For highlighting if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { top.content.nav_frame.refresh_nav(); } } ' . $this->doc->redirectUrls($listUrl) . ' ' . $dblist->CBfunctions() . ' function editRecords(table,idList,addParams,CBflag) { // window.location.href="' . $GLOBALS['BACK_PATH'] . 'alt_doc.php?returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '&edit["+table+"]["+idList+"]=edit"+addParams; } function editList(table,idList) { // var list=""; // Checking how many is checked, how many is not var pointer=0; var pos = idList.indexOf(","); while (pos!=-1) { if (cbValue(table+"|"+idList.substr(pointer,pos-pointer))) { list+=idList.substr(pointer,pos-pointer)+","; } pointer=pos+1; pos = idList.indexOf(",",pointer); } if (cbValue(table+"|"+idList.substr(pointer))) { list+=idList.substr(pointer)+","; } return list ? list : idList; } if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . '; '); // Setting up the context sensitive menu: $this->doc->getContextMenuCode(); } // access // Begin to compile the whole page, starting out with page header: $this->body = $this->doc->header($this->pageinfo['title']); $this->body .= '<form action="' . htmlspecialchars($dblist->listURL()) . '" method="post" name="dblistForm">'; $this->body .= $dblist->HTMLcode; $this->body .= '<input type="hidden" name="cmd_table" /><input type="hidden" name="cmd" /></form>'; // If a listing was produced, create the page footer with search form etc: if ($dblist->HTMLcode) { // Making field select box (when extended view for a single table is enabled): if ($dblist->table) { $this->body .= $dblist->fieldSelectBox($dblist->table); } // Adding checkbox options for extended listing and clipboard display: $this->body .= ' <!-- Listing options for extended view, clipboard and localization view --> <div id="typo3-listOptions"> <form action="" method="post">'; // Add "display bigControlPanel" checkbox: if ($this->modTSconfig['properties']['enableDisplayBigControlPanel'] === 'selectable') { $this->body .= BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLargeControl"'); $this->body .= '<label for="checkLargeControl">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('largeControl', TRUE)) . '</label><br />'; } // Add "clipboard" checkbox: if ($this->modTSconfig['properties']['enableClipBoard'] === 'selectable') { if ($dblist->showClipboard) { $this->body .= BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', $this->table ? '&table=' . $this->table : '', 'id="checkShowClipBoard"'); $this->body .= '<label for="checkShowClipBoard">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('showClipBoard', TRUE)) . '</label><br />'; } } // Add "localization view" checkbox: if ($this->modTSconfig['properties']['enableLocalizationView'] === 'selectable') { $this->body .= BackendUtility::getFuncCheck($this->id, 'SET[localization]', $this->MOD_SETTINGS['localization'], '', $this->table ? '&table=' . $this->table : '', 'id="checkLocalization"'); $this->body .= '<label for="checkLocalization">' . BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_options', $GLOBALS['LANG']->getLL('localization', TRUE)) . '</label><br />'; } $this->body .= ' </form> </div>'; } // Printing clipboard if enabled if ($this->MOD_SETTINGS['clipBoard'] && $dblist->showClipboard && ($dblist->HTMLcode || $dblist->clipObj->hasElements())) { $this->body .= '<div class="db_list-dashboard">' . $dblist->clipObj->printClipboard() . '</div>'; } // Search box: if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || $dblist->searchString !== '')) { $sectionTitle = BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.search', TRUE)); $this->body .= '<div class="db_list-searchbox">' . $this->doc->section($sectionTitle, $dblist->getSearchBox(), FALSE, TRUE, FALSE, TRUE) . '</div>'; } // Additional footer content $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['recordlist/mod1/index.php']['drawFooterHook']; if (is_array($footerContentHook)) { foreach ($footerContentHook as $hook) { $params = array(); $this->body .= GeneralUtility::callUserFunction($hook, $params, $this); } } // Setting up the buttons and markers for docheader $docHeaderButtons = $dblist->getButtons(); $markers = array('CSH' => $docHeaderButtons['csh'], 'CONTENT' => $this->body, 'EXTRACONTAINERCLASS' => $this->table ? 'singletable' : ''); // Build the <body> for the module $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); // Renders the module page $this->content = $this->doc->render('DB list', $this->content); }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj */ public function main() { $lang = $this->getLanguageService(); $lang->includeLLFile('EXT:wizard_sortpages/locallang.xlf'); $out = $this->pObj->doc->header($lang->getLL('wiz_sort')); if ($this->getBackendUser()->workspace === 0) { $theCode = ''; // Check if user has modify permissions to $sys_pages = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class); $sortByField = GeneralUtility::_GP('sortByField'); if ($sortByField) { $menuItems = array(); if (GeneralUtility::inList('title,subtitle,crdate,tstamp', $sortByField)) { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', $sortByField, '', FALSE); } elseif ($sortByField === 'REV') { $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', 'sorting', '', FALSE); $menuItems = array_reverse($menuItems); } if (!empty($menuItems)) { $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class); $tce->stripslashes_values = 0; $menuItems = array_reverse($menuItems); $cmd = array(); foreach ($menuItems as $r) { $cmd['pages'][$r['uid']]['move'] = $this->pObj->id; } $tce->start(array(), $cmd); $tce->process_cmdmap(); BackendUtility::setUpdateSignal('updatePageTree'); } } $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', FALSE); if (!empty($menuItems)) { $lines = array(); $lines[] = '<thead><tr>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_title') . '</th>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_subtitle') . '</th>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_tChange') . '</th>'; $lines[] = '<th>' . $lang->getLL('wiz_changeOrder_tCreate') . '</th>'; $lines[] = '</tr></thead>'; foreach ($menuItems as $rec) { $m_perms_clause = $this->getBackendUser()->getPagePermsClause(2); // edit permissions for that page! $pRec = BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause); $lines[] = '<tr><td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec) . (!is_array($pRec) ? '<strong class="text-danger">' . $lang->getLL('wiz_W', TRUE) . '</strong></span> ' : '') . htmlspecialchars(GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</td> <td nowrap="nowrap">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($rec['subtitle'], $this->getBackendUser()->uc['titleLen'])) . '</td> <td nowrap="nowrap">' . BackendUtility::datetime($rec['tstamp']) . '</td> <td nowrap="nowrap">' . BackendUtility::datetime($rec['crdate']) . '</td> </tr>'; } $theCode .= '<h2>' . $lang->getLL('wiz_currentPageOrder', TRUE) . '</h2>'; $theCode .= '<div class="table-fit"><table class="table table-striped table-hover">' . implode('', $lines) . '</table></div>'; // Menu: $lines = array(); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_title'), 'title'); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_subtitle'), 'subtitle'); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_tChange'), 'tstamp'); $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_tCreate'), 'crdate'); $lines[] = ''; $lines[] = $this->wiz_linkOrder($lang->getLL('wiz_changeOrder_REVERSE'), 'REV'); $theCode .= '<h4>' . $lang->getLL('wiz_changeOrder') . '</h4><p>' . implode(' ', $lines) . '</p>'; } else { $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $lang->getLL('no_subpages'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); $theCode .= $flashMessage->render(); } // CSH: $theCode .= BackendUtility::cshItem('_MOD_web_func', 'tx_wizardsortpages', NULL, '<br />|'); $out .= $this->pObj->doc->section('', $theCode, FALSE, TRUE); } else { $out .= $this->pObj->doc->section('', 'Sorry, this function is not available in the current draft workspace!', FALSE, TRUE, 1); } return $out; }
/** * Trigger updateFolderTree after a sys_file_collection record is deleted * * @param string $command * @param string $table * @param int $id * @param mixed $value * @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler * @param mixed $pasteUpdate * @param array $pasteDatamap */ public function processCmdmap_postProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler, $pasteUpdate, array $pasteDatamap) { if ($table === 'tx_falsecuredownload_folder') { \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updateFolderTree'); } }
/** * When all operations in the database where made from TYPO3 side, we have to * make some special entries for the shop. Because we don't use the built in * routines to save relations between tables, we have to do this on our own. We * make it manually because we save some additonal information in the relation * tables like values, correlation types and such stuff. * The hole save stuff is done by the "saveAllCorrelations" method. * After the relations are stored in the database, we have to call the dynaflex * extension to modify the TCA that it fit's the current situation of saved * database entries. We call it here because the TCA is allready built and so * the calls in the tca.php of commerce won't be executed between now and the * point where the backendform is rendered. * * @param string $status Status * @param string $table Table * @param int $id Id * @param array $fieldArray Field array * @param DataHandler $pObj Parent object * * @return void */ public function processDatamap_afterDatabaseOperations($status, $table, $id, array $fieldArray, DataHandler $pObj) { // get the UID of the created record if it was just created if ($status == 'new' && count($fieldArray)) { $this->unsubstitutedId = $id; $id = $pObj->substNEWwithIDs[$id]; } switch ($table) { case 'tx_commerce_categories': $this->afterDatabaseCategory($fieldArray, $id); break; case 'tx_commerce_products': $this->afterDatabaseProduct($status, $table, $id, $fieldArray, $pObj); break; case 'tx_commerce_article_prices': $this->afterDatabasePrice($fieldArray, $id); break; default: } if (TYPO3_MODE == 'BE') { BackendUtility::setUpdateSignal('updateFolderTree'); } $this->afterDatabaseHandleDynaflex($table, $id); }
/** * Generate the main settings formular: * * @return void * @todo Define visibility */ public function main() { global $LANG; if ($this->languageUpdate) { $this->doc->JScodeArray['languageUpdate'] .= ' if (top.refreshMenu) { top.refreshMenu(); } else { top.TYPO3ModuleMenu.refreshMenu(); } '; } if ($this->pagetreeNeedsRefresh) { \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree'); } // Start page: $this->doc->loadJavascriptLib('md5.js'); // Use a wrapper div $this->content .= '<div id="user-setup-wrapper">'; // Load available backend modules $this->loadModules = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader'); $this->loadModules->observeWorkspaces = TRUE; $this->loadModules->load($GLOBALS['TBE_MODULES']); $this->content .= $this->doc->header($LANG->getLL('UserSettings')); // Show if setup was saved if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('setupWasUpdated'), $LANG->getLL('UserSettings')); $this->content .= $flashMessage->render(); } // Show if temporary data was cleared if ($this->tempDataIsCleared) { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('tempDataClearedFlashMessage'), $LANG->getLL('tempDataCleared')); $this->content .= $flashMessage->render(); } // Show if temporary data was cleared if ($this->settingsAreResetToDefault) { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('settingsAreReset'), $LANG->getLL('resetConfiguration')); $this->content .= $flashMessage->render(); } // Notice if ($this->setupIsUpdated || $this->settingsAreResetToDefault) { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('activateChanges'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO); $this->content .= $flashMessage->render(); } // If password is updated, output whether it failed or was OK. if ($this->passwordIsSubmitted) { if ($this->passwordIsUpdated) { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('newPassword_ok'), $LANG->getLL('newPassword')); } else { $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $LANG->getLL('newPassword_failed'), $LANG->getLL('newPassword'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } $this->content .= $flashMessage->render(); } // Render the menu items $menuItems = $this->renderUserSetup(); $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', FALSE, FALSE, 1, FALSE, 1, $this->dividers2tabs); $formToken = $this->formProtection->generateToken('BE user setup', 'edit'); $this->content .= $this->doc->section('', '<input type="hidden" name="simUser" value="' . $this->simUser . '" /> <input type="hidden" name="formToken" value="' . $formToken . '" /> <input type="hidden" value="1" name="data[save]" /> <input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" /> <input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />'); // End of wrapper div $this->content .= '</div>'; // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers['CSH'] = $docHeaderButtons['csh']; $markers['CONTENT'] = $this->content; // Build the <body> for the module $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); // Renders the module page $this->content = $this->doc->render($LANG->getLL('UserSettings'), $this->content); }
/** * Main function creating the content for the module. * * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj */ public function main() { $GLOBALS['LANG']->includeLLFile('EXT:wizard_crpages/locallang.xlf'); $theCode = ''; $this->tsConfig = BackendUtility::getPagesTSconfig($this->pObj->id); $this->pagesTsConfig = isset($this->tsConfig['TCEFORM.']['pages.']) ? $this->tsConfig['TCEFORM.']['pages.'] : array(); // Create loremIpsum code: if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('lorem_ipsum')) { $this->loremIpsumObject = GeneralUtility::getUserObj('EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz'); } // Create new pages here? $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(8); $pRec = BackendUtility::getRecord('pages', $this->pObj->id, 'uid', ' AND ' . $m_perms_clause); $sys_pages = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', FALSE); if (is_array($pRec)) { $data = GeneralUtility::_GP('data'); if (is_array($data['pages'])) { if (GeneralUtility::_GP('createInListEnd')) { $endI = end($menuItems); $thePid = -(int) $endI['uid']; if (!$thePid) { $thePid = $this->pObj->id; } } else { $thePid = $this->pObj->id; } $firstRecord = TRUE; $previousIdentifier = ''; foreach ($data['pages'] as $identifier => $dat) { if (!trim($dat['title'])) { unset($data['pages'][$identifier]); } else { $data['pages'][$identifier]['hidden'] = GeneralUtility::_GP('hidePages') ? 1 : 0; $data['pages'][$identifier]['nav_hide'] = GeneralUtility::_GP('hidePagesInMenus') ? 1 : 0; if ($firstRecord) { $firstRecord = FALSE; $data['pages'][$identifier]['pid'] = $thePid; } else { $data['pages'][$identifier]['pid'] = '-' . $previousIdentifier; } $previousIdentifier = $identifier; } } if (!empty($data['pages'])) { reset($data); $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; // set default TCA values specific for the user $TCAdefaultOverride = $GLOBALS['BE_USER']->getTSConfigProp('TCAdefaults'); if (is_array($TCAdefaultOverride)) { $tce->setDefaultsFromUserTS($TCAdefaultOverride); } $tce->start($data, array()); $tce->process_datamap(); BackendUtility::setUpdateSignal('updatePageTree'); $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_create')); } else { $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_noCreate'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } $theCode .= $flashMessage->render(); // Display result: $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0); $lines = array(); foreach ($menuItems as $rec) { BackendUtility::workspaceOL('pages', $rec); if (is_array($rec)) { $lines[] = '<nobr>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec, array('title' => BackendUtility::titleAttribForPages($rec, '', FALSE))) . htmlspecialchars(GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</nobr>'; } } $theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_newPages_currentMenu') . '</h4>' . implode('<br />', $lines); } else { // Display create form $lines = array(); $tableData = array(); for ($a = 0; $a < 9; $a++) { $tableData[] = $this->getFormLine($a); } $lines[] = '<table id="formFieldContainer" class="t3-table"><tbody id="formFieldContainerBody">' . implode(LF, $tableData) . '</tbody></table>'; $theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_newPages') . ':</h4>' . implode('', $lines) . '<br class="clearLeft" />' . '<input type="button" id="createNewFormFields" value="' . $GLOBALS['LANG']->getLL('wiz_newPages_addMoreLines') . '" />' . '<br /><br />'; $theCode .= '<div class="checkbox"><label for="createInListEnd"><input type="checkbox" name="createInListEnd" id="createInListEnd" value="1" />' . $GLOBALS['LANG']->getLL('wiz_newPages_listEnd') . '</label></div>'; $theCode .= '<div class="checkbox"><label for="hidePages"><input type="checkbox" name="hidePages" id="hidePages" value="1" />' . $GLOBALS['LANG']->getLL('wiz_newPages_hidePages') . '</label></div>'; $theCode .= '<div class="checkbox"><label for="hidePagesInMenus"><input type="checkbox" name="hidePagesInMenus" id="hidePagesInMenus" value="1" />' . $GLOBALS['LANG']->getLL('wiz_newPages_hidePagesInMenus') . '</label></div>'; $theCode .= '<input type="submit" name="create" value="' . $GLOBALS['LANG']->getLL('wiz_newPages_lCreate') . '" /> <input type="reset" value="' . $GLOBALS['LANG']->getLL('wiz_newPages_lReset') . '" /><br />'; /** @var \TYPO3\CMS\Core\Page\PageRenderer */ $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer(); $pageRenderer->loadJquery(); $pageRenderer->loadRequireJsModule('TYPO3/CMS/WizardCrpages/WizardCreatePages'); // Add inline code $inlineJavaScriptCode = 'var tpl = "' . addslashes(str_replace(array(LF, TAB), array('', ''), $this->getFormLine('#'))) . '", i, line, div, bg, label;'; $pageRenderer->addJsInlineCode('wizard_crpages', $inlineJavaScriptCode); $pageRenderer->addCssInlineBlock('TYPO3\\CMS\\WizardCrpages\\Controller\\CreatePagesWizardModuleFunctionController', ' #formFieldContainer {float: left; margin: 0 0 10px 0;} .clearLeft {clear: left;} #formFieldContainer label {width: 70px; display: inline-block;} #formFieldContainer span {padding: 0 3px;} '); } } else { $theCode .= GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', $GLOBALS['LANG']->getLL('wiz_newPages_errorMsg1'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR)->render(); } // CSH $theCode .= BackendUtility::cshItem('_MOD_web_func', 'tx_wizardcrpages', $GLOBALS['BACK_PATH'], '<br />|'); $out = $this->pObj->doc->header($GLOBALS['LANG']->getLL('wiz_crMany')); $out .= $this->pObj->doc->section('', $theCode, FALSE, TRUE); return $out; }
/** * 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); }
/** * Injects the request object for the current request or subrequest * As this controller goes only through the main() method, it just redirects to the given URL afterwards. * * @param ServerRequestInterface $request the current request * @param ResponseInterface $response * @return ResponseInterface the response with the content */ public function mainAction(ServerRequestInterface $request, ResponseInterface $response) { $this->main(); BackendUtility::setUpdateSignal('updateFolderTree'); // go and edit the new created file if ($request->getParsedBody()['edit']) { $urlParameters = ['target' => $this->file['newfile'][0]['target'] . $this->file['newfile'][0]['data']]; if ($this->redirect) { $urlParameters['returnUrl'] = $this->redirect; } $this->redirect = BackendUtility::getModuleUrl('file_edit', $urlParameters); } if ($this->redirect) { return $response->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect))->withStatus(303); } else { // empty response return $response; } }