2 namespace TYPO3\CMS\Core\Tree\TableConfiguration;
185 public function getNodes(\TYPO3\CMS\Backend\Tree\TreeNode $node)
196 return $this->buildRepresentationForNode($this->treeData);
249 protected function buildRepresentationForNode(\TYPO3\CMS\Backend\Tree\TreeNode $basicNode,
DatabaseTreeNode $parent = null, $level = 0)
254 if ($basicNode->getId() == 0) {
255 $node->setSelected(
false);
256 $node->setExpanded(
true);
257 $node->setLabel(
$GLOBALS[
'LANG']->sL(
$GLOBALS[
'TCA'][$this->tableName][
'ctrl'][
'title']));
262 $node->setExpanded($this->
isExpanded($basicNode));
264 $node->setId($basicNode->getId());
266 $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
268 $node->setIcon($iconFactory->getIconForRecord($this->tableName, $row,
Icon::SIZE_SMALL));
269 $node->setParentNode($parent);
270 if ($basicNode->hasChildNodes()) {
271 $node->setHasChildren(
true);
274 foreach ($basicNode->getChildNodes() as $child) {
275 $childNodes->append($this->buildRepresentationForNode($child, $node, $level + 1));
277 $node->setChildNodes($childNodes);
289 parent::initializeTreeData();
290 $this->nodeSortValues = array_flip($this->itemWhiteList);
292 if (isset($this->columnConfiguration[
'foreign_table']) && $this->columnConfiguration[
'foreign_table'] != $this->
getTableName()) {
293 throw new \InvalidArgumentException(
'TCA Tree configuration is invalid: tree for different node-Tables is not implemented yet', 1290944650);
308 $this->treeData->setParentNode(null);
309 if ($this->levelMaximum >= 1) {
310 $childNodes = $this->getChildrenOf($this->treeData, 1);
311 if ($childNodes !== null) {
312 $this->treeData->setChildNodes($childNodes);
324 protected function getChildrenOf(\TYPO3\CMS\Backend\Tree\TreeNode $node, $level)
327 if ($node->getId() !== 0) {
328 $nodeData =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'*', $this->tableName,
'uid=' . $node->getId());
330 if ($nodeData == null) {
338 if (!empty($children)) {
341 foreach ($children as $child) {
343 $node->setId($child);
344 if ($level < $this->levelMaximum) {
345 $children = $this->getChildrenOf($node, $level + 1);
346 if ($children !== null) {
347 $node->setChildNodes($children);
350 $storage->append($node);
365 $children = $this->getChildrenUidsFromParentRelation($row);
367 $children = $this->getChildrenUidsFromChildrenRelation($row);
369 $allowedArray = array();
370 foreach ($children as $child) {
371 if (!in_array($child, $this->idCache) && in_array($child, $this->itemWhiteList)) {
372 $allowedArray[] = $child;
375 $this->idCache = array_merge($this->idCache, $allowedArray);
376 return $allowedArray;
385 protected function getChildrenUidsFromParentRelation(array $row)
388 switch ((
string)$this->columnConfiguration[
'type']) {
392 if ($this->columnConfiguration[
'MM']) {
396 $this->columnConfiguration[
'MM_oppositeField'] =
'children';
398 $relatedUids = $dbGroup->tableArray[$this->
getTableName()];
399 }
elseif ($this->columnConfiguration[
'foreign_field']) {
400 $relatedUids = $this->
listFieldQuery($this->columnConfiguration[
'foreign_field'], $uid);
417 protected function getChildrenUidsFromChildrenRelation(array $row)
419 $relatedUids = array();
422 switch ((
string)$this->columnConfiguration[
'type']) {
426 if ($this->columnConfiguration[
'MM']) {
429 $dbGroup->start($value, $this->
getTableName(), $this->columnConfiguration[
'MM'], $uid, $this->
getTableName(), $this->columnConfiguration);
430 $relatedUids = $dbGroup->tableArray[$this->
getTableName()];
431 }
elseif ($this->columnConfiguration[
'foreign_field']) {
432 $records =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid', $this->
getTableName(), $this->columnConfiguration[
'foreign_field'] .
'=' . (
int)$uid);
433 foreach ($records as $record) {
434 $relatedUids[] = $record[
'uid'];
455 $records =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid', $this->
getTableName(),
$GLOBALS[
'TYPO3_DB']->listQuery($fieldName, (
int)$queryId, $this->
getTableName()) . ((
int)$queryId === 0 ?
' OR CAST(' . $fieldName .
' AS CHAR) = \'\'' :
''));
457 foreach ($records as $record) {
458 $uidArray[] = $record[
'uid'];
470 $this->
getSignalSlotDispatcher()->dispatch(\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::class,
471 self::SIGNAL_PostProcessTreeData,
472 array($this, $this->treeData)
487 'TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\TableConfiguration\\DatabaseTreeDataProvider',
488 self::SIGNAL_PostProcessTreeData
490 if (!empty($deprecatedSlots)) {
491 foreach ($deprecatedSlots as $slotInformation) {
492 $slotClassNameOrObject = $slotInformation[
'object'] ? get_class($slotInformation[
'object']) : $slotInformation[
'class'];
494 'Signal "TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\TableConfiguration\\DatabaseTreeDataProvider" ' .
495 'is deprecated but used by "' . $slotClassNameOrObject .
'". ' .
496 'Please update signal name to "' . __CLASS__ .
'".'
500 'TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\TableConfiguration\\DatabaseTreeDataProvider',
501 self::SIGNAL_PostProcessTreeData,
502 array($this, $this->treeData)
514 if (!isset($this->signalSlotDispatcher)) {
515 $this->signalSlotDispatcher = $this->
getObjectManager()->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);