TYPO3 CMS  TYPO3_6-2
UnorderedListTreeRenderer.php
Go to the documentation of this file.
1 <?php
3 
22 
28  protected $recursionLevel = 0;
29 
37  public function renderNode(\TYPO3\CMS\Backend\Tree\TreeRepresentationNode $node, $recursive = TRUE) {
38  $code = '<li><span class="' . htmlspecialchars($node->getIcon()) . '">&nbsp;</span>' . htmlspecialchars($node->getLabel());
39  if ($recursive && $node->getChildNodes() !== NULL) {
40  $this->recursionLevel++;
41  $code .= $this->renderNodeCollection($node->getChildNodes());
42  $this->recursionLevel--;
43  }
44  $code .= '</li>';
45  return $code;
46  }
47 
55  public function renderTree(\TYPO3\CMS\Backend\Tree\AbstractTree $tree, $recursive = TRUE) {
56  $this->recursionLevel = 0;
57  $code = '<ul class="level' . $this->recursionLevel . '" style="margin-left:10px">';
58  $code .= $this->renderNode($tree->getRoot(), $recursive);
59  $code .= '</ul>';
60  return $code;
61  }
62 
70  public function renderNodeCollection(\TYPO3\CMS\Backend\Tree\TreeNodeCollection $collection, $recursive = TRUE) {
71  $code = '<ul class="level' . $this->recursionLevel . '" style="margin-left:10px">';
72  foreach ($collection as $node) {
73  $code .= $this->renderNode($node, $recursive);
74  }
75  $code .= '</ul>';
76  return $code;
77  }
78 
79 }
renderTree(\TYPO3\CMS\Backend\Tree\AbstractTree $tree, $recursive=TRUE)
renderNode(\TYPO3\CMS\Backend\Tree\TreeRepresentationNode $node, $recursive=TRUE)
renderNodeCollection(\TYPO3\CMS\Backend\Tree\TreeNodeCollection $collection, $recursive=TRUE)