/**
  * Returns the actions for the given node information's
  *
  * @param stdClass $nodeData
  * @return array
  */
 public function getActionsForNodeArray($nodeData)
 {
     /** @var $node \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode */
     $node = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\Pagetree\\PagetreeNode', (array) $nodeData);
     $node->setRecord(\TYPO3\CMS\Backend\Tree\Pagetree\Commands::getNodeRecord($node->getId()));
     $this->initDataProvider();
     $this->dataProvider->setContextMenuType('table.' . $node->getType());
     $actionCollection = $this->dataProvider->getActionsForNode($node);
     if ($actionCollection instanceof \TYPO3\CMS\Backend\ContextMenu\ContextMenuActionCollection) {
         $actions = $actionCollection->toArray();
     }
     return $actions;
 }
Exemple #2
0
 /**
  * Returns the actions for the given node information's
  *
  * @param \stdClass $nodeData
  * @return array
  */
 public function getActionsForNodeArray($nodeData)
 {
     $node = GeneralUtility::makeInstance(PagetreeNode::class, (array) $nodeData);
     $node->setRecord(Commands::getNodeRecord($node->getId()));
     $this->initDataProvider();
     $this->dataProvider->setContextMenuType('table.' . $node->getType());
     $actionCollection = $this->dataProvider->getActionsForNode($node);
     $actions = [];
     if ($actionCollection instanceof ContextMenuActionCollection) {
         $actions = $actionCollection->toArray();
     }
     return $actions;
 }
 /**
  * Copies the source node directly as the first child of the destination
  * node and returns the created node.
  *
  * @param    integer $nodeUid        The node which will be duplicated.
  * @param    integer $destinationUid The uid of the new node's parent.
  * @return    integer    The uid of the new node's first page.
  */
 private function copyNodeToDestination($nodeUid, $destinationUid)
 {
     $beUserSave = $GLOBALS['BE_USER'];
     $GLOBALS['BE_USER']->uc['copyLevels'] = 100;
     $GLOBALS['BE_USER']->workspace = 0;
     $nodeData = new \stdClass();
     $nodeData->serializeClassName = PagetreeNode::class;
     $nodeData->id = $nodeUid;
     $nodeData->type = 'pages';
     /** @var PagetreeNode $node */
     $node = GeneralUtility::makeInstance(PagetreeNode::class, (array) $nodeData);
     $duplicatedPageUid = Commands::copyNode($node, $destinationUid);
     $GLOBALS['BE_USER'] = $beUserSave;
     return $duplicatedPageUid;
 }
 /**
  * Adds the rootline of a given node to the tree expansion state and adds the node
  * itself as the current selected page. This leads to the expansion and selection of
  * the node in the tree after a refresh.
  *
  * @static
  * @param string $stateId
  * @param int $nodeId
  * @return array
  */
 public static function addRootlineOfNodeToStateHash($stateId, $nodeId)
 {
     $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
     if (empty($mountPoints)) {
         $mountPoints = array(0);
     }
     $mountPoints[] = (int) $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint'];
     $mountPoints = array_unique($mountPoints);
     /** @var $userSettingsController \TYPO3\CMS\Backend\Controller\UserSettingsController */
     $userSettingsController = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\UserSettingsController::class);
     $state = $userSettingsController->process('get', 'BackendComponents.States.' . $stateId);
     if (empty($state)) {
         $state = new \StdClass();
         $state->stateHash = new \StdClass();
     }
     $state->stateHash = (object) $state->stateHash;
     $rootline = BackendUtility::BEgetRootLine($nodeId, '', $GLOBALS['BE_USER']->workspace != 0);
     $rootlineIds = array();
     foreach ($rootline as $pageData) {
         $rootlineIds[] = (int) $pageData['uid'];
     }
     foreach ($mountPoints as $mountPoint) {
         if (!in_array($mountPoint, $rootlineIds, true)) {
             continue;
         }
         $isFirstNode = true;
         foreach ($rootline as $pageData) {
             $node = Commands::getNewNode($pageData, $mountPoint);
             if ($isFirstNode) {
                 $isFirstNode = false;
                 $state->stateHash->lastSelectedNode = $node->calculateNodeId();
             } else {
                 $state->stateHash->{$node->calculateNodeId('')} = 1;
             }
         }
     }
     $userSettingsController->process('set', 'BackendComponents.States.' . $stateId, $state);
     return (array) $state->stateHash;
 }
 /**
  * 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;
 }
Exemple #6
0
 /**
  * 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;
 }
 /**
  * Adds the rootline of a given node to the tree expansion state and adds the node
  * itself as the current selected page. This leads to the expansion and selection of
  * the node in the tree after a refresh.
  *
  * @static
  * @param string $stateId
  * @param integer $nodeId
  * @return array
  */
 public static function addRootlineOfNodeToStateHash($stateId, $nodeId)
 {
     $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
     if (count($mountPoints) == 0) {
         $mountPoints = array(0);
     }
     $mountPoints[] = (int) $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint'];
     $mountPoints = array_unique($mountPoints);
     /** @var $userSettings \TYPO3\CMS\Backend\User\ExtDirect\BackendUserSettingsDataProvider */
     $userSettings = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
     $state = $userSettings->get('BackendComponents.States.' . $stateId);
     $state->stateHash = (object) $state->stateHash;
     $rootline = BackendUtility::BEgetRootLine($nodeId, '', $GLOBALS['BE_USER']->workspace != 0);
     $rootlineIds = array();
     foreach ($rootline as $pageData) {
         $rootlineIds[] = (int) $pageData['uid'];
     }
     foreach ($mountPoints as $mountPoint) {
         if (!in_array($mountPoint, $rootlineIds, TRUE)) {
             continue;
         }
         $isFirstNode = TRUE;
         foreach ($rootline as $pageData) {
             $node = Commands::getNewNode($pageData, $mountPoint);
             if ($isFirstNode) {
                 $isFirstNode = FALSE;
                 $state->stateHash->lastSelectedNode = $node->calculateNodeId();
             } else {
                 $state->stateHash->{$node->calculateNodeId('')} = 1;
             }
         }
     }
     $userSettings->set('BackendComponents.States.' . $stateId, $state);
     return (array) $state->stateHash;
 }
Exemple #8
0
 /**
  * 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;
 }
Exemple #9
0
 /**
  * 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);
 }
 /**
  * Gets the path steps for a given page.
  * This methods considers multiple mount points,
  * thus the returned array is multidimensional, e.g.
  *
  * array(
  *   array('p0', 'p1', 'p13', 'p44'),
  *   array('p0', 'p13-1', 'p44-1'),
  * )
  *
  * @param int $pageId
  * @return array
  */
 public static function getNodePaths($pageId)
 {
     $pagePaths = array();
     $mountPoints = array_map('intval', static::getBackendUser()->returnWebmounts());
     if (empty($mountPoints)) {
         $mountPoints = array(0);
     }
     $mountPoints[] = (int) static::getBackendUser()->uc['pageTree_temporaryMountPoint'];
     $mountPoints = array_unique($mountPoints);
     $rootLine = BackendUtility::BEgetRootLine($pageId, '', (int) static::getBackendUser()->workspace !== 0);
     $rootLineIds = array();
     foreach ($rootLine as $rootLineLevel) {
         $rootLineIds[] = (int) $rootLineLevel['uid'];
     }
     foreach ($mountPoints as $mountPoint) {
         $pagePath = array();
         if (!in_array($mountPoint, $rootLineIds, true)) {
             continue;
         }
         foreach ($rootLine as $rootLineLevel) {
             $node = Commands::getNewNode($rootLineLevel, $mountPoint);
             array_unshift($pagePath, $node->calculateNodeId());
             // Break if mount-point has been reached
             if ($mountPoint === (int) $rootLineLevel['uid']) {
                 break;
             }
         }
         // Attach valid partial root-lines
         if (!empty($pagePath)) {
             if ($mountPoint !== 0) {
                 array_unshift($pagePath, Commands::getNewNode(array('uid' => 0))->calculateNodeId());
             }
             $pagePaths[] = $pagePath;
         }
     }
     return $pagePaths;
 }