‪TYPO3CMS  9.5
UnorderedListTreeRenderer.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
27  protected ‪$recursionLevel = 0;
28 
36  public function ‪renderNode(\‪TYPO3\CMS\Backend\Tree\‪TreeRepresentationNode $node, $recursive = true)
37  {
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  {
57  $this->recursionLevel = 0;
58  $code = '<ul class="level' . $this->recursionLevel . '" style="margin-left:10px">';
59  $code .= $this->‪renderNode($tree->getRoot(), $recursive);
60  $code .= '</ul>';
61  return $code;
62  }
63 
71  public function ‪renderNodeCollection(\‪TYPO3\CMS\Backend\Tree\‪TreeNodeCollection $collection, $recursive = true)
72  {
73  $code = '<ul class="level' . $this->recursionLevel . '" style="margin-left:10px">';
74  foreach ($collection as $node) {
75  $code .= $this->‪renderNode($node, $recursive);
76  }
77  $code .= '</ul>';
78  return $code;
79  }
80 }
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\$recursionLevel
‪int $recursionLevel
Definition: UnorderedListTreeRenderer.php:26
‪TYPO3\CMS\Backend\Tree\TreeRepresentationNode
Definition: TreeRepresentationNode.php:22
‪TYPO3
‪TYPO3\CMS\Backend\Tree\Renderer
Definition: AbstractTreeRenderer.php:2
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\renderNodeCollection
‪string renderNodeCollection(\TYPO3\CMS\Backend\Tree\TreeNodeCollection $collection, $recursive=true)
Definition: UnorderedListTreeRenderer.php:70
‪TYPO3\CMS\Backend\Tree\TreeNodeCollection
Definition: TreeNodeCollection.php:21
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\renderTree
‪string renderTree(\TYPO3\CMS\Backend\Tree\AbstractTree $tree, $recursive=true)
Definition: UnorderedListTreeRenderer.php:54
‪TYPO3\CMS\Backend\Tree\Renderer\AbstractTreeRenderer
Definition: AbstractTreeRenderer.php:21
‪TYPO3\CMS\Backend\Tree\AbstractTree
Definition: AbstractTree.php:21
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer
Definition: UnorderedListTreeRenderer.php:21
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\renderNode
‪string renderNode(\TYPO3\CMS\Backend\Tree\TreeRepresentationNode $node, $recursive=true)
Definition: UnorderedListTreeRenderer.php:35