2 namespace TYPO3\CMS\Backend\Tree\View;
94 parent::__construct();
96 $this->storages = $this->BE_USER->getFileStorages();
113 public function PMicon($folderObject, $subFolderCounter, $totalSubFolders, $nextCount, $isExpanded)
134 if (empty($this->scope)) {
135 $this->scope = array(
136 'class' => get_class($this),
137 'script' => $this->thisScript,
138 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs
142 if ($this->thisScript) {
144 $scopeData = serialize($this->scope);
147 return '<a class="list-tree-control' . (!$isExpand ?
' list-tree-control-open' :
' list-tree-control-closed') .
'" onclick="' . $js .
'"><i class="fa"></i></a>';
160 $link = $this->thisScript ?
' href="' . htmlspecialchars($this->
getThisScript() .
'PM=' . $cmd) .
'"' :
'';
161 return '<a class="list-tree-control list-tree-control-' . ($isOpen ?
'open' :
'closed') .
'"' . $link .
'><i class="fa"></i></a>';
178 if (!$this->ext_IconMode) {
183 }
elseif ($this->ext_IconMode ===
'titlelink') {
185 $theFolderIcon =
'<a href="#" onclick="' . htmlspecialchars($aOnClick) .
'">' . $icon .
'</a>';
187 return $theFolderIcon;
219 public function getId($folderObject)
221 return GeneralUtility::md5Int($folderObject->getCombinedIdentifier());
233 return rawurlencode($folderObject->getCombinedIdentifier());
246 return $row[
'_title'] ?: parent::getTitleStr($row, $titleLen);
258 return htmlspecialchars($folderObject->getName());
272 $treeItems = array();
274 foreach ($this->storages as $storageObject) {
275 $this->getBrowseableTreeForStorage($storageObject);
277 $treeItems = array_merge($treeItems, $this->tree);
288 public function getBrowseableTreeForStorage(
ResourceStorage $storageObject)
292 $rootLevelFolders = array();
293 if (!empty($fileMounts)) {
294 foreach ($fileMounts as $fileMountInfo) {
295 $rootLevelFolders[] = array(
296 'folder' => $fileMountInfo[
'folder'],
297 'name' => $fileMountInfo[
'title']
300 }
elseif ($this->BE_USER->isAdmin()) {
301 $rootLevelFolders[] = array(
303 'name' => $storageObject->
getName()
309 foreach ($rootLevelFolders as $rootLevelFolderInfo) {
311 $rootLevelFolder = $rootLevelFolderInfo[
'folder'];
312 $rootLevelFolderName = $rootLevelFolderInfo[
'name'];
314 $this->specUIDmap[$folderHashSpecUID] = $rootLevelFolder->getCombinedIdentifier();
318 $this->bank = $storageHashNumber;
319 $isOpen = $this->stored[$storageHashNumber][$folderHashSpecUID] ||
$this->expandFirst;
330 if ($storageObject->
isOnline() ===
false) {
331 $rootLevelFolderName .=
' (' . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_mod_file.xlf:sys_file_storage.isOffline') .
')';
334 $icon = $this->iconFactory->getIconForResource($rootLevelFolder,
Icon::SIZE_SMALL, null, array(
'mount-root' =>
true));
335 $firstHtml .= $this->
wrapIcon($icon, $rootLevelFolder);
337 'uid' => $folderHashSpecUID,
338 'title' => $rootLevelFolderName,
339 'path' => $rootLevelFolder->getCombinedIdentifier(),
340 'folder' => $rootLevelFolder
343 $this->tree[] = array(
344 'HTML' => $firstHtml,
346 'bank' => $this->bank,
348 'hasSub' => $isOpen && $storageObject->
isBrowsable(),
349 'invertedDepth' => 1000,
354 $this->getFolderTree($rootLevelFolder, 999);
369 public function getFolderTree(Folder $folderObject, $depth = 999, $type =
'')
371 $depth = (int)$depth;
375 if ($folderObject instanceof InaccessibleFolder) {
376 $subFolders = array();
378 $subFolders = $folderObject->getSubfolders();
379 $subFolders = \TYPO3\CMS\Core\Resource\Utility\ListUtility::resolveSpecialFolderNames($subFolders);
380 uksort($subFolders,
'strnatcasecmp');
383 $totalSubFolders = count($subFolders);
385 $subFolderCounter = 0;
388 foreach ($subFolders as $subFolderName => $subFolder) {
391 $this->tree[] = array();
394 $isLocked = $subFolder instanceof InaccessibleFolder;
395 $treeKey = key($this->tree);
397 $this->specUIDmap[$specUID] = $subFolder->getCombinedIdentifier();
400 'path' => $subFolder->getCombinedIdentifier(),
401 'title' => $subFolderName,
402 'folder' => $subFolder
405 if (!$isLocked && $depth > 1 && $this->
expandNext($specUID)) {
406 $nextCount = $this->getFolderTree($subFolder, $depth - 1, $type);
415 if ($this->makeHTML) {
416 $HTML = $this->
PMicon($subFolder, $subFolderCounter, $totalSubFolders, $nextCount, $isOpen);
419 $role = $subFolder->getRole();
421 $row[
'_title'] =
'<strong>' . $subFolderName .
'</strong>';
423 $icon =
'<span title="' . htmlspecialchars($subFolderName) .
'">'
424 . $this->iconFactory->getIconForResource($subFolder,
Icon::SIZE_SMALL, null, array(
'folder-open' => (
bool)$isOpen))
426 $HTML .= $this->
wrapIcon($icon, $subFolder);
429 $this->tree[$treeKey] = array(
432 'hasSub' => $nextCount && $this->
expandNext($specUID),
433 'isFirst' => $subFolderCounter == 1,
435 'invertedDepth' => $depth,
436 'bank' => $this->bank
439 if ($subFolderCounter > 0) {
440 $this->tree[$treeKey][
'isLast'] =
true;
442 return $totalSubFolders;
451 public function printTree($treeItems =
'')
456 $titleLength = (int)$this->BE_USER->uc[
'titleLen'];
457 if (!is_array($treeItems)) {
461 if (empty($treeItems)) {
464 $this->
getLanguageService()->sL(
'LLL:EXT:backend/Resources/Private/Language/locallang.xlf:foldertreeview.noFolders.message'),
465 $this->
getLanguageService()->sL(
'LLL:EXT:backend/Resources/Private/Language/locallang.xlf:foldertreeview.noFolders.title'),
468 return $message->render();
471 $expandedFolderHash =
'';
472 $invertedDepthOfAjaxRequestedItem = 0;
473 $out =
'<ul class="list-tree list-tree-root">';
475 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
477 if ($expandCollapseCommand == 1) {
485 $closeDepth = array();
486 foreach ($treeItems as $treeItem) {
488 $folderObject = $treeItem[
'row'][
'folder'];
489 $classAttr = $treeItem[
'row'][
'_CSSCLASS'];
490 $folderIdentifier = $folderObject->getCombinedIdentifier();
493 $idAttr = htmlspecialchars($this->domIdPrefix . $this->
getId($folderObject) .
'_' . $treeItem[
'bank']);
497 if ($treeItem[
'isFirst'] && !$doCollapse && !($doExpand && $isExpandedFolderIdentifier)) {
498 $itemHTML =
'<ul class="list-tree">';
501 if ($treeItem[
'hasSub']) {
502 $classAttr .=
' list-tree-control-open';
505 <li id="' . $idAttr .
'" ' . ($classAttr ?
' class="' . trim($classAttr) .
'"' :
'') .
'><span class="list-tree-group">' . $treeItem[
'HTML'] . $this->
wrapTitle($this->
getTitleStr($treeItem[
'row'], $titleLength), $folderObject, $treeItem[
'bank']) .
'</span>';
506 if (!$treeItem[
'hasSub']) {
507 $itemHTML .=
'</li>';
511 if ($treeItem[
'isLast'] && !($doExpand && $isExpandedFolderIdentifier)) {
512 $closeDepth[$treeItem[
'invertedDepth']] = 1;
516 if ($treeItem[
'isLast'] && !$treeItem[
'hasSub'] && !$doCollapse && !($doExpand && $isExpandedFolderIdentifier)) {
517 for ($i = $treeItem[
'invertedDepth']; $closeDepth[$i] == 1; $i++) {
519 $itemHTML .=
'</ul></li>';
523 if ($doCollapse && $isExpandedFolderIdentifier) {
524 $this->ajaxStatus =
true;
528 if ($doExpand && $isExpandedFolderIdentifier) {
529 $ajaxOutput .= $itemHTML;
530 $invertedDepthOfAjaxRequestedItem = $treeItem[
'invertedDepth'];
531 }
elseif ($invertedDepthOfAjaxRequestedItem) {
532 if ($treeItem[
'invertedDepth'] && ($treeItem[
'invertedDepth'] < $invertedDepthOfAjaxRequestedItem)) {
533 $ajaxOutput .= $itemHTML;
535 $this->ajaxStatus =
true;
543 $this->ajaxStatus =
true;
561 return count($subFolders);
573 $this->stored = unserialize($this->BE_USER->uc[
'browseTrees'][$this->treeName]);
581 if (in_array($storageHashNumber, $this->storageHashNumbers)) {
582 if ($doExpand == 1) {
584 $this->stored[$storageHashNumber][$numericFolderHash] = 1;
587 unset($this->stored[$storageHashNumber][$numericFolderHash]);
604 if (!$this->storageHashNumbers) {
605 $this->storageHashNumbers = array();
608 foreach ($this->storages as $storageUid => $storage) {
609 $fileMounts = $storage->getFileMounts();
610 if (!empty($fileMounts)) {
611 foreach ($fileMounts as $fileMount) {
613 $this->storageHashNumbers[$storageUid . $fileMount[
'folder']->getCombinedIdentifier()] = $nkey;
616 $folder = $storage->getRootLevelFolder();
618 $this->storageHashNumbers[$storageUid . $folder->getCombinedIdentifier()] = $nkey;
622 if ($storageObject) {
623 if ($startingPointFolder) {
624 return $this->storageHashNumbers[$storageObject->
getUid() . $startingPointFolder->getCombinedIdentifier()];
626 return $this->storageHashNumbers[$storageObject->
getUid()];
649 if (($PMpos = strpos($PM,
'#')) !==
false) {
650 $PM = substr($PM, 0, $PMpos);
654 list($mountKey, $doExpand, $folderIdentifier) = explode(
'_', $PM, 3);
678 $mountKey !== null ? $mountKey : $this->bank,
679 $doExpand == 1 ? 1 : 0,
683 return implode(
'_', $parts);