5 require_once
"./Services/Object/classes/class.ilObject2.php";
30 $this->db = $DIC->database();
32 parent::__construct($a_id,
false);
53 $this->sorting_mode = $a_val;
63 return $this->sorting_mode;
73 $this->item_sorting = $a_val;
94 if ($this->
getId() > 0) {
95 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
122 $ilDB->manipulate(
"INSERT INTO tax_data " .
123 "(id, sorting_mode, item_sorting) VALUES (" .
124 $ilDB->quote($this->getId(),
"integer") .
"," .
125 $ilDB->quote((
int) $this->getSortingMode(),
"integer") .
"," .
126 $ilDB->quote((
int) $this->getItemSorting(),
"integer") .
130 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
133 $node->setTitle(
"Root node for taxonomy " . $this->
getId());
134 $node->setTaxonomyId($this->
getId());
136 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
138 $tax_tree->addTree($this->
getId(), $node->getId());
149 $a_new_obj->setTitle($this->
getTitle());
153 $this->node_mapping = array();
157 $a_new_obj->getTree()->readRootId(),
168 public function cloneNodes($a_new_obj, $a_target_parent, $a_source_parent)
170 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
174 foreach (
$nodes as $node) {
175 switch ($node[
"type"]) {
178 $new_node = $tax_node->copy($a_new_obj->getId());
188 $this->node_mapping[$node[
"child"]] = $new_node->getId();
191 $this->
cloneNodes($a_new_obj, $new_node->getId(), $node[
"child"]);
204 self::deleteUsagesOfTaxonomy($this->
getId());
208 $subtree =
$tree->getSubTreeIds(
$tree->readRootId());
209 $subtree[] =
$tree->readRootId();
213 $root_node_data =
$tree->getNodeData(
$tree->readRootId());
216 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyNode.php");
217 foreach ($subtree as $node_id) {
224 $tree->deleteTree($root_node_data);
228 "DELETE FROM tax_data WHERE " .
229 " id = " .
$ilDB->quote($this->getId(),
"integer")
242 "SELECT * FROM tax_data " .
243 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
245 $rec =
$ilDB->fetchAssoc($set);
258 $t =
"UPDATE tax_data SET " .
259 " sorting_mode = " .
$ilDB->quote((
int) $this->getSortingMode(),
"integer") .
", " .
260 " item_sorting = " .
$ilDB->quote((
int) $this->getItemSorting(),
"integer") .
261 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
275 $lng = $DIC->language();
277 $lng->loadLanguageModule(
"tax");
291 $ilDB = $DIC->database();
293 if ($a_tax_id > 0 && $a_obj_id > 0) {
296 array(
"tax_id" => array(
"integer", $a_tax_id),
297 "obj_id" => array(
"integer", $a_obj_id)
314 $ilDB = $DIC->database();
317 "SELECT tax_id FROM tax_usage " .
318 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer")
321 while ($rec =
$ilDB->fetchAssoc($set)) {
322 if (!$a_include_titles) {
323 $tax[] = $rec[
"tax_id"];
325 $tax[] = array(
"tax_id" => $rec[
"tax_id"],
343 $ilDB = $DIC->database();
346 "DELETE FROM tax_usage WHERE " .
347 " tax_id = " .
$ilDB->quote($a_id,
"integer")
358 public static function getSubTreeItems($a_comp, $a_obj_id, $a_item_type, $a_tax_id, $a_node)
360 include_once(
"./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
363 $sub_nodes =
$tree->getSubTreeIds($a_node);
364 $sub_nodes[] = $a_node;
365 include_once(
"./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
368 $items = $tn_ass->getAssignmentsOfNode($sub_nodes);
379 protected static function lookup($a_field, $a_id)
383 $ilDB = $DIC->database();
386 "SELECT " . $a_field .
" FROM tax_data " .
387 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
389 $rec =
$ilDB->fetchAssoc($set);
391 return $rec[$a_field];
402 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.
static lookup($a_field, $a_id)
Lookup.
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.
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.
cloneNodes($a_new_obj, $a_target_parent, $a_source_parent)
Clone nodes.
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.