5 require_once
"./Services/Object/classes/class.ilObject2.php";
49 $this->sorting_mode = $a_val;
59 return $this->sorting_mode;
70 if ($this->
getId() > 0)
72 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
99 $ilDB->manipulate(
"INSERT INTO tax_data ".
100 "(id, sorting_mode) VALUES (".
101 $ilDB->quote($this->getId(),
"integer").
",".
102 $ilDB->quote((
int) $this->getSortingMode(),
"integer").
106 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
109 $node->setTitle(
"Root node for taxonomy ".$this->
getId());
110 $node->setTaxonomyId($this->
getId());
112 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
114 $tax_tree->addTree($this->
getId(), $node->getId());
127 $a_new_obj->setTitle($this->
getTitle());
131 $this->node_mapping = array();
133 $this->
cloneNodes($a_new_obj, $a_new_obj->getTree()->readRootId(),
134 $this->
getTree()->readRootId());
143 function cloneNodes($a_new_obj, $a_target_parent, $a_source_parent)
145 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
148 $nodes = $this->
getTree()->getChilds($a_source_parent);
149 foreach ($nodes as $node)
151 switch ($node[
"type"])
155 $new_node = $tax_node->copy($a_new_obj->getId());
160 $new_node, $a_target_parent);
162 $this->node_mapping[$node[
"child"]] = $new_node->getId();
165 $this->
cloneNodes($a_new_obj, $new_node->getId(), $node[
"child"]);
183 $subtree = $tree->getSubTreeIds($tree->readRootId());
184 $subtree[] = $tree->readRootId();
188 $root_node_data = $tree->getNodeData($tree->readRootId());
191 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
192 foreach ($subtree as $node_id)
200 $tree->deleteTree($root_node_data);
203 $ilDB->manipulate(
"DELETE FROM tax_data WHERE ".
204 " id = ".$ilDB->quote($this->getId(),
"integer")
217 $set = $ilDB->query(
"SELECT * FROM tax_data ".
218 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
220 $rec = $ilDB->fetchAssoc($set);
231 $ilDB->manipulate(
"UPDATE tax_data SET ".
232 " sorting_mode = ".$ilDB->quote((
int) $this->getSortingMode(),
"integer").
233 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
247 $lng->loadLanguageModule(
"tax");
261 $ilDB->replace(
"tax_usage",
262 array(
"tax_id" => array(
"integer", $a_tax_id),
263 "obj_id" => array(
"integer", $a_obj_id)
279 $set = $ilDB->query(
"SELECT tax_id FROM tax_usage ".
280 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
283 while ($rec = $ilDB->fetchAssoc($set))
285 $tax[] = $rec[
"tax_id"];
300 $ilDB->manipulate(
"DELETE FROM tax_usage WHERE ".
301 " tax_id = ".$ilDB->quote($a_id,
"integer")
315 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
318 $sub_nodes = $tree->getSubTreeIds($a_node);
319 $sub_nodes[] = $a_node;
320 include_once(
"./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
332 static protected function lookup($a_field, $a_id)
336 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM tax_data ".
337 " WHERE id = ".$ilDB->quote($a_id,
"integer")
339 $rec = $ilDB->fetchAssoc($set);
341 return $rec[$a_field];