expandAll = true; $checkSub = $levels > 0; $this->buildTree($pid, $levels, $checkSub); } /** * Creation of a tree structure with predefined depth to prepare the export. * * @param int $pid Page ID * @param int $levels Page tree levels * @param bool $checkSub Should root page be checked for sub pages? */ protected function buildTree(int $pid, int $levels, bool $checkSub): void { $this->reset(); $iconFactory = GeneralUtility::makeInstance(IconFactory::class); // Root page if ($pid > 0) { $rootRecord = BackendUtility::getRecordWSOL('pages', $pid); $rootHtml = $iconFactory->getIconForRecord('pages', $rootRecord, IconSize::SMALL)->render(); } else { $rootRecord = [ 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], 'uid' => 0, ]; $rootHtml = $iconFactory->getIcon('apps-pagetree-root', IconSize::SMALL)->render(); } $this->tree[] = [ 'HTML' => $rootHtml, 'row' => $rootRecord, 'hasSub' => $checkSub, 'bank' => $this->bank, ]; // Subtree if ($checkSub) { $this->getTree($pid, $levels); } $idH = []; $idH[$pid]['uid'] = $pid; if (!empty($this->buffer_idH)) { $idH[$pid]['subrow'] = $this->buffer_idH; } $this->buffer_idH = $idH; // Check if root page has subtree if (empty($this->buffer_idH)) { $this->tree[0]['hasSub'] = false; } } /** * Compiles the HTML code for displaying the structure found inside the ->tree array * * @param array|string $treeArr "tree-array" - if blank string, the internal ->tree array is used. * @return string The HTML code for the tree */ public function printTree($treeArr = '') { if (!is_array($treeArr)) { $treeArr = $this->tree; } $out = ''; $closeDepth = []; foreach ($treeArr as $treeItem) { if ($treeItem['isFirst'] ?? false) { $out .= '