41 $this->db = $DIC->database();
51 public function setTitle(
string $a_title): void
53 $this->title = $a_title;
61 public function setType(
string $a_type): void
63 $this->type = $a_type;
71 public function setId(
int $a_id): void
83 $this->order_nr = $a_val;
93 $this->taxonomy_id = $a_val;
105 if (!isset($this->data_record)) {
106 $query =
"SELECT * FROM tax_node WHERE obj_id = " .
107 $ilDB->quote($this->
id,
"integer");
108 $obj_set =
$ilDB->query($query);
109 $this->data_record =
$ilDB->fetchAssoc($obj_set);
111 $this->
setType($this->data_record[
"type"]);
112 $this->
setTitle($this->data_record[
"title"]);
113 $this->
setOrderNr((
int) $this->data_record[
"order_nr"]);
122 die(
"ilTaxonomyNode->create: No taxonomy ID given");
126 $id =
$ilDB->nextId(
"tax_node");
127 $query =
"INSERT INTO tax_node (obj_id, title, type, create_date, order_nr, tax_id) " .
129 $ilDB->quote($id,
"integer") .
"," .
132 $ilDB->now() .
", " .
136 $ilDB->manipulate($query);
144 $query =
"UPDATE tax_node SET " .
147 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
149 $ilDB->manipulate($query);
152 public function delete():
void 159 $query =
"DELETE FROM tax_node WHERE obj_id= " .
161 $ilDB->manipulate($query);
168 $taxn->setType($this->
getType());
170 if ($a_tax_id == 0) {
173 $taxn->setTaxonomyId($a_tax_id);
181 protected static function _lookup(
int $a_obj_id,
string $a_field): string
185 $ilDB = $DIC->database();
187 $query =
"SELECT $a_field FROM tax_node WHERE obj_id = " .
188 $ilDB->quote($a_obj_id,
"integer");
189 $obj_set =
$ilDB->query($query);
190 if ($obj_rec =
$ilDB->fetchAssoc($obj_set)) {
191 return $obj_rec[$a_field];
198 return self::_lookup($a_obj_id,
"title");
204 int $a_parent_id = 0,
205 int $a_target_node_id = 0,
211 $parent_id = ($a_parent_id != 0)
213 : $tax_tree->readRootId();
216 if ($a_target_node_id != 0) {
217 $target = $a_target_node_id;
220 $childs = $tax_tree->getChilds($parent_id);
222 if (count($childs) == 0) {
225 $target = $childs[count($childs) - 1][
"obj_id"];
229 if ($tax_tree->isInTree($parent_id) && !$tax_tree->isInTree($a_node->
getId())) {
230 $tax_tree->insertNode($a_node->
getId(), $parent_id, $target);
235 public static function writeOrderNr(
int $a_node_id,
int $a_order_nr): void
239 $ilDB = $DIC->database();
242 "UPDATE tax_node SET " .
243 " order_nr = " .
$ilDB->quote($a_order_nr,
"integer") .
244 " WHERE obj_id = " .
$ilDB->quote($a_node_id,
"integer")
251 public static function writeTitle(
int $a_node_id,
string $a_title): void
255 $ilDB = $DIC->database();
258 "UPDATE tax_node SET " .
259 " title = " .
$ilDB->quote($a_title,
"text") .
260 " WHERE obj_id = " .
$ilDB->quote($a_node_id,
"integer")
270 if ($a_parent_id == 0) {
271 $a_parent_id = $tax_tree->readRootId();
273 $childs = $tax_tree->getChilds($a_parent_id);
276 foreach ($childs as
$c) {
277 if ((
int) $c[
"order_nr"] > $max) {
278 $max = (
int) $c[
"order_nr"] + 10;
289 if ($a_parent_id == 0) {
290 $a_parent_id = $tax_tree->readRootId();
292 $childs = $tax_tree->getChilds($a_parent_id);
296 foreach ($childs as
$c) {
297 self::writeOrderNr((
int) $c[
"child"], $cnt);
static getNextOrderNr(int $a_tax_id, int $a_parent_id)
Put this node into the taxonomy tree.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static writeTitle(int $a_node_id, string $a_title)
Write title.
setTitle(string $a_title)
__construct($a_id=0)
Constructor public.
static deleteAllAssignmentsOfNode(int $a_node_id)
setTaxonomyId(int $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $a_obj_id)
static _lookup(int $a_obj_id, string $a_field)
static putInTree(int $a_tax_id, ilTaxonomyNode $a_node, int $a_parent_id=0, int $a_target_node_id=0, int $a_order_nr=0)
static writeOrderNr(int $a_node_id, int $a_order_nr)
static fixOrderNumbers(int $a_tax_id, int $a_parent_id)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)