5 require_once
"./Services/Object/classes/class.ilObject2.php";
29 parent::__construct($a_id,
false);
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"]);
201 self::deleteUsagesOfTaxonomy($this->
getId());
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];
390 return self::lookup(
"sorting_mode", $a_id);
Taxonomy node <-> item assignment.
static deleteUsagesOfTaxonomy($a_id)
Delete all usages of a taxonomy.
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
doRead()
Read taxonomy properties.
setItemSorting($a_val)
Set item sorting.
static _lookupTitle($a_id)
lookup object title
doDelete()
Delete taxonomy object.
setSortingMode($a_val)
Set sorting mode.
doUpdate()
Upate taxonomy properties.
getNodeMapping()
Get node mapping (used after cloning)
static lookupSortingMode($a_id)
Lookup sorting mode.
getItemSorting()
Get item sorting.
Create styles array
The data for the language used.
static lookup($a_field, $a_id)
Lookup.
doCloneObject($a_new_obj, $a_target_id, $a_copy_id=null)
clone taxonomy sheet (note: taxonomies have no ref ids and return an object id)
__construct($a_id=0)
Constructor.
static saveUsage($a_tax_id, $a_obj_id)
Save Usage.
static putInTree($a_tax_id, $a_node, $a_parent_id="", $a_target_node_id="", $a_order_nr=0)
Put this node into the taxonomy tree.
cloneNodes($a_new_obj, $a_target_parent, $a_source_parent)
Clone nodes.
Class ilObject2 This is an intermediate progress of ilObject class.
getSortingMode()
Get sorting mode.
doCreate()
Create a new taxonomy.
static getSubTreeItems($a_comp, $a_obj_id, $a_item_type, $a_tax_id, $a_node)
Get all assigned items under a node.
static loadLanguageModule()
Load language module.