‪TYPO3CMS  10.4
RecordBrowserPageTreeView.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 
28 {
38  public function ‪printTree($treeArr = '')
39  {
40  $titleLen = (int)‪$GLOBALS['BE_USER']->uc['titleLen'];
41  if (!is_array($treeArr)) {
42  $treeArr = ‪$this->tree;
43  }
44  $out = '';
45  // We need to count the opened <ul>'s every time we dig into another level,
46  // so we know how many we have to close when all children are done rendering
47  $closeDepth = [];
48  foreach ($treeArr as $treeItem) {
49  $classAttr = $treeItem['row']['_CSSCLASS'];
50  if ($treeItem['isFirst']) {
51  $out .= '<ul class="list-tree">';
52  }
53 
54  // Add CSS classes to the list item
55  if ($treeItem['hasSub']) {
56  $classAttr .= ' list-tree-control-open';
57  }
58 
59  $selected = '';
60  if ($this->linkParameterProvider->isCurrentlySelectedItem(['pid' => (int)$treeItem['row']['uid']])) {
61  $selected = ' bg-success';
62  $classAttr .= ' active';
63  }
64  $out .= '
65  <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
66  <span class="list-tree-group' . $selected . '">
67  ' . $treeItem['HTML']
68  . $this->‪wrapTitle($this->‪getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], ‪$this->ext_pArrPages)
69  . '</span>
70  ';
71  if (!$treeItem['hasSub']) {
72  $out .= '</li>';
73  }
74 
75  // We have to remember if this is the last one
76  // on level X so the last child on level X+1 closes the <ul>-tag
77  if ($treeItem['isLast']) {
78  $closeDepth[$treeItem['invertedDepth']] = 1;
79  }
80  // If this is the last one and does not have subitems, we need to close
81  // the tree as long as the upper levels have last items too
82  if ($treeItem['isLast'] && !$treeItem['hasSub']) {
83  for ($i = $treeItem['invertedDepth']; $closeDepth[$i] == 1; $i++) {
84  $closeDepth[$i] = 0;
85  $out .= '</ul></li>';
86  }
87  }
88  }
89  $out = '<ul class="list-tree list-tree-root">' . $out . '</ul>';
90 
91  return $out;
92  }
93 
102  public function ‪wrapTitle(‪$title, $record, ‪$ext_pArrPages = false)
103  {
104  $urlParameters = $this->linkParameterProvider->getUrlParameters(['pid' => (int)$record['uid']]);
105  $url = $this->‪getThisScript() . ‪HttpUtility::buildQueryString($urlParameters);
106 
107  return '<span class="list-tree-title"><a href="' . htmlspecialchars($url) . '">' . ‪$title . '</a></span>';
108  }
109 
119  public function ‪ext_isLinkable($doktype, $uid)
120  {
121  return true;
122  }
123 }
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView\wrapTitle
‪string wrapTitle($title, $record, $ext_pArrPages=false)
Definition: RecordBrowserPageTreeView.php:102
‪TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView
Definition: ElementBrowserPageTreeView.php:30
‪TYPO3\CMS\Backend\Tree\View\AbstractTreeView\$title
‪string $title
Definition: AbstractTreeView.php:74
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView
Definition: RecordBrowserPageTreeView.php:28
‪TYPO3\CMS\Backend\Tree\View\AbstractTreeView\$tree
‪array $tree
Definition: AbstractTreeView.php:209
‪TYPO3\CMS\Backend\Tree\View\BrowseTreeView\getTitleStr
‪string getTitleStr($row, $titleLen=30)
Definition: BrowseTreeView.php:142
‪TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString
‪static string buildQueryString(array $parameters, string $prependCharacter='', bool $skipEmptyParameters=false)
Definition: HttpUtility.php:163
‪TYPO3\CMS\Recordlist\Tree\View
Definition: DummyLinkParameterProvider.php:16
‪TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView\$ext_pArrPages
‪bool $ext_pArrPages
Definition: ElementBrowserPageTreeView.php:40
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView\printTree
‪string printTree($treeArr='')
Definition: RecordBrowserPageTreeView.php:38
‪TYPO3\CMS\Backend\Tree\View\AbstractTreeView\getThisScript
‪string getThisScript()
Definition: AbstractTreeView.php:250
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:24
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView\ext_isLinkable
‪bool ext_isLinkable($doktype, $uid)
Definition: RecordBrowserPageTreeView.php:119