/** * Initializes the NestedSet object * which is needed to manage the news categories. * * @access public */ public function __construct() { global $objDatabase; //nestedSet setup $arrTableStructure = array('catid' => 'id', 'parent_id' => 'rootid', 'left_id' => 'l', 'right_id' => 'r', 'sorting' => 'norder', 'level' => 'level'); $objNs = new \DB_NestedSet($arrTableStructure); $this->objNestedSet = $objNs->factory('ADODB', $objDatabase, $arrTableStructure); $this->objNestedSet->setAttr(array('node_table' => DBPREFIX . 'module_news_categories', 'lock_table' => DBPREFIX . 'module_news_categories_locks')); if (count($rootNodes = $this->objNestedSet->getRootNodes()) > 0) { foreach ($rootNodes as $rootNode) { $this->nestedSetRootId = $rootNode->id; break; } } else { // create first entry of sequence table for NestedSet $objResult = $objDatabase->SelectLimit("SELECT `id` FROM `" . DBPREFIX . "module_news_categories_catid`", 1); if ($objResult->RecordCount() == 0) { $objDatabase->Execute("INSERT INTO `" . DBPREFIX . "module_news_categories_catid` VALUES (0)"); } $this->nestedSetRootId = $this->objNestedSet->createRootNode(array(), false, false); } }