コード例 #1
0
 /**
  * Clone nodes
  *
  * @param
  * @return
  */
 function cloneNodes($a_new_obj, $a_target_parent, $a_source_parent)
 {
     include_once "./Services/Taxonomy/classes/class.ilTaxonomyNode.php";
     // get all childs
     $nodes = $this->getTree()->getChilds($a_source_parent);
     foreach ($nodes as $node) {
         switch ($node["type"]) {
             case "taxn":
                 $tax_node = new ilTaxonomyNode($node["child"]);
                 $new_node = $tax_node->copy($a_new_obj->getId());
                 break;
         }
         ilTaxonomyNode::putInTree($a_new_obj->getId(), $new_node, $a_target_parent);
         $this->node_mapping[$node["child"]] = $new_node->getId();
         // handle childs
         $this->cloneNodes($a_new_obj, $new_node->getId(), $node["child"]);
     }
 }
コード例 #2
0
 /**
  * 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());
     }
 }
コード例 #3
0
 /**
  * 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;
     }
 }