예제 #1
0
 public function renderNode(TreeViewNode $node)
 {
     $nodes = $node->getNodes();
     $snippetId = $node->getSnippetId();
     $nodeContainer = $this->getWrapper('node container');
     $nodeContainer->id = $snippetId;
     if (count($nodes) > 0) {
         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);
         }
     } else {
         $icon = $this->getWrapper('node icon');
         if (null !== $icon) {
             $nodeContainer->add($icon);
         }
     }
     $link = $this->renderLink($node, 'nodeLink');
     if (null !== $link) {
         $nodeContainer->add($link);
     }
     if ($this->tree->sortable) {
         foreach (array('up', 'down', 'left', 'right') as $direction) {
             $nodeContainer->add($this->renderSortableLink($node, $direction));
         }
     }
     //$up = $this->renderLink($node, 'moveUpLink', 'sorting up');
     //$down = $this->renderLink($node, 'moveDownLink', 'sorting down');
     //$left = $this->renderLink($node, 'moveLeftLink', 'sorting left');
     //$right = $this->renderLink($node, 'moveRightLink', 'sorting right');
     $this->tree->onNodeRender($this->tree, $node, $nodeContainer);
     if (TreeViewNode::EXPANDED === $node->getState() && count($nodes) > 0) {
         $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;
 }
예제 #2
0
 public function renderNode(TreeViewNode $node)
 {
     $nodes = $node->getNodes();
     $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 && count($nodes) > 0) {
         $nodeContainer->addClass($this->getValue('node .expanded'));
     }
     if (count($nodes) > 0) {
         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);
         }
     } else {
         $icon = $this->getWrapper('node icon');
         if (NULL !== $icon) {
             $nodeContainer->add($icon);
         }
     }
     $link = $this->renderLink($node, 'nodeLink');
     if (NULL !== $link) {
         $nodeContainer->add($link);
     }
     $this->tree->onNodeRender($this->tree, $node, $nodeContainer);
     if (TreeViewNode::EXPANDED === $node->getState() && count($nodes) > 0) {
         $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;
 }