/** * addUnitNode * @param integer $intParentId * @param array $arrData * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function addUnitNode($intParentId, $arrData = array()) { try { $intNodeId = null; $this->getUnitTable(); $objNestedSet = new NestedSet($this->objUnitTable); $objNestedSet->setDBFParent('idParentUnit'); $objNestedSet->setDBFRoot('idRootUnit'); /** * if $intParentId == 0, this is a root unit node */ if ($intParentId == 0) { $intNodeId = $objNestedSet->newRootNode($arrData); } else { $intNodeId = $objNestedSet->newLastChild($intParentId, $arrData); } return $intNodeId; } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * addFolderNode * @param integer $intRootId, * @param integer $intParentId * @param array $arrData * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function addFolderNode($intRootId, $intParentId, $arrData = array()) { try { $intFolderId = null; $this->getFolderTable(); $objNestedSet = new NestedSet($this->objFolderTable); $objNestedSet->setDBFParent('idParentFolder'); $objNestedSet->setDBFRoot('idRootLevels'); /** * if $intParentId > 0, has parent folder id */ if ($intParentId != '' && $intParentId > 0) { $intFolderId = $objNestedSet->newLastChild($intParentId, $arrData); } else { $objLastRootFolderData = $this->loadLastRootFolder($intRootId); if (count($objLastRootFolderData) > 0) { $objLastRootFolder = $objLastRootFolderData->current(); $intFolderId = $objNestedSet->newNextSibling($objLastRootFolder->id, $arrData); } else { $intFolderId = $objNestedSet->newRootNodeWithExistingRootId($intRootId, $arrData); } } return $intFolderId; } catch (Exception $exc) { $this->core->logger->err($exc); } }