5 require_once
"./Services/Object/classes/class.ilObject2.php";
50 $this->sorting_mode = $a_val;
60 return $this->sorting_mode;
70 $this->item_sorting = $a_val;
91 if ($this->
getId() > 0)
93 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
120 $ilDB->manipulate(
"INSERT INTO tax_data ".
121 "(id, sorting_mode, item_sorting) VALUES (".
122 $ilDB->quote($this->getId(),
"integer").
",".
123 $ilDB->quote((
int) $this->getSortingMode(),
"integer").
",".
124 $ilDB->quote((
int) $this->getItemSorting(),
"integer").
128 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
131 $node->setTitle(
"Root node for taxonomy ".$this->
getId());
132 $node->setTaxonomyId($this->
getId());
134 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
136 $tax_tree->addTree($this->
getId(), $node->getId());
149 $a_new_obj->setTitle($this->
getTitle());
153 $this->node_mapping = array();
155 $this->
cloneNodes($a_new_obj, $a_new_obj->getTree()->readRootId(),
156 $this->
getTree()->readRootId());
165 function cloneNodes($a_new_obj, $a_target_parent, $a_source_parent)
167 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
170 $nodes = $this->
getTree()->getChilds($a_source_parent);
171 foreach ($nodes as $node)
173 switch ($node[
"type"])
177 $new_node = $tax_node->copy($a_new_obj->getId());
182 $new_node, $a_target_parent);
184 $this->node_mapping[$node[
"child"]] = $new_node->getId();
187 $this->
cloneNodes($a_new_obj, $new_node->getId(), $node[
"child"]);
205 $subtree = $tree->getSubTreeIds($tree->readRootId());
206 $subtree[] = $tree->readRootId();
210 $root_node_data = $tree->getNodeData($tree->readRootId());
213 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
214 foreach ($subtree as $node_id)
222 $tree->deleteTree($root_node_data);
225 $ilDB->manipulate(
"DELETE FROM tax_data WHERE ".
226 " id = ".$ilDB->quote($this->getId(),
"integer")
239 $set = $ilDB->query(
"SELECT * FROM tax_data ".
240 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
242 $rec = $ilDB->fetchAssoc($set);
254 $ilDB->manipulate(
$t =
"UPDATE tax_data SET ".
255 " sorting_mode = ".$ilDB->quote((
int) $this->getSortingMode(),
"integer").
", ".
256 " item_sorting = ".$ilDB->quote((
int) $this->getItemSorting(),
"integer").
257 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
271 $lng->loadLanguageModule(
"tax");
285 if ($a_tax_id > 0 && $a_obj_id > 0)
287 $ilDB->replace(
"tax_usage",
288 array(
"tax_id" => array(
"integer", $a_tax_id),
289 "obj_id" => array(
"integer", $a_obj_id)
306 $set = $ilDB->query(
"SELECT tax_id FROM tax_usage ".
307 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
310 while ($rec = $ilDB->fetchAssoc($set))
312 if (!$a_include_titles)
314 $tax[] = $rec[
"tax_id"];
318 $tax[] = array(
"tax_id" => $rec[
"tax_id"],
336 $ilDB->manipulate(
"DELETE FROM tax_usage WHERE ".
337 " tax_id = ".$ilDB->quote($a_id,
"integer")
351 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
354 $sub_nodes = $tree->getSubTreeIds($a_node);
355 $sub_nodes[] = $a_node;
356 include_once(
"./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
359 $items = $tn_ass->getAssignmentsOfNode($sub_nodes);
370 static protected function lookup($a_field, $a_id)
374 $set = $ilDB->query(
"SELECT ".$a_field.
" FROM tax_data ".
375 " WHERE id = ".$ilDB->quote($a_id,
"integer")
377 $rec = $ilDB->fetchAssoc($set);
379 return $rec[$a_field];