/** * 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) { /**@param $node \TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeNode */ $node = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\DatabaseTreeNode'); $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 = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', FALSE); if ($this->getLabelField() !== '') { $label = Tx_News_Service_CategoryService::translateCategoryRecord($row[$this->getLabelField()], $row); $node->setLabel($label); } else { $node->setLabel($basicNode->getId()); } $node->setSelected(\TYPO3\CMS\Core\Utility\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(!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->getNonSelectableLevelList(), $level) && !in_array($basicNode->getId(), $this->getItemUnselectableList())); $node->setSortValue($this->nodeSortValues[$basicNode->getId()]); $node->setIcon(\TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($this->tableName, $row)); $node->setParentNode($parent); if ($basicNode->hasChildNodes()) { $node->setHasChildren(TRUE); /** @var \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection $childNodes */ $childNodes = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\SortedTreeNodeCollection'); $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(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'), 'typo3/sysext/list/mod1/db_list.php') || strpos(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'), 'typo3/mod.php?&M=web_list') || strpos(\TYPO3\CMS\Core\Utility\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'] = Tx_News_Service_CategoryService::translateCategoryRecord($params['row']['title'], $params['row']); } }