/** * Sets a temporary mount point * * @param stdClass $nodeData * @return array */ public static function setTemporaryMountPoint($nodeData) { /** @var $node \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode */ $node = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode::class, (array) $nodeData); $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint'] = $node->getId(); $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc); return Commands::getMountPointPath(); }
/** * Returns the language labels, sprites and configuration options for the pagetree * * @return void */ public function loadResources() { $file = 'LLL:EXT:lang/locallang_core.xlf:'; $indicators = $this->getIndicators(); $configuration = array('LLL' => array('copyHint' => $GLOBALS['LANG']->sL($file . 'tree.copyHint', TRUE), 'fakeNodeHint' => $GLOBALS['LANG']->sL($file . 'mess.please_wait', TRUE), 'activeFilterMode' => $GLOBALS['LANG']->sL($file . 'tree.activeFilterMode', TRUE), 'dropToRemove' => $GLOBALS['LANG']->sL($file . 'tree.dropToRemove', TRUE), 'buttonRefresh' => $GLOBALS['LANG']->sL($file . 'labels.refresh', TRUE), 'buttonNewNode' => $GLOBALS['LANG']->sL($file . 'tree.buttonNewNode', TRUE), 'buttonFilter' => $GLOBALS['LANG']->sL($file . 'tree.buttonFilter', TRUE), 'dropZoneElementRemoved' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRemoved', TRUE), 'dropZoneElementRestored' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored', TRUE), 'searchTermInfo' => $GLOBALS['LANG']->sL($file . 'tree.searchTermInfo', TRUE), 'temporaryMountPointIndicatorInfo' => $GLOBALS['LANG']->sl($file . 'labels.temporaryDBmount', TRUE), 'deleteDialogTitle' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:deleteItem', TRUE), 'deleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:deleteWarning', TRUE), 'recursiveDeleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:recursiveDeleteWarning', TRUE)), 'Configuration' => array('hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'), 'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(4), 'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == TRUE, 'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu'), 'indicator' => $indicators['html'], 'temporaryMountPoint' => Commands::getMountPointPath()), 'Sprites' => array('Filter' => IconUtility::getSpriteIconClasses('actions-system-tree-search-open'), 'NewNode' => IconUtility::getSpriteIconClasses('actions-page-new'), 'Refresh' => IconUtility::getSpriteIconClasses('actions-system-refresh'), 'InputClear' => IconUtility::getSpriteIconClasses('actions-input-clear'), 'TrashCan' => IconUtility::getSpriteIconClasses('actions-edit-delete'), 'TrashCanRestore' => IconUtility::getSpriteIconClasses('actions-edit-restore'), 'Info' => IconUtility::getSpriteIconClasses('actions-document-info'))); return $configuration; }
/** * Returns the page tree mounts for the current user * * Note: If you add the search filter parameter, the nodes will be filtered by this string. * * @param string $searchFilter * @return \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection */ public function getTreeMounts($searchFilter = '') { /** @var $nodeCollection \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection */ $nodeCollection = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection::class); $isTemporaryMountPoint = false; $rootNodeIsVirtual = false; $mountPoints = (int) $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint']; if (!$mountPoints) { $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts()); $mountPoints = array_unique($mountPoints); if (!in_array(0, $mountPoints)) { $rootNodeIsVirtual = true; // use a virtual root // the real mountpoints will be fetched in getNodes() then // since those will be the "subpages" of the virtual root $mountPoints = [0]; } } else { $isTemporaryMountPoint = true; $mountPoints = [$mountPoints]; } if (empty($mountPoints)) { return $nodeCollection; } foreach ($mountPoints as $mountPoint) { if ($mountPoint === 0) { $sitename = 'TYPO3'; if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] !== '') { $sitename = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } $record = ['uid' => 0, 'title' => $sitename]; $subNode = Commands::getNewNode($record); $subNode->setLabelIsEditable(false); if ($rootNodeIsVirtual) { $subNode->setType('virtual_root'); $subNode->setIsDropTarget(false); } else { $subNode->setType('pages_root'); $subNode->setIsDropTarget(true); } } else { if (in_array($mountPoint, $this->hiddenRecords)) { continue; } $record = $this->getRecordWithWorkspaceOverlay($mountPoint); if (!$record) { continue; } $subNode = Commands::getNewNode($record, $mountPoint); if ($this->showRootlineAboveMounts && !$isTemporaryMountPoint) { $rootline = Commands::getMountPointPath($record['uid']); $subNode->setReadableRootline($rootline); } } if (count($mountPoints) <= 1) { $subNode->setExpanded(true); $subNode->setCls('typo3-pagetree-node-notExpandable'); } $subNode->setIsMountPoint(true); $subNode->setDraggable(false); if ($searchFilter === '') { $childNodes = $this->getNodes($subNode, $mountPoint); } else { $childNodes = $this->getFilteredNodes($subNode, $searchFilter, $mountPoint); $subNode->setExpanded(true); } $subNode->setChildNodes($childNodes); $nodeCollection->append($subNode); } foreach ($this->processCollectionHookObjects as $hookObject) { /** @var $hookObject \TYPO3\CMS\Backend\Tree\Pagetree\CollectionProcessorInterface */ $hookObject->postProcessGetTreeMounts($searchFilter, $nodeCollection); } return $nodeCollection; }
/** * Returns the language labels and configuration options for the pagetree * * @return array */ public function loadResources() { $file = 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:'; $indicators = $this->getIndicators(); $configuration = ['LLL' => ['copyHint' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.copyHint')), 'fakeNodeHint' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'mess.please_wait')), 'activeFilterMode' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.activeFilterMode')), 'dropToRemove' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.dropToRemove')), 'buttonRefresh' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'labels.refresh')), 'buttonNewNode' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.buttonNewNode')), 'buttonFilter' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.buttonFilter')), 'dropZoneElementRemoved' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRemoved')), 'dropZoneElementRestored' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored')), 'searchTermInfo' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'tree.searchTermInfo')), 'temporaryMountPointIndicatorInfo' => htmlspecialchars($GLOBALS['LANG']->sL($file . 'labels.temporaryDBmount')), 'deleteDialogTitle' => htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:deleteItem')), 'deleteDialogMessage' => htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:deleteWarning')), 'recursiveDeleteDialogMessage' => htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:recursiveDeleteWarning'))], 'Configuration' => ['hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'), 'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(JsConfirmation::DELETE), 'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == true, 'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu'), 'indicator' => $indicators['html'], 'temporaryMountPoint' => Commands::getMountPointPath()], 'Icons' => ['InputClear' => $this->iconFactory->getIcon('actions-input-clear', Icon::SIZE_SMALL)->render(), 'Close' => $this->iconFactory->getIcon('actions-close', Icon::SIZE_SMALL)->render('inline'), 'TrashCan' => $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline'), 'TrashCanRestore' => $this->iconFactory->getIcon('actions-edit-restore', Icon::SIZE_SMALL)->render('inline'), 'Info' => $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render('inline'), 'NewNode' => $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render(), 'Filter' => $this->iconFactory->getIcon('actions-filter', Icon::SIZE_SMALL)->render(), 'Refresh' => $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render()]]; return $configuration; }
/** * Will create and return the HTML code for a browsable tree * Is based on the mounts found in the internal array ->MOUNTS (set in the constructor) * * @return string HTML code for the browsable tree */ public function getBrowsableTree() { // Get stored tree structure AND updating it if needed according to incoming PM GET var. $this->initializePositionSaving(); // Init done: $treeArr = []; // Traverse mounts: foreach ($this->MOUNTS as $idx => $uid) { // Set first: $this->bank = $idx; $isOpen = $this->stored[$idx][$uid] || $this->expandFirst; // Save ids while resetting everything else. $curIds = $this->ids; $this->reset(); $this->ids = $curIds; // Set PM icon for root of mount: $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $uid . '_' . $this->treeName; $firstHtml = $this->PM_ATagWrap('', $cmd, '', $isOpen); // Preparing rootRec for the mount if ($uid) { $rootRec = $this->getRecord($uid); if (is_array($rootRec)) { $firstHtml .= $this->getIcon($rootRec); } if ($this->ext_showPathAboveMounts) { $mountPointPid = $rootRec['pid']; if ($lastMountPointPid !== $mountPointPid) { $title = \TYPO3\CMS\Backend\Tree\Pagetree\Commands::getMountPointPath($mountPointPid); $this->tree[] = ['isMountPointPath' => true, 'title' => $title]; } $lastMountPointPid = $mountPointPid; } } else { // Artificial record for the tree root, id=0 $rootRec = $this->getRootRecord(); $firstHtml .= $this->getRootIcon($rootRec); } if (is_array($rootRec)) { // In case it was swapped inside getRecord due to workspaces. $uid = $rootRec['uid']; // Add the root of the mount to ->tree $this->tree[] = ['HTML' => $firstHtml, 'row' => $rootRec, 'hasSub' => $isOpen, 'bank' => $this->bank]; // If the mount is expanded, go down: if ($isOpen) { $depthData = '<span class="treeline-icon treeline-icon-clear"></span>'; if ($this->addSelfId) { $this->ids[] = $uid; } $this->getTree($uid, 999, $depthData); } // Add tree: $treeArr = array_merge($treeArr, $this->tree); } } return $this->printTree($treeArr); }
/** * Sets a temporary mount point * * @param \stdClass $nodeData * @return array */ public static function setTemporaryMountPoint($nodeData) { /** @var $node PagetreeNode */ $node = GeneralUtility::makeInstance(PagetreeNode::class, (array) $nodeData); static::getBackendUser()->uc['pageTree_temporaryMountPoint'] = $node->getId(); static::getBackendUser()->writeUC(static::getBackendUser()->uc); return Commands::getMountPointPath(); }