/**
  * Returns the actions for the given node information's
  *
  * @param stdClass $node
  * @return array
  */
 public function getActionsForNodeArray($nodeData)
 {
     /** @var $node t3lib_tree_pagetree_Node */
     $node = t3lib_div::makeInstance('t3lib_tree_pagetree_Node', (array) $nodeData);
     $node->setRecord(t3lib_tree_pagetree_Commands::getNodeRecord($node->getId()));
     $this->initDataProvider();
     $this->dataProvider->setContextMenuType('table.' . $node->getType());
     $actionCollection = $this->dataProvider->getActionsForNode($node);
     if ($actionCollection instanceof t3lib_contextmenu_ActionCollection) {
         $actions = $actionCollection->toArray();
     }
     return $actions;
 }
 /**
  * Delete the page
  *
  * @param stdClass $nodeData
  * @return array
  */
 public function deleteNode($nodeData)
 {
     /** @var $node t3lib_tree_pagetree_Node */
     $node = t3lib_div::makeInstance('t3lib_tree_pagetree_Node', (array) $nodeData);
     try {
         t3lib_tree_pagetree_Commands::deleteNode($node);
         $returnValue = array();
         if ($GLOBALS['BE_USER']->workspace) {
             $record = t3lib_tree_pagetree_Commands::getNodeRecord($node->getId());
             if ($record['_ORIG_uid']) {
                 $newNode = t3lib_tree_pagetree_Commands::getNewNode($record);
                 $returnValue = $newNode->toArray();
             }
         }
     } catch (Exception $exception) {
         $returnValue = array('success' => FALSE, 'message' => $exception->getMessage());
     }
     return $returnValue;
 }
 /**
  * Returns a node collection of filtered nodes
  *
  * @param t3lib_tree_Node $node
  * @param string $searchFilter
  * @param int $mountPoint
  * @return void
  */
 public function getFilteredNodes(t3lib_tree_Node $node, $searchFilter, $mountPoint = 0)
 {
     /** @var $nodeCollection t3lib_tree_pagetree_NodeCollection */
     $nodeCollection = t3lib_div::makeInstance('t3lib_tree_pagetree_NodeCollection');
     $records = $this->getSubpages(-1, $searchFilter);
     if (!is_array($records) || !count($records)) {
         return $nodeCollection;
     }
     $isNumericSearchFilter = is_numeric($searchFilter) && $searchFilter > 0;
     $nodeId = intval($node->getId());
     foreach ($records as $record) {
         $record = t3lib_tree_pagetree_Commands::getNodeRecord($record['uid']);
         if (intval($record['pid']) === -1 || in_array($record['uid'], $this->hiddenRecords)) {
             continue;
         }
         $rootline = t3lib_BEfunc::BEgetRootLine($record['uid'], ' AND uid != ' . $nodeId);
         $rootline = array_reverse($rootline);
         if ($nodeId === 0) {
             array_shift($rootline);
         }
         $reference = $nodeCollection;
         $inFilteredRootline = FALSE;
         $amountOfRootlineElements = count($rootline);
         for ($i = 0; $i < $amountOfRootlineElements; ++$i) {
             $rootlineElement = $rootline[$i];
             if (intval($rootlineElement['pid']) === $nodeId) {
                 $inFilteredRootline = TRUE;
             }
             if (!$inFilteredRootline) {
                 continue;
             }
             $rootlineElement = t3lib_tree_pagetree_Commands::getNodeRecord($rootlineElement['uid']);
             $ident = intval($rootlineElement['sorting']) . intval($rootlineElement['uid']);
             if ($reference->offsetExists($ident)) {
                 /** @var $refNode t3lib_tree_pagetree_Node */
                 $refNode = $reference->offsetGet($ident);
                 $refNode->setExpanded(TRUE);
                 $refNode->setLeaf(FALSE);
                 $reference = $refNode->getChildNodes();
                 continue;
             }
             $refNode = t3lib_tree_pagetree_Commands::getNewNode($rootlineElement, $mountPoint);
             $replacement = '<span class="typo3-pagetree-filteringTree-highlight">$1</span>';
             if ($isNumericSearchFilter && intval($rootlineElement['uid']) === intval($searchFilter)) {
                 $text = str_replace('$1', $refNode->getText(), $replacement);
             } else {
                 $text = preg_replace('/(' . $searchFilter . ')/i', $replacement, $refNode->getText());
             }
             $refNode->setText($text, $refNode->getTextSourceField(), $refNode->getPrefix(), $refNode->getSuffix());
             /** @var $childCollection t3lib_tree_pagetree_NodeCollection */
             $childCollection = t3lib_div::makeInstance('t3lib_tree_pagetree_NodeCollection');
             if ($i + 1 >= $amountOfRootlineElements) {
                 $childNodes = $this->getNodes($refNode, $mountPoint);
                 foreach ($childNodes as $childNode) {
                     /** @var $childNode t3lib_tree_pagetree_Node */
                     $childRecord = $childNode->getRecord();
                     $childIdent = intval($childRecord['sorting']) . intval($childRecord['uid']);
                     $childCollection->offsetSet($childIdent, $childNode);
                 }
                 $refNode->setChildNodes($childNodes);
             }
             $refNode->setChildNodes($childCollection);
             $reference->offsetSet($ident, $refNode);
             $reference->ksort();
             $reference = $childCollection;
         }
     }
     return $nodeCollection;
 }
 /**
  * Returns the mount point path for a temporary mount or the given id
  *
  * @static
  * @param int $uid
  * @return void
  */
 public static function getMountPointPath($uid = -1)
 {
     if ($uid === -1) {
         $uid = intval($GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint']);
     }
     if ($uid <= 0) {
         return '';
     }
     $useNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
     $rootline = array_reverse(t3lib_BEfunc::BEgetRootLine($uid));
     array_shift($rootline);
     $path = array();
     foreach ($rootline as $rootlineElement) {
         $record = t3lib_tree_pagetree_Commands::getNodeRecord($rootlineElement['uid']);
         $text = $record['title'];
         if ($useNavTitle && trim($record['nav_title']) !== '') {
             $text = $record['nav_title'];
         }
         $path[] = $text;
     }
     return htmlspecialchars('/' . implode('/', $path));
 }