2 namespace TYPO3\CMS\Backend\Tree\View;
151 public $defaultList =
'uid,pid,tstamp,sorting,deleted,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,crdate,cruser_id';
285 $route = $router->match($routePath);
287 $this->thisScript = (string)$uriBuilder->buildUriFromRoute($route->getOption(
'_identifier'));
289 $this->thisScript = BackendUtility::getModuleUrl($moduleName);
300 return strpos($this->thisScript,
'?') ===
false ? $this->thisScript .
'?' : $this->thisScript .
'&';
313 $this->BE_USER =
$GLOBALS[
'BE_USER'];
321 if (!is_array($this->MOUNTS)) {
323 $this->MOUNTS = array(0 => 0);
326 $this->treeName = str_replace(
'_',
'', $this->treeName ?: $this->table);
329 $this->dataLookup =
false;
342 $this->fieldArray[] = $field;
353 $this->tree = array();
354 $this->recs = array();
355 $this->ids = array();
356 $this->ids_hierarchy = array();
357 $this->orig_ids_hierarchy = array();
378 foreach ($this->MOUNTS as $idx => $uid) {
385 $this->ids = $curIds;
387 $cmd = $this->bank .
'_' . ($isOpen ?
'0_' :
'1_') . $uid .
'_' . $this->treeName;
389 $firstHtml = $this->
PM_ATagWrap(
'', $cmd,
'', $isOpen);
393 $firstHtml .= $this->
getIcon($rootRec);
399 if (is_array($rootRec)) {
401 $uid = $rootRec[
'uid'];
403 $this->tree[] = array(
'HTML' => $firstHtml,
'row' => $rootRec,
'hasSub' => $isOpen,
'bank' => $this->bank);
406 $depthData =
'<span class="treeline-icon treeline-icon-clear"></span>';
407 if ($this->addSelfId) {
410 $this->
getTree($uid, 999, $depthData);
413 $treeArr = array_merge($treeArr, $this->tree);
427 $titleLen = (int)$this->BE_USER->uc[
'titleLen'];
428 if (!is_array($treeArr)) {
432 $closeDepth = array();
433 foreach ($treeArr as $treeItem) {
435 if ($treeItem[
'isFirst']) {
436 $out .=
'<ul class="list-tree">';
440 if ($treeItem[
'hasSub']) {
441 $classAttr .=
' list-tree-control-open';
444 $idAttr = htmlspecialchars($this->domIdPrefix . $this->
getId($treeItem[
'row']) .
'_' . $treeItem[
'bank']);
446 <li id="' . $idAttr .
'"' . ($classAttr ?
' class="' . trim($classAttr) .
'"' :
'') .
'>
447 <span class="list-tree-group">
448 <span class="list-tree-icon">' . $treeItem[
'HTML'] .
'</span>
449 <span class="list-tree-title">' . $this->
wrapTitle($this->
getTitleStr($treeItem[
'row'], $titleLen), $treeItem[
'row'], $treeItem[
'bank']) .
'</span>
452 if (!$treeItem[
'hasSub']) {
458 if ($treeItem[
'isLast']) {
459 $closeDepth[$treeItem[
'invertedDepth']] = 1;
463 if ($treeItem[
'isLast'] && !$treeItem[
'hasSub']) {
464 for ($i = $treeItem[
'invertedDepth']; $closeDepth[$i] == 1; $i++) {
466 $out .=
'</ul></li>';
470 $out =
'<ul class="list-tree list-tree-root list-tree-root-clean">' . $out .
'</ul>';
491 public function PMicon($row, $a, $c, $nextCount, $isOpen)
494 $cmd = $this->bank .
'_' . ($isOpen ?
'0_' :
'1_') . $row[
'uid'] .
'_' . $this->treeName;
495 $bMark = $this->bank .
'_' . $row[
'uid'];
496 return $this->
PM_ATagWrap(
'', $cmd, $bMark, $isOpen);
512 public function PM_ATagWrap($icon, $cmd, $bMark =
'', $isOpen =
false)
514 if ($this->thisScript) {
515 $anchor = $bMark ?
'#' . $bMark :
'';
516 $name = $bMark ?
' name="' . $bMark .
'"' :
'';
518 return '<a class="list-tree-control ' . ($isOpen ?
'list-tree-control-open' :
'list-tree-control-closed') .
' href="' . htmlspecialchars($aUrl) .
'"' . $name .
'><i class="fa"></i></a>';
536 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) .
'">' .
$title .
'</a>';
561 return preg_replace(
'/ ?\\/?>$/',
'', $icon) .
' ' . $attr .
' />';
574 if ($row[
'php_tree_stop']) {
597 return $this->stored[
$this->bank][$id] || $this->expandAll ? 1 : 0;
609 $this->stored = unserialize($this->BE_USER->uc[
'browseTrees'][$this->treeName]);
615 if (count($PM) === 4 && $PM[3] == $this->treeName) {
616 if (isset($this->MOUNTS[$PM[0]])) {
619 $this->stored[$PM[0]][$PM[2]] = 1;
622 unset($this->stored[$PM[0]][$PM[2]]);
638 $this->BE_USER->uc[
'browseTrees'][
$this->treeName] = serialize($this->stored);
639 $this->BE_USER->writeUC();
670 $title = $this->showDefaultTitleAttribute ? htmlspecialchars(
'UID: ' . $row[
'uid']) : $this->
getTitleAttrib($row);
672 $icon =
'<span title="' .
$title .
'">' . $iconFactory->getIconForRecord($this->table, $row,
Icon::SIZE_SMALL)->render() .
'</span>';
673 return $this->
wrapIcon($icon, $row);
687 $title = trim($row[
'title']) ===
'' ?
'<em>[' . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.no_title',
true) .
']</em>' :
$title;
700 return htmlspecialchars($row[
'title']);
722 return $this->
getId($row);
739 public function getTree($uid, $depth = 999, $depthData =
'')
742 $this->buffer_idH = array();
744 $depth = (int)$depth;
749 $crazyRecursionLimiter = 999;
752 while ($crazyRecursionLimiter > 0 && ($row = $this->
getDataNext($res))) {
753 $pageUid = ($this->table ===
'pages') ? $row[
'uid'] : $row[
'pid'];
760 $crazyRecursionLimiter--;
761 $newID = $row[
'uid'];
763 throw new \RuntimeException(
'Endless recursion detected: TYPO3 has detected an error in the database. Please fix it manually (e.g. using phpMyAdmin) and change the UID of ' . $this->table .
':0 to a new value. See http://forge.typo3.org/issues/16150 to get more information about a possible cause.', 1294586383);
766 $this->tree[] = array();
769 $treeKey = key($this->tree);
771 if ($this->setRecs) {
772 $this->recs[$row[
'uid']] = $row;
775 $this->ids[] = ($idH[$row[
'uid']][
'uid'] = $row[
'uid']);
776 $this->ids_hierarchy[$depth][] = $row[
'uid'];
777 $this->orig_ids_hierarchy[$depth][] = $row[
'_ORIG_uid'] ?: $row[
'uid'];
780 $nextLevelDepthData = $depthData .
'<span class="treeline-icon treeline-icon-' . ($a === $c ?
'clear' :
'line') .
'"></span>';
781 $hasSub = $this->
expandNext($newID) && !$row[
'php_tree_stop'];
782 if ($depth > 1 && $hasSub) {
783 $nextCount = $this->
getTree($newID, $depth - 1, $nextLevelDepthData);
784 if (!empty($this->buffer_idH)) {
790 $nextCount = $this->
getCount($newID);
795 if ($this->makeHTML) {
796 $HTML = $this->
PMicon($row, $a, $c, $nextCount, $isOpen) . $this->
wrapStop($this->
getIcon($row), $row);
799 $this->tree[$treeKey] = array(
802 'invertedDepth' => $depth,
803 'depthData' => $depthData,
804 'bank' => $this->bank,
805 'hasSub' => $nextCount && $hasSub,
806 'isFirst' => $a === 1,
807 'isLast' => $a === $c,
812 $this->buffer_idH = $idH;
831 if (is_array($this->data)) {
837 return $db->exec_SELECTcountRows(
'uid', $this->table, $where);
848 return array(
'title' => $this->title,
'uid' => 0);
861 if (is_array($this->data)) {
862 return $this->dataLookup[$uid];
880 if (is_array($this->data)) {
881 if (!is_array($this->dataLookup[$parentId][$this->subLevelID])) {
884 reset($this->dataLookup[$parentId][$this->subLevelID]);
890 return $db->exec_SELECTquery(implode(
',', $this->fieldArray), $this->table, $where,
'', $this->orderByFields);
904 if (is_array($this->data)) {
905 return count($this->dataLookup[$res][$this->subLevelID]);
922 if (is_array($this->data)) {
926 list(, $row) = each($this->dataLookup[$res][$this->subLevelID]);
932 if (is_array($row)) {
949 if (!is_array($this->data)) {
969 $this->data = &$dataArr;
970 $this->dataLookup = array();
974 foreach ($dataArr as $uid => $val) {
975 $dataArr[$uid][
'uid'] = $uid;
976 $dataArr[$uid][
'pid'] = $pid;
978 $this->dataLookup[$uid] = &$dataArr[$uid];
979 if (is_array($val[$this->subLevelID])) {
994 $this->data = &$treeArr;
995 $this->dataLookup = &$treeLookupArr;