/** * Builds a complete node including children * * @param \TYPO3\CMS\Backend\Tree\TreeNode|\TYPO3\CMS\Backend\Tree\TreeNode $basicNode * @param NULL|\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent * @param integer $level * @param bool $restriction * @return \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode node */ protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode, \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode $parent = null, $level = 0, $restriction = false) { $iconFactory = GeneralUtility::makeInstance(IconFactory::class); /**@param $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */ $node = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode::class); $row = array(); if ($basicNode->getId() == 0) { $node->setSelected(false); $node->setExpanded(true); $node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title'])); } else { $row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', false); if ($this->getLabelField() !== '') { $label = CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row); $node->setLabel($label); } else { $node->setLabel($basicNode->getId()); } $node->setSelected(GeneralUtility::inList($this->getSelectedList(), $basicNode->getId())); $node->setExpanded($this->isExpanded($basicNode)); $node->setLabel($node->getLabel()); } $node->setId($basicNode->getId()); // Break to force single category activation if ($parent != null && $level != 0 && $this->isSingleCategoryAclActivated() && !$this->isCategoryAllowed($node)) { return null; } $node->setSelectable(!GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList())); $node->setSortValue($this->nodeSortValues[$basicNode->getId()]); $node->setIcon($iconFactory->getIconForRecord($this->tableName, $row, Icon::SIZE_SMALL)->render()); $node->setParentNode($parent); if ($basicNode->hasChildNodes()) { $node->setHasChildren(true); /** @var \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection $childNodes */ $childNodes = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection::class); $foundSomeChild = false; foreach ($basicNode->getChildNodes() as $child) { // Change in custom TreeDataProvider by adding the if clause if ($restriction || $this->isCategoryAllowed($child)) { $returnedChild = $this->buildRepresentationForNode($child, $node, $level + 1, true); if (!is_null($returnedChild)) { $foundSomeChild = true; $childNodes->append($returnedChild); } else { $node->setParentNode(null); $node->setHasChildren(false); } } // Change in custom TreeDataProvider end } if ($foundSomeChild) { $node->setChildNodes($childNodes); } } return $node; }
/** * Generate additional label for category records * including the title of the parent category * * @param array $params * @return void */ public function getUserLabelCategory(array &$params) { // In list view: show normal label $listView = strpos(GeneralUtility::getIndpEnv('REQUEST_URI'), 'typo3/sysext/list/mod1/db_list.php') || strpos(GeneralUtility::getIndpEnv('REQUEST_URI'), 'typo3/mod.php?&M=web_list') || strpos(GeneralUtility::getIndpEnv('REQUEST_URI'), 'typo3/mod.php?M=web_list'); // No overlay if language of category is not base or no language yet selected if ($listView || !is_array($params['row'])) { $params['title'] = $params['row']['title']; } else { $params['title'] = CategoryService::translateCategoryRecord($params['row']['title'], $params['row']); } }
/** * Generate additional label for category records * including the title of the parent category * * @param array $params * @return void */ public function getUserLabelCategory(array &$params) { $showTranslationInformation = false; $getVars = GeneralUtility::_GET(); if (isset($getVars['route']) && $getVars['route'] === '/record/edit' && isset($getVars['edit']) && is_array($getVars['edit']) && (isset($getVars['edit']['tt_content']) || isset($getVars['edit']['tx_news_domain_model_news']) || isset($getVars['edit']['sys_category']))) { $showTranslationInformation = true; } if ($showTranslationInformation && is_array($params['row'])) { $params['title'] = CategoryService::translateCategoryRecord($params['row']['title'], $params['row']); } else { $params['title'] = $params['row']['title']; } }