62 $this->storages = $this->BE_USER->getFileStorages();
63 $this->treeName =
'folder';
65 $this->titleAttrib =
'';
66 $this->domIdPrefix =
'folder';
81 public function PMicon(\
TYPO3\CMS\Core\Resource\Folder $folderObject, $subFolderCounter, $totalSubFolders, $nextCount, $isExpanded) {
82 $PM = $nextCount ? ($isExpanded ?
'minus' :
'plus') :
'join';
83 $BTM = $subFolderCounter == $totalSubFolders ?
'bottom' :
'';
84 $icon =
'<img' .
IconUtility::skinImg($this->backPath, (
'gfx/ol/' . $PM . $BTM .
'.gif'),
'width="18" height="16"') .
' alt="" />';
103 if (empty($this->scope)) {
104 $this->scope = array(
105 'class' => get_class($this),
106 'script' => $this->thisScript,
107 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
109 'mode' =>
$GLOBALS[
'SOBE']->browser->mode,
110 'act' =>
$GLOBALS[
'SOBE']->browser->act,
115 if ($this->thisScript) {
117 $scopeData = serialize($this->scope);
120 return '<a class="pm" onclick="' . $js .
'">' . $icon .
'</a>';
134 public function wrapIcon($icon, \
TYPO3\CMS\Core\Resource\Folder $folderObject) {
138 if (!$this->ext_IconMode) {
140 if (!$folderObject instanceof \
TYPO3\CMS\Core\Resource\InaccessibleFolder) {
141 $theFolderIcon =
$GLOBALS[
'TBE_TEMPLATE']->wrapClickMenuOnIcon($icon, $folderObject->getCombinedIdentifier(),
'', 0);
143 } elseif ($this->ext_IconMode ===
'titlelink') {
144 $aOnClick =
'return jumpTo(\'' . $this->
getJumpToParam($folderObject) .
'\',
this,\
'' . $this->domIdPrefix . $this->
getId($folderObject) .
'\',
' . $this->bank . ');
'; 145 $theFolderIcon = '<a href=
"#" onclick=
"' . htmlspecialchars($aOnClick) . '">
' . $icon . '</a>
'; 147 return $theFolderIcon; 159 public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject, $bank = 0) { 160 // Check storage access to wrap with click menu 161 if ($folderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) { 164 $aOnClick = 'return jumpTo(\
'' . $this->
getJumpToParam($folderObject) .
'\',
this, \
'' . $this->domIdPrefix . $this->
getId($folderObject) .
'\',
' . $bank . ');
'; 165 $CSM = ' oncontextmenu=
"' . htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('', $folderObject->getCombinedIdentifier(), '', 0, ('&bank=' . $this->bank), '', TRUE)) . '"'; 167 return '<a href=
"#" title=
"' . htmlspecialchars($title) . '" onclick=
"' . htmlspecialchars($aOnClick) . '"' . $CSM . '>
' . $title . '</a>
'; 176 public function getId(\TYPO3\CMS\Core\Resource\Folder $folderObject) { 177 return GeneralUtility::md5Int($folderObject->getCombinedIdentifier()); 186 public function getJumpToParam(\TYPO3\CMS\Core\Resource\Folder $folderObject) { 187 return rawurlencode($folderObject->getCombinedIdentifier()); 198 public function getTitleStr($row, $titleLen = 30) { 199 return $row['_title
'] ?: parent::getTitleStr($row, $titleLen); 209 public function getTitleAttrib(\TYPO3\CMS\Core\Resource\Folder $folderObject) { 210 return htmlspecialchars($folderObject->getName()); 219 public function getBrowsableTree() { 220 // Get stored tree structure AND updating it if needed according to incoming PM GET var. 221 $this->initializePositionSaving(); 223 $treeItems = array(); 225 foreach ($this->storages as $storageObject) { 226 $this->getBrowseableTreeForStorage($storageObject); 228 $treeItems = array_merge($treeItems, $this->tree); 229 // if this is an AJAX call, don't run through all mounts, only
231 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
244 public function getBrowseableTreeForStorage(\
TYPO3\CMS\Core\Resource\ResourceStorage $storageObject) {
246 $fileMounts = $storageObject->getFileMounts();
247 $rootLevelFolders = array();
248 if (count($fileMounts)) {
249 foreach ($fileMounts as $fileMountInfo) {
250 $rootLevelFolders[] = array(
251 'folder' => $fileMountInfo[
'folder'],
252 'name' => $fileMountInfo[
'title']
255 } elseif ($this->BE_USER->isAdmin()) {
256 $rootLevelFolders[] = array(
257 'folder' => $storageObject->getRootLevelFolder(),
258 'name' => $storageObject->getName()
264 foreach ($rootLevelFolders as $rootLevelFolderInfo) {
266 $rootLevelFolder = $rootLevelFolderInfo[
'folder'];
267 $rootLevelFolderName = $rootLevelFolderInfo[
'name'];
269 $this->specUIDmap[$folderHashSpecUID] = $rootLevelFolder->getCombinedIdentifier();
273 $this->bank = $storageHashNumber;
274 $isOpen = $this->stored[$storageHashNumber][$folderHashSpecUID] ||
$this->expandFirst;
279 } elseif (!$isOpen) {
280 $rootIcon =
'plusonly';
282 $rootIcon =
'minusonly';
284 $icon =
'<img' .
IconUtility::skinImg($this->backPath, (
'gfx/ol/' . $rootIcon .
'.gif')) .
' alt="" />';
286 if (in_array($rootIcon, array(
'minusonly',
'plusonly'))) {
293 if ($storageObject->isOnline() === FALSE) {
294 $rootLevelFolderName .=
' (' . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_mod_file.xlf:sys_file_storage.isOffline') .
')';
299 'uid' => $folderHashSpecUID,
300 'title' => $rootLevelFolderName,
301 'path' => $rootLevelFolder->getCombinedIdentifier(),
302 'folder' => $rootLevelFolder
305 $this->tree[] = array(
306 'HTML' => $firstHtml,
308 'bank' => $this->bank,
310 'hasSub' => $isOpen && $storageObject->isBrowsable()
313 if ($isOpen && $storageObject->isBrowsable()) {
329 public function getFolderTree(\
TYPO3\CMS\Core\Resource\Folder $folderObject, $depth = 999, $type =
'') {
330 $depth = (int)$depth;
334 if ($folderObject instanceof \
TYPO3\CMS\Core\Resource\InaccessibleFolder) {
335 $subFolders = array();
337 $subFolders = $folderObject->getSubfolders();
338 $subFolders = \TYPO3\CMS\Core\Resource\Utility\ListUtility::resolveSpecialFolderNames($subFolders);
339 uksort($subFolders,
'strnatcasecmp');
342 $totalSubFolders = count($subFolders);
344 $subFolderCounter = 0;
345 foreach ($subFolders as $subFolderName => $subFolder) {
348 $this->tree[] = array();
351 $isLocked = $subFolder instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder;
352 $treeKey = key($this->tree);
354 $this->specUIDmap[$specUID] = $subFolder->getCombinedIdentifier();
357 'path' => $subFolder->getCombinedIdentifier(),
358 'title' => $subFolderName,
359 'folder' => $subFolder
362 if (!$isLocked && $depth > 1 && $this->
expandNext($specUID)) {
363 $nextCount = $this->
getFolderTree($subFolder, $depth - 1, $type);
372 if ($this->makeHTML) {
373 $HTML = $this->
PMicon($subFolder, $subFolderCounter, $totalSubFolders, $nextCount, $isOpen);
376 $role = $subFolder->getRole();
378 $row[
'_title'] =
'<strong>' . $subFolderName .
'</strong>';
381 $HTML .= $this->
wrapIcon($icon, $subFolder);
384 $this->tree[$treeKey] = array(
387 'hasSub' => $nextCount && $this->
expandNext($specUID),
388 'isFirst' => $subFolderCounter == 1,
390 'invertedDepth' => $depth,
391 'bank' => $this->bank
394 if ($subFolderCounter > 0) {
395 $this->tree[$treeKey][
'isLast'] = TRUE;
397 return $totalSubFolders;
406 public function printTree($treeItems =
'') {
410 $titleLength = (int)$this->BE_USER->uc[
'titleLen'];
411 if (!is_array($treeItems)) {
415 if (empty($treeItems)) {
417 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
418 $this->
getLanguageService()->sL(
'LLL:EXT:backend/Resources/Private/Language/locallang_errors.xlf:foldertreeview.noFolders.message'),
419 $this->
getLanguageService()->sL(
'LLL:EXT:backend/Resources/Private/Language/locallang_errors.xlf:foldertreeview.noFolders.title'),
422 return $message->render();
426 <!-- TYPO3 folder tree structure. --> 427 <ul class="tree" id="treeRoot"> 430 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
432 if ($expandCollapseCommand == 1) {
434 $invertedDepthOfAjaxRequestedItem = 0;
442 $closeDepth = array();
443 foreach ($treeItems as $treeItem) {
445 $folderObject = $treeItem[
'row'][
'folder'];
446 $classAttr = $treeItem[
'row'][
'_CSSCLASS'];
447 $folderIdentifier = $folderObject->getCombinedIdentifier();
450 $idAttr = htmlspecialchars($this->domIdPrefix . $this->
getId($folderObject) .
'_' . $treeItem[
'bank']);
454 if ($treeItem[
'isFirst'] && !$doCollapse && !($doExpand && $isExpandedFolderIdentifier)) {
459 if ($treeItem[
'hasSub']) {
460 $classAttr .=
' expanded';
462 if ($treeItem[
'isLast']) {
463 $classAttr .=
' last';
466 <li id="' . $idAttr .
'" ' . ($classAttr ?
' class="' . trim($classAttr) .
'"' :
'') .
'><div class="treeLinkItem">' . $treeItem[
'HTML'] . $this->
wrapTitle($this->
getTitleStr($treeItem[
'row'], $titleLength), $folderObject, $treeItem[
'bank']) .
'</div>';
467 if (!$treeItem[
'hasSub']) {
473 if ($treeItem[
'isLast'] && !($doExpand && $isExpandedFolderIdentifier)) {
474 $closeDepth[$treeItem[
'invertedDepth']] = 1;
478 if ($treeItem[
'isLast'] && !$treeItem[
'hasSub'] && !$doCollapse && !($doExpand && $isExpandedFolderIdentifier)) {
479 for ($i = $treeItem[
'invertedDepth']; $closeDepth[$i] == 1; $i++) {
481 $itemHTML .=
'</ul></li> 486 if ($doCollapse && $isExpandedFolderIdentifier) {
487 $this->ajaxStatus = TRUE;
491 if ($doExpand && $isExpandedFolderIdentifier) {
492 $ajaxOutput .= $itemHTML;
493 $invertedDepthOfAjaxRequestedItem = $treeItem[
'invertedDepth'];
494 } elseif ($invertedDepthOfAjaxRequestedItem) {
495 if ($treeItem[
'invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {
496 $ajaxOutput .= $itemHTML;
498 $this->ajaxStatus = TRUE;
506 $this->ajaxStatus = TRUE;
522 $subFolders = $folderObject->getSubfolders();
523 return count($subFolders);
535 $this->stored = unserialize($this->BE_USER->uc[
'browseTrees'][$this->treeName]);
543 if (in_array($storageHashNumber, $this->storageHashNumbers)) {
544 if ($doExpand == 1) {
546 $this->stored[$storageHashNumber][$numericFolderHash] = 1;
549 unset($this->stored[$storageHashNumber][$numericFolderHash]);
564 if (!$this->storageHashNumbers) {
565 $this->storageHashNumbers = array();
568 foreach ($this->storages as $storageUid => $storage) {
569 $fileMounts = $storage->getFileMounts();
570 if (count($fileMounts)) {
571 foreach ($fileMounts as $fileMount) {
573 $this->storageHashNumbers[$storageUid . $fileMount[
'folder']->getCombinedIdentifier()] = $nkey;
576 $folder = $storage->getRootLevelFolder();
578 $this->storageHashNumbers[$storageUid . $folder->getCombinedIdentifier()] = $nkey;
582 if ($storageObject) {
583 if ($startingPointFolder) {
584 return $this->storageHashNumbers[$storageObject->getUid() . $startingPointFolder->getCombinedIdentifier()];
586 return $this->storageHashNumbers[$storageObject->getUid()];
608 if (($PMpos = strpos($PM,
'#')) !== FALSE) {
609 $PM = substr($PM, 0, $PMpos);
613 list($mountKey, $doExpand, $folderIdentifier) = explode(
'_', $PM, 3);
635 $mountKey !== NULL ? $mountKey : $this->bank,
636 $doExpand == 1 ? 1 : 0,
640 return implode(
'_', $parts);
PMicon(\TYPO3\CMS\Core\Resource\Folder $folderObject, $subFolderCounter, $totalSubFolders, $nextCount, $isExpanded)
static skinImg($backPath, $src, $wHattribs='', $outputMode=0)
getShortHashNumberForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject=NULL, \TYPO3\CMS\Core\Resource\Folder $startingPointFolder=NULL)
generateExpandCollapseParameter($mountKey=NULL, $doExpand=FALSE, \TYPO3\CMS\Core\Resource\Folder $folderObject=NULL, $treeName=NULL)
static getSpriteIconForResource(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, array $options=array(), array $overlays=array())
getTitleStr($row, $titleLen=30)
static quoteJSvalue($value)
getFolderTree(\TYPO3\CMS\Core\Resource\Folder $folderObject, $depth=999, $type='')
PM_ATagWrap($icon, $cmd, $bMark='')
static hmac($input, $additionalSecret='')
static makeInstance($className)
getId(\TYPO3\CMS\Core\Resource\Folder $folderObject)
getNumberOfSubfolders(\TYPO3\CMS\Core\Resource\Folder $folderObject)
evaluateExpandCollapseParameter($PM=NULL)
wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject, $bank=0)
wrapIcon($icon, \TYPO3\CMS\Core\Resource\Folder $folderObject)
if(isset($ajaxID)) if(in_array( $ajaxID, $noUserAjaxIDs))
Re-apply pairs of single-quotes to the text.
initializePositionSaving()
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static revExplode($delimiter, $string, $count=0)
PMiconATagWrap($icon, $cmd, $isExpand=TRUE)
getJumpToParam(\TYPO3\CMS\Core\Resource\Folder $folderObject)