/** * @param TreeViewNode $node */ public function renderNode(TreeViewNode $node) { $nodes = $node->getNodes(); $ncount = $nodes->count() - 1; $snippetId = $node->getSnippetId(); $nodeContainer = $this->getWrapper('node container'); $nodeContainer->id = $snippetId; if ($this->tree->getSelected() == $node->name) { $nodeContainer->addClass($this->getValue('node .selected')); } if ($node->getState() == TreeViewNode::EXPANDED && $ncount) { $nodeContainer->addClass($this->getValue('node .expanded')); } if ($ncount) { switch ($node->getState()) { case TreeViewNode::EXPANDED: $stateLink = $this->renderLink($node, 'stateLink', 'link collapse'); break; case TreeViewNode::COLLAPSED: $stateLink = $this->renderLink($node, 'stateLink', 'link expand'); break; } if (NULL !== $stateLink) { $nodeContainer->add($stateLink); } } elseif (NULL !== ($icon = $this->getWrapper('node icon'))) { $nodeContainer->add($icon); } if (NULL !== ($link = $this->renderLink($node, 'nodeLink'))) { $nodeContainer->add($link); } $this->tree->onNodeRender($this->tree, $node, $nodeContainer); if (TreeViewNode::EXPANDED === $node->getState() && $ncount) { $nodesContainer = $this->renderNodes($nodes); if (NULL !== $nodesContainer) { $nodeContainer->add($nodesContainer); } } $html = isset($nodeContainer) ? $nodeContainer : $nodesContainer; if ($node->isInvalid()) { $this->tree->getPresenter()->getPayload()->snippets[$snippetId] = (string) $html; } return $html; }
protected function load() { if (!$this->loaded) { $this->loaded = TRUE; $pid = $this->treeView->parentColumn; $dataRows = TreeView::EXPANDED !== $this->treeView->mode ? $this->getDataRows() : $this->treeView->getDataRows(); foreach ($dataRows as $dataRow) { if (empty($this->dataRow) || !empty($this->dataRow) && $this->dataRow['id'] === $dataRow[$pid]) { $node = new TreeViewNode($this, $dataRow[$this->treeView->primaryKey], $dataRow); $node['nodeLink'] = clone $this['nodeLink']; if (TreeView::EXPANDED === $this->treeView->mode && ($this->treeView->rememberState && !$node->isSessionState() || !$this->treeView->rememberState)) { $node->expand(); } } } } }
/** * @return \ArrayIterator */ protected function getDataRows() { if (TreeView::EXPANDED === $this->mode) { if ($this->dataRows === NULL) { $this->dataRows = $this->dataSource->fetchAssoc($this->primaryKey); } return $this->dataRows; } return parent::getDataRows(); }