TYPO3 CMS  TYPO3_8-7
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 
20 
25 {
35  public function printTree($treeArr = '')
36  {
37  $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
38  if (!is_array($treeArr)) {
39  $treeArr = $this->tree;
40  }
41  $out = '';
42  // We need to count the opened <ul>'s every time we dig into another level,
43  // so we know how many we have to close when all children are done rendering
44  $closeDepth = [];
45  foreach ($treeArr as $treeItem) {
46  $classAttr = $treeItem['row']['_CSSCLASS'];
47  if ($treeItem['isFirst']) {
48  $out .= '<ul class="list-tree">';
49  }
50 
51  // Add CSS classes to the list item
52  if ($treeItem['hasSub']) {
53  $classAttr .= ' list-tree-control-open';
54  }
55 
56  $selected = '';
57  if ($this->linkParameterProvider->isCurrentlySelectedItem(['pid' => (int)$treeItem['row']['uid']])) {
58  $selected = ' bg-success';
59  $classAttr .= ' active';
60  }
61  $out .= '
62  <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
63  <span class="list-tree-group' . $selected . '">
64  ' . $treeItem['HTML']
65  . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $this->ext_pArrPages)
66  . '</span>
67  ';
68  if (!$treeItem['hasSub']) {
69  $out .= '</li>';
70  }
71 
72  // We have to remember if this is the last one
73  // on level X so the last child on level X+1 closes the <ul>-tag
74  if ($treeItem['isLast']) {
75  $closeDepth[$treeItem['invertedDepth']] = 1;
76  }
77  // If this is the last one and does not have subitems, we need to close
78  // the tree as long as the upper levels have last items too
79  if ($treeItem['isLast'] && !$treeItem['hasSub']) {
80  for ($i = $treeItem['invertedDepth']; $closeDepth[$i] == 1; $i++) {
81  $closeDepth[$i] = 0;
82  $out .= '</ul></li>';
83  }
84  }
85  }
86  $out = '<ul class="list-tree list-tree-root">' . $out . '</ul>';
87 
88  return $out;
89  }
90 
99  public function wrapTitle($title, $record, $ext_pArrPages = false)
100  {
101  $urlParameters = $this->linkParameterProvider->getUrlParameters(['pid' => (int)$record['uid']]);
102  $url = $this->getThisScript() . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&');
103  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($url) . ');';
104 
105  return '<span class="list-tree-title"><a href="#" onclick="' . htmlspecialchars($aOnClick) . '">'
106  . $title . '</a></span>';
107  }
108 
118  public function ext_isLinkable($doktype, $uid)
119  {
120  return true;
121  }
122 }
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']