‪TYPO3CMS  10.4
UnorderedListTreeRenderer.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
26 {
32  protected ‪$recursionLevel = 0;
33 
41  public function ‪renderNode(‪TreeRepresentationNode $node, $recursive = true)
42  {
43  $code = '<li><span class="' . htmlspecialchars($node->‪getIcon()) . '">&nbsp;</span>' . htmlspecialchars($node->‪getLabel());
44  if ($recursive && $node->‪getChildNodes() !== null) {
45  $this->recursionLevel++;
46  $code .= $this->‪renderNodeCollection($node->‪getChildNodes());
47  $this->recursionLevel--;
48  }
49  $code .= '</li>';
50  return $code;
51  }
52 
60  public function ‪renderTree(‪AbstractTree $tree, $recursive = true)
61  {
62  $this->recursionLevel = 0;
63  $code = '<ul class="level' . $this->recursionLevel . '" style="margin-left:10px">';
64  $code .= $this->‪renderNode($tree->‪getRoot(), $recursive);
65  $code .= '</ul>';
66  return $code;
67  }
68 
76  public function ‪renderNodeCollection(‪TreeNodeCollection $collection, $recursive = true)
77  {
78  $code = '<ul class="level' . $this->recursionLevel . '" style="margin-left:10px">';
79  foreach ($collection as $node) {
80  $code .= $this->‪renderNode($node, $recursive);
81  }
82  $code .= '</ul>';
83  return $code;
84  }
85 }
‪TYPO3\CMS\Backend\Tree\TreeRepresentationNode\getLabel
‪string getLabel()
Definition: TreeRepresentationNode.php:98
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\$recursionLevel
‪int $recursionLevel
Definition: UnorderedListTreeRenderer.php:31
‪TYPO3\CMS\Backend\Tree\TreeRepresentationNode
Definition: TreeRepresentationNode.php:24
‪TYPO3\CMS\Backend\Tree\Renderer
Definition: AbstractTreeRenderer.php:16
‪TYPO3\CMS\Backend\Tree\AbstractTree\getRoot
‪TYPO3 CMS Backend Tree TreeNode getRoot()
‪TYPO3\CMS\Backend\Tree\TreeNodeCollection
Definition: TreeNodeCollection.php:25
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\renderNodeCollection
‪string renderNodeCollection(TreeNodeCollection $collection, $recursive=true)
Definition: UnorderedListTreeRenderer.php:75
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\renderTree
‪string renderTree(AbstractTree $tree, $recursive=true)
Definition: UnorderedListTreeRenderer.php:59
‪TYPO3\CMS\Backend\Tree\Renderer\AbstractTreeRenderer
Definition: AbstractTreeRenderer.php:26
‪TYPO3\CMS\Backend\Tree\TreeRepresentationNode\getIcon
‪string Icon getIcon()
Definition: TreeRepresentationNode.php:82
‪TYPO3\CMS\Backend\Tree\AbstractTree
Definition: AbstractTree.php:24
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer
Definition: UnorderedListTreeRenderer.php:26
‪TYPO3\CMS\Backend\Tree\Renderer\UnorderedListTreeRenderer\renderNode
‪string renderNode(TreeRepresentationNode $node, $recursive=true)
Definition: UnorderedListTreeRenderer.php:40
‪TYPO3\CMS\Backend\Tree\TreeNode\getChildNodes
‪TYPO3 CMS Backend Tree TreeNodeCollection getChildNodes()
Definition: TreeNode.php:85