‪TYPO3CMS  9.5
RecordBrowserPageTreeView.php
Go to the documentation of this file.
1 <?php
2 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 
21 
27 {
37  public function ‪printTree($treeArr = '')
38  {
39  $titleLen = (int)‪$GLOBALS['BE_USER']->uc['titleLen'];
40  if (!is_array($treeArr)) {
41  $treeArr = ‪$this->tree;
42  }
43  $out = '';
44  // We need to count the opened <ul>'s every time we dig into another level,
45  // so we know how many we have to close when all children are done rendering
46  $closeDepth = [];
47  foreach ($treeArr as $treeItem) {
48  $classAttr = $treeItem['row']['_CSSCLASS'];
49  if ($treeItem['isFirst']) {
50  $out .= '<ul class="list-tree">';
51  }
52 
53  // Add CSS classes to the list item
54  if ($treeItem['hasSub']) {
55  $classAttr .= ' list-tree-control-open';
56  }
57 
58  $selected = '';
59  if ($this->linkParameterProvider->isCurrentlySelectedItem(['pid' => (int)$treeItem['row']['uid']])) {
60  $selected = ' bg-success';
61  $classAttr .= ' active';
62  }
63  $out .= '
64  <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
65  <span class="list-tree-group' . $selected . '">
66  ' . $treeItem['HTML']
67  . $this->‪wrapTitle($this->‪getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], ‪$this->ext_pArrPages)
68  . '</span>
69  ';
70  if (!$treeItem['hasSub']) {
71  $out .= '</li>';
72  }
73 
74  // We have to remember if this is the last one
75  // on level X so the last child on level X+1 closes the <ul>-tag
76  if ($treeItem['isLast']) {
77  $closeDepth[$treeItem['invertedDepth']] = 1;
78  }
79  // If this is the last one and does not have subitems, we need to close
80  // the tree as long as the upper levels have last items too
81  if ($treeItem['isLast'] && !$treeItem['hasSub']) {
82  for ($i = $treeItem['invertedDepth']; $closeDepth[$i] == 1; $i++) {
83  $closeDepth[$i] = 0;
84  $out .= '</ul></li>';
85  }
86  }
87  }
88  $out = '<ul class="list-tree list-tree-root">' . $out . '</ul>';
89 
90  return $out;
91  }
92 
101  public function ‪wrapTitle(‪$title, $record, ‪$ext_pArrPages = false)
102  {
103  $urlParameters = $this->linkParameterProvider->getUrlParameters(['pid' => (int)$record['uid']]);
104  $url = $this->‪getThisScript() . ‪HttpUtility::buildQueryString($urlParameters);
105  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($url) . ');';
106 
107  return '<span class="list-tree-title"><a href="#" onclick="' . htmlspecialchars($aOnClick) . '">'
108  . ‪$title . '</a></span>';
109  }
110 
120  public function ‪ext_isLinkable($doktype, $uid)
121  {
122  return true;
123  }
124 }
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView\wrapTitle
‪string wrapTitle($title, $record, $ext_pArrPages=false)
Definition: RecordBrowserPageTreeView.php:101
‪TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView
Definition: ElementBrowserPageTreeView.php:29
‪TYPO3\CMS\Backend\Tree\View\AbstractTreeView\$title
‪string $title
Definition: AbstractTreeView.php:73
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView
Definition: RecordBrowserPageTreeView.php:27
‪TYPO3\CMS\Backend\Tree\View\AbstractTreeView\$tree
‪array $tree
Definition: AbstractTreeView.php:230
‪TYPO3\CMS\Backend\Tree\View\BrowseTreeView\getTitleStr
‪string getTitleStr($row, $titleLen=30)
Definition: BrowseTreeView.php:143
‪TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString
‪static string buildQueryString(array $parameters, string $prependCharacter='', bool $skipEmptyParameters=false)
Definition: HttpUtility.php:160
‪TYPO3\CMS\Recordlist\Tree\View
Definition: DummyLinkParameterProvider.php:2
‪TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView\$ext_pArrPages
‪bool $ext_pArrPages
Definition: ElementBrowserPageTreeView.php:39
‪$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:37
‪TYPO3\CMS\Backend\Tree\View\AbstractTreeView\getThisScript
‪string getThisScript()
Definition: AbstractTreeView.php:276
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:21
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Recordlist\Tree\View\RecordBrowserPageTreeView\ext_isLinkable
‪bool ext_isLinkable($doktype, $uid)
Definition: RecordBrowserPageTreeView.php:120