TYPO3 CMS  TYPO3_7-6
ElementBrowserPageTreeView.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 
20 
27 {
34  public $ext_showPageId = false;
35 
39  public $ext_pArrPages = true;
40 
45 
49  public function __construct()
50  {
51  parent::__construct();
52  $this->init();
53  $this->clause = ' AND doktype <> ' . PageRepository::DOKTYPE_RECYCLER . $this->clause;
54  }
55 
62  {
63  $this->linkParameterProvider = $linkParameterProvider;
64  $this->thisScript = $linkParameterProvider->getScriptUrl();
65  }
66 
75  public function wrapTitle($title, $v, $ext_pArrPages = false)
76  {
77  if ($this->ext_isLinkable($v['doktype'], $v['uid'])) {
78  return '<span class="list-tree-title"><a href="#" class="t3js-pageLink" data-id="' . (int)$v['uid'] . '">' . $title . '</a></span>';
79  } else {
80  return '<span class="list-tree-title text-muted">' . $title . '</span>';
81  }
82  }
83 
90  public function printTree($treeArr = '')
91  {
92  $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
93  if (!is_array($treeArr)) {
94  $treeArr = $this->tree;
95  }
96  $out = '';
97  // We need to count the opened <ul>'s every time we dig into another level,
98  // so we know how many we have to close when all children are done rendering
99  $closeDepth = [];
100  foreach ($treeArr as $treeItem) {
101  if ($treeItem['isMountPointPath']) {
102  $out .= '<li class="list-tree-path">' . $treeItem['title'] . '</li>';
103  continue;
104  }
105 
106  $classAttr = $treeItem['row']['_CSSCLASS'];
107  if ($treeItem['isFirst']) {
108  $out .= '<ul class="list-tree">';
109  }
110 
111  // Add CSS classes to the list item
112  if ($treeItem['hasSub']) {
113  $classAttr .= ' list-tree-control-open';
114  }
115 
116  $selected = '';
117  if ($this->linkParameterProvider->isCurrentlySelectedItem(['pid' => (int)$treeItem['row']['uid']])) {
118  $selected = ' bg-success';
119  $classAttr .= ' active';
120  }
121  $urlParameters = $this->linkParameterProvider->getUrlParameters(['pid' => (int)$treeItem['row']['uid']]);
122  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&')) . ');';
123  $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid'])
124  ? '<a href="#" class="list-tree-show" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>'
125  : '';
126  $out .= '
127  <li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '>
128  <span class="list-tree-group' . $selected . '">
129  ' . $cEbullet . $treeItem['HTML'] . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $this->ext_pArrPages) . '
130  </span>
131  ';
132  if (!$treeItem['hasSub']) {
133  $out .= '</li>';
134  }
135 
136  // We have to remember if this is the last one
137  // on level X so the last child on level X+1 closes the <ul>-tag
138  if ($treeItem['isLast']) {
139  $closeDepth[$treeItem['invertedDepth']] = 1;
140  }
141  // If this is the last one and does not have subitems, we need to close
142  // the tree as long as the upper levels have last items too
143  if ($treeItem['isLast'] && !$treeItem['hasSub']) {
144  for ($i = $treeItem['invertedDepth']; $closeDepth[$i] == 1; $i++) {
145  $closeDepth[$i] = 0;
146  $out .= '</ul></li>';
147  }
148  }
149  }
150  return '<ul class="list-tree list-tree-root">' . $out . '</ul>';
151  }
152 
160  public function ext_isLinkable($doktype, $uid)
161  {
162  return $uid && $doktype < PageRepository::DOKTYPE_SPACER;
163  }
164 
174  public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = false)
175  {
176  $anchor = $bMark ? '#' . $bMark : '';
177  $name = $bMark ? ' name=' . $bMark : '';
178  $urlParameters = $this->linkParameterProvider->getUrlParameters([]);
179  $urlParameters['PM'] = $cmd;
180  $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&')) . ',' . GeneralUtility::quoteJSvalue($anchor) . ');';
181  return '<a class="list-tree-control ' . ($isOpen ? 'list-tree-control-open' : 'list-tree-control-closed')
182  . '" href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa"></i></a>';
183  }
184 
192  public function wrapIcon($icon, $row)
193  {
194  if ($this->ext_showPageId) {
195  $icon .= '[' . $row['uid'] . ']&nbsp;';
196  }
197  return $icon;
198  }
199 }
init($clause='', $orderByFields='')
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)
$uid
Definition: server.php:38
setLinkParameterProvider(LinkParameterProviderInterface $linkParameterProvider)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']