/** * @param tx_caretaker_AbstractNode $node * @param int $depth * @return array */ protected function nodeToArray($node, $depth = 1) { // show node and icon $result = array(); $uid = $node->getUid(); $title = $node->getTitle(); $hidden = $node->getHidden(); $id = $node->getCaretakerNodeId(); $testResult = $node->getTestResult(); $resultClass = 'caretaker-state-' . strtolower($testResult->getStateInfo()); $typeClass = 'caretaker-type-' . strtolower($node->getType()); $result['type'] = strtolower($node->getType()); $result['id'] = $id; $result['uid'] = $uid; $result['disabled'] = $hidden; $result['text'] = $title ? $title : '[no title]'; $result['cls'] = $resultClass . ' ' . $typeClass; $result['iconCls'] = 'icon-' . $typeClass . ($hidden ? '-hidden' : ''); if (strtolower($node->getType()) == 'instance' && $node instanceof tx_caretaker_InstanceNode) { $result['url'] = $node->getUrl(); } else { $result['url'] = false; } // show subitems of tx_caretaker_AggregatorNodes if ($node instanceof tx_caretaker_AggregatorNode) { $children = $node->getChildren(true); $result['leaf'] = count($children) == 0 ? true : false; if ($depth > 0) { $result['children'] = array(); foreach ($children as $child) { $result['children'][] = $this->nodeToArray($child, $depth - 1); } } } else { $result['leaf'] = TRUE; } return $result; }
/** * @param tx_caretaker_AbstractNode $node * @return string */ function showNodeInfo($node) { // render first level Children if ($node instanceof tx_caretaker_AggregatorNode) { $template = $this->cObj->cObjGetSingle($this->conf['template'], $this->conf['template.']); $children = $node->getChildren(); $child_template = $this->cObj->getSubpart($template, '###CARETAKER-CHILD###'); $child_infos = ''; foreach ($children as $child) { $data = $this->getNodeData($child); $lcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $lcObj->start($data); $node_markers = array(); if ($this->conf['childMarkers.']) { foreach (array_keys($this->conf['childMarkers.']) as $key) { if (substr($key, -1) != '.') { $mark = $lcObj->cObjGetSingle($this->conf['childMarkers.'][$key], $this->conf['childMarkers.'][$key . '.']); $node_markers['###' . $key . '###'] = $mark; } } $child_infos .= $this->cObj->substituteMarkerArray($child_template, $node_markers); } } $template = $this->cObj->substituteSubpart($template, 'CARETAKER-CHILDREN', $child_infos); } else { $template = $this->cObj->cObjGetSingle($this->conf['templateChild'], $this->conf['templateChild.']); } // render Rootline $rootline_subpart = $this->cObj->getSubpart($template, '###ROOTLINE_ITEM###'); $rootline_items = array(); $rootline_node = $node; do { $data = $this->getNodeData($rootline_node); $lcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $lcObj->start($data); $node_markers = array(); if ($this->conf['rootlineMarkers.']) { foreach (array_keys($this->conf['rootlineMarkers.']) as $key) { if (substr($key, -1) != '.') { $mark = $lcObj->cObjGetSingle($this->conf['rootlineMarkers.'][$key], $this->conf['rootlineMarkers.'][$key . '.']); $node_markers['###' . $key . '###'] = $mark; } } $rootline_items[] = $this->cObj->substituteMarkerArray($rootline_subpart, $node_markers); } } while ($rootline_node = $rootline_node->getParent()); $rootline_items = array_reverse($rootline_items); $template = $this->cObj->substituteSubpart($template, '###ROOTLINE###', implode('', $rootline_items)); // render Node Infos $data = $this->getNodeData($node, true); $data['chart'] = $this->getNodeChart($node); $lcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $lcObj->start($data); $node_markers = array(); if ($this->conf['nodeMarkers.']) { foreach (array_keys($this->conf['nodeMarkers.']) as $key) { if (substr($key, -1) != '.') { $mark = $lcObj->cObjGetSingle($this->conf['nodeMarkers.'][$key], $this->conf['nodeMarkers.'][$key . '.']); $node_markers['###' . $key . '###'] = $mark; } } $template = $this->cObj->substituteMarkerArray($template, $node_markers); } return $template; }