/**
  * Save tax node form
  *
  */
 public function saveTaxNode()
 {
     global $tpl, $lng, $ilCtrl;
     $this->initTaxNodeForm("create");
     if ($this->form->checkInput()) {
         $tax = $this->getCurrentTaxonomy();
         // create node
         include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php";
         $node = new ilTaxonomyNode();
         $node->setTitle($this->form->getInput("title"));
         $tax = $this->getCurrentTaxonomy();
         if ($tax->getSortingMode() == ilObjTaxonomy::SORT_MANUAL) {
             $order_nr = $this->form->getInput("order_nr");
         }
         if ($order_nr === "") {
             $order_nr = ilTaxonomyNode::getNextOrderNr($tax->getId(), (int) $_GET["tax_node"]);
         }
         //echo $order_nr; exit;
         $node->setOrderNr($order_nr);
         $node->setTaxonomyId($tax->getId());
         $node->create();
         // put in tree
         ilTaxonomyNode::putInTree($tax->getId(), $node, (int) $_GET["tax_node"]);
         ilTaxonomyNode::fixOrderNumbers($tax->getId(), (int) $_GET["tax_node"]);
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
         $ilCtrl->redirect($this, "listNodes");
     } else {
         $this->form->setValuesByPost();
         $tpl->setContent($this->form->getHtml());
     }
 }
 /**
  * Copy taxonomy node
  */
 function copy($a_tax_id = 0)
 {
     $taxn = new ilTaxonomyNode();
     $taxn->setTitle($this->getTitle());
     $taxn->setType($this->getType());
     $taxn->setOrderNr($this->getOrderNr());
     if ($a_tax_id == 0) {
         $taxn->setTaxonomyId($this->getTaxonomyId());
     } else {
         $taxn->setTaxonomyId($a_tax_id);
     }
     $taxn->create();
     return $taxn;
 }
 /**
  * Create a new taxonomy
  */
 function doCreate()
 {
     global $ilDB;
     // create tax data record
     $ilDB->manipulate("INSERT INTO tax_data " . "(id, sorting_mode, item_sorting) VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote((int) $this->getSortingMode(), "integer") . "," . $ilDB->quote((int) $this->getItemSorting(), "integer") . ")");
     // create the taxonomy tree
     include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php";
     $node = new ilTaxonomyNode();
     $node->setType("");
     // empty type
     $node->setTitle("Root node for taxonomy " . $this->getId());
     $node->setTaxonomyId($this->getId());
     $node->create();
     include_once "./Services/Taxonomy/classes/class.ilTaxonomyTree.php";
     $tax_tree = new ilTaxonomyTree($this->getId());
     $tax_tree->addTree($this->getId(), $node->getId());
 }
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     //echo $a_entity;
     //var_dump($a_rec);
     switch ($a_entity) {
         case "tax":
             include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php";
             //				if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
             //				{
             //					$newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
             //				}
             //				else
             //				{
             $newObj = new ilObjTaxonomy();
             $newObj->create();
             //				}
             $newObj->setTitle($a_rec["Title"]);
             $newObj->setDescription($a_rec["Description"]);
             $newObj->setSortingMode($a_rec["SortingMode"]);
             $newObj->update();
             $this->current_obj = $newObj;
             $a_mapping->addMapping("Services/Taxonomy", "tax", $a_rec["Id"], $newObj->getId());
             break;
         case "tax_tree":
             switch ($a_rec["Type"]) {
                 case "taxn":
                     $parent = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["Parent"]);
                     $tax_id = $a_mapping->getMapping("Services/Taxonomy", "tax", $a_rec["TaxId"]);
                     if ($parent == 0) {
                         $parent = $this->current_obj->getTree()->readRootId();
                     }
                     $node = new ilTaxonomyNode();
                     $node->setTitle($a_rec["Title"]);
                     $node->setOrderNr($a_rec["OrderNr"]);
                     $node->setTaxonomyId($tax_id);
                     $node->create();
                     ilTaxonomyNode::putInTree($tax_id, $node, (int) $parent, "", $a_rec["OrderNr"]);
                     $a_mapping->addMapping("Services/Taxonomy", "tax_tree", $a_rec["Child"], $node->getId());
                     break;
             }
         case "tax_node_assignment":
             $new_item_id = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_item", $a_rec["Component"] . ":" . $a_rec["ItemType"] . ":" . $a_rec["ItemId"]);
             $new_node_id = (int) $a_mapping->getMapping("Services/Taxonomy", "tax_tree", $a_rec["NodeId"]);
             if ($new_item_id > 0 && $new_node_id > 0) {
                 include_once "./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php";
                 $node_ass = new ilTaxNodeAssignment($a_rec["Component"], $a_rec["ItemType"], $this->current_obj->getId());
                 $node_ass->addAssignment($new_node_id, $new_item_id);
             }
             break;
         case "tax_usage":
             $usage = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $a_rec["ObjId"]);
             if ($usage != "") {
                 $usage .= ":";
             }
             $a_mapping->addMapping("Services/Taxonomy", "tax_usage_of_obj", $a_rec["ObjId"], $this->current_obj->getId());
             break;
     }
 }