コード例 #1
0
ファイル: TreeViewRenderer.php プロジェクト: romcok/treeview
 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
ファイル: TreeViewRenderer.php プロジェクト: oaki/demoshop
 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;
 }
コード例 #3
0
ファイル: CBTree.php プロジェクト: oaki/demoshop
 /**
  * Render 1 node (+ subnodes)
  * @param TreeViewNode node
  * @param control
  * @param label
  * @return Nette\Web\Html
  */
 private function renderNode(TreeViewNode $node, $control, $label)
 {
     $pcontrol = clone $control;
     $li = NHtml::el('li');
     $nid = $node->getDataRow()->id;
     $control->id = $label->for = $control->id . '-' . $nid;
     $ck = $this->checkColumn;
     /*
      * Pridal som ze ak neezistuje stlpec, aby nedavalo notice
      */
     if (isset($node->getDataRow()->{$ck}) and $node->getDataRow()->{$ck}) {
         $control->checked = 'checked';
     } else {
         $control->checked = null;
     }
     $control->value = $nid;
     $nc = $this->nameColumn;
     $label->setText($node->getDataRow()->{$nc});
     $li->add((string) $control . (string) $label);
     $nodes = $node->getNodes();
     if (count($nodes)) {
         $ul = NHtml::el('ul');
         $li->add($ul);
         foreach ($nodes as $n) {
             $ul->add($this->renderNode($n, $pcontrol, $label));
         }
     }
     return $li;
 }
コード例 #4
0
ファイル: EditableTree.php プロジェクト: oaki/demoshop
 /**
  * @param TreeViewNode
  * @return Nette\Web\Html
  */
 public function renderNode(TreeViewNode $node)
 {
     $nodes = $node->getNodes();
     $nodeContainer = Html::el('li', array('class' => 'clear-element ' . $this->tree->getName() . '-item sort-handle left', 'id' => $node->getDataRow()->id, 'style' => 'clear: both; text-align: left;'));
     $link = $this->renderLink($node, 'nodeLink');
     if ($link !== NULL) {
         $nodeContainer->add($link);
     }
     $this->tree->onNodeRender($this->tree, $node, $nodeContainer);
     if (count($nodes) > 0) {
         $nodesContainer = $this->renderNodes($nodes);
         if ($nodesContainer !== NULL) {
             $nodeContainer->add($nodesContainer);
         }
     }
     $html = isset($nodeContainer) ? $nodeContainer : $nodesContainer;
     if ($node->isInvalid()) {
         $this->tree->getPresenter()->getPayload()->snippets[$node->getSnippetId()] = (string) $html;
     }
     return $html;
 }