17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
58 'textExtensions' =>
'Using TypoScriptTemplateModuleController::$textExtensions is deprecated and will not be possible anymore in TYPO3 v10.0.',
59 'pageinfo' =>
'Using TypoScriptTemplateModuleController::$pageinfo is deprecated and will not be possible anymore in TYPO3 v10.0.',
60 'id' =>
'Using TypoScriptTemplateModuleController::$id is deprecated and will not be possible anymore in TYPO3 v10.0.',
61 'modTSconfig' =>
'Using TypoScriptTemplateModuleController::$modTSconfig is deprecated and will not be possible anymore in TYPO3 v10.0.',
62 'content' =>
'Using TypoScriptTemplateModuleController::$content is deprecated and will not be possible anymore in TYPO3 v10.0.',
63 'extObj' =>
'Using TypoScriptTemplateModuleController::$extObj is deprecated and will not be possible anymore in TYPO3 v10.0.',
64 'access' =>
'Using TypoScriptTemplateModuleController::$access is deprecated and will not be possible anymore in TYPO3 v10.0.',
65 'perms_clause' =>
'Using TypoScriptTemplateModuleController::$perms_clause is deprecated and will not be possible anymore in TYPO3 v10.0.',
66 'extClassConf' =>
'Using TypoScriptTemplateModuleController::$extClassConf is deprecated and will not be possible anymore in TYPO3 v10.0.',
67 'edit' =>
'Using TypoScriptTemplateModuleController::$edit is deprecated, property will be removed in TYPO3 v10.0.',
68 'modMenu_type' =>
'Using TypoScriptTemplateModuleController::$modMenu_type is deprecated, property will be removed in TYPO3 v10.0.',
69 'MCONF' =>
'Using TypoScriptTemplateModuleController::$MCONF is deprecated, property will be removed in TYPO3 v10.0.',
70 'CMD' =>
'Using TypoScriptTemplateModuleController::$CMD is deprecated, property will be removed in TYPO3 v10.0.',
71 'sObj' =>
'Using TypoScriptTemplateModuleController::$sObj is deprecated, property will be removed in TYPO3 v10.0.',
78 'getExternalItemConfig' =>
'Using TypoScriptTemplateModuleController::getExternalItemConfig() is deprecated and will not be possible anymore in TYPO3 v10.0.',
79 'init' =>
'Using TypoScriptTemplateModuleController::init() is deprecated and will not be possible anymore in TYPO3 v10.0.',
80 'clearCache' =>
'Using TypoScriptTemplateModuleController::clearCache() is deprecated and will not be possible anymore in TYPO3 v10.0.',
81 'main' =>
'Using TypoScriptTemplateModuleController::main() is deprecated and will not be possible anymore in TYPO3 v10.0.',
82 'setInPageArray' =>
'Using TypoScriptTemplateModuleController::setInPageArray() is deprecated and will not be possible anymore in TYPO3 v10.0.',
83 'menuConfig' =>
'Using TypoScriptTemplateModuleController::menuConfig() is deprecated and will not be possible anymore in TYPO3 v10.0.',
84 'mergeExternalItems' =>
'Using TypoScriptTemplateModuleController::mergeExternalItems() is deprecated and will not be possible anymore in TYPO3 v10.0.',
85 'handleExternalFunctionValue' =>
'Using TypoScriptTemplateModuleController::handleExternalFunctionValue() is deprecated and will not be possible anymore in TYPO3 v10.0.',
86 'checkExtObj' =>
'Using TypoScriptTemplateModuleController::checkExtObj() is deprecated and will not be possible anymore in TYPO3 v10.0.',
87 'extObjContent' =>
'Using TypoScriptTemplateModuleController::extObjContent() is deprecated and will not be possible anymore in TYPO3 v10.0.',
88 'getExtObjContent' =>
'Using TypoScriptTemplateModuleController::getExtObjContent() is deprecated and will not be possible anymore in TYPO3 v10.0.',
89 'checkSubExtObj' =>
'Using TypoScriptTemplateModuleController::checkSubExtObj() is deprecated, method will be removed in TYPO3 v10.0.',
90 'extObjHeader' =>
'Using TypoScriptTemplateModuleController::extObjHeader() is deprecated, method will be removed in TYPO3 v10.0.',
235 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
242 $this->moduleTemplate->addJavaScriptCode(
245 function jumpToUrl(URL) {
246 window.location.href = URL;
256 protected function init()
259 $this->CMD = GeneralUtility::_GP(
'CMD');
260 $this->
id = (int)GeneralUtility::_GP(
'id');
264 $this->sObj = GeneralUtility::_GP(
'sObj');
266 $this->edit = GeneralUtility::_GP(
'edit');
275 if (GeneralUtility::_GP(
'clear_all_cache')) {
276 $tce = GeneralUtility::makeInstance(DataHandler::class);
278 $tce->clear_cacheCmd(
'all');
285 protected function main()
290 $this->access = is_array($this->pageinfo);
292 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
293 if ($this->
id && $this->access) {
298 $aHref = (string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters);
301 $this->moduleTemplate->addJavaScriptCode(
302 'TSTemplateInlineJS',
303 'function uFormUrl(aname) {
304 document.forms[0].action = ' . GeneralUtility::quoteJSvalue($aHref .
'#') .
'+aname;
306 function brPoint(lnumber,t) {
307 window.location.href = '
308 . GeneralUtility::quoteJSvalue(
309 $aHref .
'&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\'
310 .
'TypoScriptTemplateObjectBrowserModuleFunctionController&SET[ts_browser_type]='
311 ) .
'+(t?"setup":"const")+"&breakPointLN="+lnumber;
314 if (top.fsMod) top.fsMod.recentIds["web"] = ' . $this->
id .
';'
316 $this->moduleTemplate->getPageRenderer()->addCssInlineBlock(
317 'TSTemplateInlineStyle',
318 'TABLE#typo3-objectBrowser { width: 100%; margin-bottom: 24px; }
319 TABLE#typo3-objectBrowser A { text-decoration: none; }
320 TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
321 .ts-typoscript { width: 100%; }
322 .tsob-search-submit {margin-left: 3px; margin-right: 3px;}
323 .tst-analyzer-options { margin:5px 0; }'
326 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule(
'TYPO3/CMS/Backend/ContextMenu');
328 $view->assign(
'actionName', $aHref);
335 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
336 ->getQueryBuilderForTable(
'sys_template');
337 $queryBuilder->getRestrictions()
339 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
345 $result = $queryBuilder
360 ->from(
'sys_template')
361 ->orderBy(
'sys_template.pid')
362 ->addOrderBy(
'sys_template.sorting')
365 while ($record = $result->fetch()) {
370 $additionalFieldsForRootline = [
'sorting',
'shortcut'];
375 $view->getRenderingContext()->setControllerAction(
'PageZero');
376 $view->assign(
'pageTree', $pArray);
382 $this->content = $view->render();
392 $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
393 $menu->setIdentifier(
'WebFuncJumpMenu');
394 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
395 foreach ($this->MOD_MENU[
'function'] as $controller => $title) {
399 (
string)$uriBuilder->buildUriFromRoute(
404 'function' => $controller
410 if ($controller === $this->MOD_SETTINGS[
'function']) {
411 $item->setActive(
true);
413 $menu->addMenuItem($item);
415 $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
425 public function mainAction(ServerRequestInterface $request): ResponseInterface
438 $this->moduleTemplate->setContent($this->content);
439 return new HtmlResponse($this->moduleTemplate->renderContent());
447 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
450 if ($this->
id && $this->access) {
452 $viewButton = $buttonBar->makeLinkButton()
455 $this->pageinfo[
'uid'],
459 ->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
460 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-view-page',
Icon::SIZE_SMALL));
463 if ($this->extClassConf[
'name'] === TypoScriptTemplateInformationModuleFunctionController::class) {
468 'createExtension' =>
'new'
470 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
471 $newButton = $buttonBar->makeLinkButton()
472 ->setHref((
string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters))
473 ->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:db_new.php.pagetitle'))
474 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
478 $buttonBar->addButton($newButton);
479 } elseif ($this->extClassConf[
'name'] === TypoScriptTemplateConstantEditorModuleFunctionController::class
480 && !empty($this->MOD_MENU[
'constant_editor_cat'])) {
482 $saveButton = $buttonBar->makeInputButton()
483 ->setName(
'_savedok')
485 ->setForm(
'TypoScriptTemplateModuleController')
486 ->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.saveDoc'))
487 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
488 'actions-document-save',
491 ->setShowLabelText(
true);
492 $buttonBar->addButton($saveButton);
493 } elseif ($this->extClassConf[
'name'] === TypoScriptTemplateObjectBrowserModuleFunctionController::class
494 && !empty(GeneralUtility::_GP(
'sObj'))
500 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
501 $backButton = $buttonBar->makeLinkButton()
502 ->setHref((
string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters))
503 ->setClasses(
'typo3-goBack')
504 ->setTitle($lang->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
505 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
506 'actions-view-go-back',
509 $buttonBar->addButton($backButton);
513 $shortcutButton = $buttonBar->makeShortcutButton()
514 ->setModuleName(
'web_ts')
515 ->setGetVariables([
'id',
'route']);
516 $buttonBar->addButton($shortcutButton);
531 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
532 $aHref = (string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters);
534 $title =
'<a href="' . htmlspecialchars($aHref .
'&e[' . $onlyKey .
']=1&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController') .
'">' . htmlspecialchars($title) .
'</a>';
536 $title =
'<a href="' . htmlspecialchars($aHref .
'&e[constants]=1&e[config]=1&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController') .
'">' . htmlspecialchars($title) .
'</a>';
547 public function noTemplate($newStandardTemplate = 0)
549 $this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
554 if ($newStandardTemplate) {
559 if (!empty($hookObject)) {
561 'selectorHtml' => &$selector,
562 'staticsText' => &$staticsText
564 GeneralUtility::callUserFunction(
569 $selector = $reference[
'selectorHtml'];
570 $staticsText = $reference[
'staticsText'];
573 $moduleContent[
'staticsText'] = $staticsText;
574 $moduleContent[
'selector'] = $selector;
577 $previousPage = $this->templateService->ext_prevPageWithTemplate($this->
id, $this->perms_clause);
580 'id' => $previousPage[
'uid']
582 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
583 $previousPage[
'aHref'] = (string)$uriBuilder->buildUriFromRoute(
'web_ts', $urlParameters);
584 $moduleContent[
'previousPage'] = $previousPage;
587 $view->assign(
'content', $moduleContent);
588 return $view->render();
598 $this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
600 $all = $this->templateService->ext_getAllTemplates($this->
id);
601 if (count($all) > 1) {
602 $this->MOD_MENU[
'templatesOnPage'] = [];
603 foreach ($all as $d) {
604 $this->MOD_MENU[
'templatesOnPage'][$d[
'uid']] = $d[
'title'];
609 GeneralUtility::_GP(
'SET'),
612 $this->modMenu_dontValidateList,
613 $this->modMenu_setDefaultList
617 'SET[templatesOnPage]',
618 $this->MOD_SETTINGS[
'templatesOnPage'],
619 $this->MOD_MENU[
'templatesOnPage']
633 $tce = GeneralUtility::makeInstance(DataHandler::class);
635 if (GeneralUtility::_GP(
'createExtension')) {
636 $recData[
'sys_template'][
'NEW'] = [
637 'pid' => $actTemplateId ? -1 * $actTemplateId :
$id,
640 $tce->start($recData, []);
641 $tce->process_datamap();
642 } elseif (GeneralUtility::_GP(
'newWebsite')) {
645 if (!empty($hookObject)) {
647 'recData' => &$recData,
650 GeneralUtility::callUserFunction(
655 $recData = $reference[
'recData'];
657 $recData[
'sys_template'][
'NEW'] = [
664 # Default PAGE object:
667 page.10.value = HELLO WORLD!
671 $tce->start($recData, []);
672 $tce->process_datamap();
673 $tce->clear_cacheCmd(
'all');
675 return $tce->substNEWwithIDs[
'NEW'];
690 if (!$rlArr[0][
'uid']) {
693 $cEl = current($rlArr);
694 if (empty($pArray[$cEl[
'uid']])) {
695 $pArray[$cEl[
'uid']] = $cEl;
698 if (!empty($rlArr)) {
699 if (empty($pArray[$cEl[
'uid']][
'_nodes'])) {
700 $pArray[$cEl[
'uid']][
'_nodes'] = [];
704 $pArray[$cEl[
'uid']][
'_templates'][] = $row;
706 uasort($pArray,
function ($a, $b) {
707 return $a[
'sorting'] - $b[
'sorting'];
720 public function renderList($pArray, $lines = [], $c = 0)
723 'The method `TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateModuleController::renderList` has been deprecated and should not be used any longer, this method will be removed in TYPO3 v10.0',
727 if (!is_array($pArray)) {
731 $statusCheckedIcon = $this->moduleTemplate->getIconFactory()
733 foreach ($pArray as $k => $v) {
737 $line[
'marginLeft'] = $c * 20;
738 $line[
'pageTitle'] = GeneralUtility::fixed_lgd_cs($pArray[$k], 30);
739 $line[
'icon'] = $this->moduleTemplate->getIconFactory()
745 if (!empty($pArray[$key])) {
746 $line[
'href'] = GeneralUtility::linkThisScript([
'id' => (
int)$k]);
747 $line[
'title'] =
'ID: ' . (int)$k;
748 $line[
'count'] = $pArray[$k .
'_'][
'count'];
749 $line[
'root_max_val'] = ($pArray[$key][
'root_max_val'] > 0 ? $statusCheckedIcon :
' ');
750 $line[
'root_min_val'] = ($pArray[$key][
'root_min_val'] === 0 ? $statusCheckedIcon :
' ');
755 $line[
'root_max_val'] =
'';
756 $line[
'root_min_val'] =
'';
759 $lines = $this->
renderList($pArray[$k .
'.'], $lines, $c + 1);
774 $view = GeneralUtility::makeInstance(StandaloneView::class);
775 $view->getRenderingContext()->getTemplatePaths()->fillDefaultsByPackageName($extensionName);
776 $view->getRenderingContext()->setControllerAction($templateName);
777 $view->getRequest()->setControllerExtensionName(
'tstemplate');
787 QueryBuilder $queryBuilder,
791 if (empty(
$GLOBALS[
'TCA'][$tableName][
'ctrl'][
'versioningWS'])) {
796 if ($workspaceId > 0) {
797 $workspaceIds[] = $workspaceId;
799 $queryBuilder->andWhere(
800 $queryBuilder->expr()->in(
802 $queryBuilder->createNamedParameter($workspaceIds, Connection::PARAM_INT_ARRAY)
804 $queryBuilder->expr()->neq(
806 $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)
817 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][self::class][$action])) {
818 return $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][self::class][$action];
834 $this->MOD_MENU[
'function'] = $this->
mergeExternalItems(
'web_ts',
'function', $this->MOD_MENU[
'function']);
835 $blindActions = $this->modTSconfig[
'properties'][
'menu.'][
'function.'] ?? [];
836 foreach ($blindActions as $key => $value) {
837 if (!$value && array_key_exists($key, $this->MOD_MENU[
'function'])) {
838 unset($this->MOD_MENU[
'function'][$key]);
841 $this->MOD_SETTINGS =
BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP(
'SET'),
'web_ts', $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
856 $mergeArray =
$GLOBALS[
'TBE_MODULES_EXT'][$modName][
'MOD_MENU'][$menuKey];
857 if (is_array($mergeArray)) {
858 foreach ($mergeArray as $k => $v) {
859 if (((
string)$v[
'ws'] ===
'' || $this->
getBackendUser()->workspace === 0 && GeneralUtility::inList($v[
'ws'],
'online')) || $this->
getBackendUser()->workspace === -1 && GeneralUtility::inList($v[
'ws'],
'offline') || $this->
getBackendUser()->workspace > 0 && GeneralUtility::inList($v[
'ws'],
'custom')) {
876 if ($MS_value ===
null) {
877 $MS_value = $this->MOD_SETTINGS[$MM_key];
894 if (isset(
$GLOBALS[
'TBE_MODULES_EXT'][$modName])) {
895 return (
string)$value !==
''
896 ?
$GLOBALS[
'TBE_MODULES_EXT'][$modName][
'MOD_MENU'][$menuKey][$value]
897 :
$GLOBALS[
'TBE_MODULES_EXT'][$modName][
'MOD_MENU'][$menuKey];
912 if (is_array($this->extClassConf) && $this->extClassConf[
'name']) {
913 $this->extObj = GeneralUtility::makeInstance($this->extClassConf[
'name']);
914 $this->extObj->init($this);
916 $this->MOD_SETTINGS =
BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP(
'SET'),
'web_ts', $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
927 if (is_object($this->extObj) && is_callable([$this->extObj,
'checkExtObj'])) {
928 $this->extObj->checkExtObj();
941 if (is_callable([$this->extObj,
'head'])) {
942 $this->extObj->head();
951 if ($this->extObj ===
null) {
952 $flashMessage = GeneralUtility::makeInstance(
954 $this->
getLanguageService()->sL(
'LLL:EXT:backend/Resources/Private/Language/locallang.xlf:no_modules_registered'),
958 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
960 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
961 $defaultFlashMessageQueue->enqueue($flashMessage);
963 if (is_callable([$this->extObj,
'main'])) {
964 $this->content .= $this->extObj->main();
980 $this->content = $savedContent;
1007 return GeneralUtility::makeInstance(PageRenderer::class);