186 return $this->buildRepresentationForNode($this->treeData);
235 protected function buildRepresentationForNode(\
TYPO3\CMS\Backend\Tree\TreeNode $basicNode, \
TYPO3\CMS\Core\Tree\TableConfiguration\
DatabaseTreeNode $parent = NULL, $level = 0) {
239 if ($basicNode->getId() == 0) {
240 $node->setSelected(FALSE);
241 $node->setExpanded(TRUE);
242 $node->setLabel(
$GLOBALS[
'LANG']->sL(
$GLOBALS[
'TCA'][$this->tableName][
'ctrl'][
'title']));
247 $node->setExpanded($this->
isExpanded($basicNode));
249 $node->setId($basicNode->getId());
251 $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
252 $node->setIcon(\
TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconClass($this->tableName, $row));
253 $node->setParentNode($parent);
254 if ($basicNode->hasChildNodes()) {
255 $node->setHasChildren(TRUE);
258 foreach ($basicNode->getChildNodes() as $child) {
259 $childNodes->append($this->buildRepresentationForNode($child, $node, $level + 1));
261 $node->setChildNodes($childNodes);
272 parent::initializeTreeData();
273 $this->nodeSortValues = array_flip($this->itemWhiteList);
275 if (isset($this->columnConfiguration[
'foreign_table']) && $this->columnConfiguration[
'foreign_table'] != $this->
getTableName()) {
276 throw new \InvalidArgumentException(
'TCA Tree configuration is invalid: tree for different node-Tables is not implemented yet', 1290944650);
280 $this->treeData->setParentNode(NULL);
281 $childNodes = $this->getChildrenOf($this->treeData, 0);
282 if ($childNodes !== NULL) {
283 $this->treeData->setChildNodes($childNodes);
296 protected function getChildrenOf(\
TYPO3\CMS\Backend\Tree\TreeNode $node, $level) {
298 if ($node->getId() !== 0) {
299 $nodeData =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
'*', $this->tableName,
'uid=' . $node->getId());
301 if ($nodeData == NULL) {
309 if (count($children)) {
312 foreach ($children as $child) {
314 $node->setId($child);
315 if ($level <= $this->levelMaximum) {
316 $children = $this->getChildrenOf($node, $level + 1);
317 if ($children !== NULL) {
318 $node->setChildNodes($children);
321 $storage->append($node);
335 $children = $this->getChildrenUidsFromParentRelation($row);
337 $children = $this->getChildrenUidsFromChildrenRelation($row);
339 $allowedArray = array();
340 foreach ($children as $child) {
341 if (!in_array($child, $this->idCache) && in_array($child, $this->itemWhiteList)) {
342 $allowedArray[] = $child;
345 $this->idCache = array_merge($this->idCache, $allowedArray);
346 return $allowedArray;
355 protected function getChildrenUidsFromParentRelation(array $row) {
357 switch ((
string) $this->columnConfiguration[
'type']) {
361 if ($this->columnConfiguration[
'MM']) {
365 $this->columnConfiguration[
'MM_oppositeField'] =
'children';
367 $relatedUids = $dbGroup->tableArray[$this->
getTableName()];
368 } elseif ($this->columnConfiguration[
'foreign_field']) {
369 $relatedUids = $this->
listFieldQuery($this->columnConfiguration[
'foreign_field'],
$uid);
386 protected function getChildrenUidsFromChildrenRelation(array $row) {
387 $relatedUids = array();
390 switch ((
string) $this->columnConfiguration[
'type']) {
394 if ($this->columnConfiguration[
'MM']) {
397 $dbGroup->start($value, $this->
getTableName(), $this->columnConfiguration[
'MM'],
$uid, $this->
getTableName(), $this->columnConfiguration);
398 $relatedUids = $dbGroup->tableArray[$this->
getTableName()];
399 } elseif ($this->columnConfiguration[
'foreign_field']) {
400 $records =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid', $this->
getTableName(), $this->columnConfiguration[
'foreign_field'] .
'=' . (
int)
$uid);
401 foreach ($records as $record) {
402 $relatedUids[] = $record[
'uid'];
422 $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) = \'\'' :
''));
424 foreach ($records as $record) {
425 $uidArray[] = $record[
'uid'];
436 $this->
getSignalSlotDispatcher()->dispatch(
'TYPO3\\CMS\\Core\\Tree\\TableConfiguration\\TableConfiguration\\DatabaseTreeDataProvider',
437 self::SIGNAL_PostProcessTreeData,
438 array($this, $this->treeData)
448 if (!isset($this->signalSlotDispatcher)) {
449 $this->signalSlotDispatcher = $this->
getObjectManager()->get(
'TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
getNonSelectableLevelList()
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
getItemUnselectableList()
getNodes(\TYPO3\CMS\Backend\Tree\TreeNode $node)
const SIGNAL_PostProcessTreeData
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
getSignalSlotDispatcher()
static makeInstance($className)
getRelatedRecords(array $row)
setTableWhere($tableWhere)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
isExpanded(\TYPO3\CMS\Backend\Tree\TreeNode $node)
listFieldQuery($fieldName, $queryId)
setLookupField($lookupField)
setLookupMode($lookupMode)
setLabelField($labelField)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
emitPostProcessTreeDataSignal()
static inList($list, $item)