/**
  * A Static method used to build the initial treeview when the page is first displayed
  *
  * @param String div_id - this div in which to display the tree
  * @return Tree - the tree that is built
  */
 function buildTreeView($div_id, $isAlive = true)
 {
     $tree = new Tree($div_id);
     $nodes = array();
     if ($isAlive) {
         $nodes = PackageManager::getCategories('');
     }
     foreach ($nodes as $arr_node) {
         $node = new Node($arr_node['id'], $arr_node['label']);
         $node->dynamicloadfunction = 'PackageManager.loadDataForNodeForPackage';
         $node->expanded = false;
         $node->dynamic_load = true;
         $node->set_property('href', "javascript:PackageManager.catClick('treeview');");
         $tree->add_node($node);
         $node->set_property('description', $arr_node['description']);
     }
     return $tree;
 }
 /**
  * Retrieve a list of categories that are subcategories to the selected category
  *
  * @param id - the id of the parent_category, -1 if this is the root
  * @return array - a list of categories/nodes which are underneath this node
  */
 function getCategories()
 {
     $json = getJSONobj();
     $node_id = '';
     if (isset($_REQUEST['category_id'])) {
         $node_id = nl2br($_REQUEST['category_id']);
     }
     $GLOBALS['log']->debug("NODE ID: " . $node_id);
     $nodes = PackageManager::getCategories($node_id);
     echo 'result = ' . $json->encode(array('nodes' => $nodes));
 }