Ejemplo n.º 1
0
 /**
  * Fetches the sub-nodes of the given node
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode $node
  * @param int $mountPoint
  * @param int $level internally used variable as a recursion limiter
  * @return \TYPO3\CMS\Backend\Tree\TreeNodeCollection
  */
 public function getNodes(\TYPO3\CMS\Backend\Tree\TreeNode $node, $mountPoint = 0, $level = 0)
 {
     /** @var $nodeCollection \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection */
     $nodeCollection = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection::class);
     if ($level >= 99 || $node->getStopPageTree()) {
         return $nodeCollection;
     }
     $isVirtualRootNode = false;
     $subpages = $this->getSubpages($node->getId());
     // check if fetching subpages the "root"-page
     // and in case of a virtual root return the mountpoints as virtual "subpages"
     if ((int) $node->getId() === 0) {
         // check no temporary mountpoint is used
         if (!(int) $GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint']) {
             $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
             $mountPoints = array_unique($mountPoints);
             if (!in_array(0, $mountPoints)) {
                 // using a virtual root node
                 // so then return the mount points here as "subpages" of the first node
                 $isVirtualRootNode = true;
                 $subpages = [];
                 foreach ($mountPoints as $webMountPoint) {
                     $subpages[] = ['uid' => $webMountPoint, 'isMountPoint' => true];
                 }
             }
         }
     }
     if (is_array($subpages) && !empty($subpages)) {
         $lastRootline = [];
         foreach ($subpages as $subpage) {
             if (in_array($subpage['uid'], $this->hiddenRecords)) {
                 continue;
             }
             // must be calculated above getRecordWithWorkspaceOverlay,
             // because the information is lost otherwise
             $isMountPoint = $subpage['isMountPoint'] === true;
             if ($isVirtualRootNode) {
                 $mountPoint = (int) $subpage['uid'];
             }
             $subpage = $this->getRecordWithWorkspaceOverlay($subpage['uid'], true);
             if (!$subpage) {
                 continue;
             }
             $subNode = Commands::getNewNode($subpage, $mountPoint);
             $subNode->setIsMountPoint($isMountPoint);
             if ($isMountPoint && $this->showRootlineAboveMounts) {
                 if ($subpage['pid'] > 0) {
                     $rootline = Commands::getMountPointPath($subpage['pid']);
                 } else {
                     $rootline = Commands::getMountPointPath($subpage['uid']);
                 }
                 if ($lastRootline !== $rootline) {
                     $subNode->setReadableRootline($rootline);
                 }
                 $lastRootline = $rootline;
             }
             if ($this->nodeCounter < $this->nodeLimit) {
                 $childNodes = $this->getNodes($subNode, $mountPoint, $level + 1);
                 $subNode->setChildNodes($childNodes);
                 $this->nodeCounter += $childNodes->count();
             } else {
                 $subNode->setLeaf(!$this->hasNodeSubPages($subNode->getId()));
             }
             if (!$GLOBALS['BE_USER']->isAdmin() && (int) $subpage['editlock'] === 1) {
                 $subNode->setLabelIsEditable(false);
             }
             $nodeCollection->append($subNode);
         }
     }
     foreach ($this->processCollectionHookObjects as $hookObject) {
         /** @var $hookObject \TYPO3\CMS\Backend\Tree\Pagetree\CollectionProcessorInterface */
         $hookObject->postProcessGetNodes($node, $mountPoint, $level, $nodeCollection);
     }
     return $nodeCollection;
 }