40 $this->db = $DIC->database();
50 public function setTitle(
string $a_title): void
52 $this->title = $a_title;
60 public function setType(
string $a_type): void
62 $this->type = $a_type;
70 public function setId(
int $a_id): void
82 $this->order_nr = $a_val;
92 $this->taxonomy_id = $a_val;
104 if (!isset($this->data_record)) {
105 $query =
"SELECT * FROM tax_node WHERE obj_id = " .
106 $ilDB->quote($this->
id,
"integer");
108 $this->data_record =
$ilDB->fetchAssoc($obj_set);
110 $this->
setType($this->data_record[
"type"]);
111 $this->
setTitle($this->data_record[
"title"]);
112 $this->
setOrderNr((
int) $this->data_record[
"order_nr"]);
121 die(
"ilTaxonomyNode->create: No taxonomy ID given");
125 $id =
$ilDB->nextId(
"tax_node");
126 $query =
"INSERT INTO tax_node (obj_id, title, type, create_date, order_nr, tax_id) " .
128 $ilDB->quote($id,
"integer") .
"," .
131 $ilDB->now() .
", " .
143 $query =
"UPDATE tax_node SET " .
146 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
151 public function delete():
void 158 $query =
"DELETE FROM tax_node WHERE obj_id= " .
167 $taxn->setType($this->
getType());
169 if ($a_tax_id == 0) {
172 $taxn->setTaxonomyId($a_tax_id);
180 protected static function _lookup(
int $a_obj_id,
string $a_field): string
184 $ilDB = $DIC->database();
186 $query =
"SELECT $a_field FROM tax_node WHERE obj_id = " .
187 $ilDB->quote($a_obj_id,
"integer");
189 if ($obj_rec =
$ilDB->fetchAssoc($obj_set)) {
190 return $obj_rec[$a_field];
197 return self::_lookup($a_obj_id,
"title");
203 int $a_parent_id = 0,
204 int $a_target_node_id = 0,
210 $parent_id = ($a_parent_id != 0)
212 : $tax_tree->readRootId();
215 if ($a_target_node_id != 0) {
216 $target = $a_target_node_id;
219 $childs = $tax_tree->getChilds($parent_id);
221 if (count($childs) == 0) {
224 $target = $childs[count($childs) - 1][
"obj_id"];
228 if ($tax_tree->isInTree($parent_id) && !$tax_tree->isInTree($a_node->
getId())) {
229 $tax_tree->insertNode($a_node->
getId(), $parent_id, $target);
234 public static function writeOrderNr(
int $a_node_id,
int $a_order_nr): void
238 $ilDB = $DIC->database();
241 "UPDATE tax_node SET " .
242 " order_nr = " .
$ilDB->quote($a_order_nr,
"integer") .
243 " WHERE obj_id = " .
$ilDB->quote($a_node_id,
"integer")
250 public static function writeTitle(
int $a_node_id,
string $a_title): void
254 $ilDB = $DIC->database();
257 "UPDATE tax_node SET " .
258 " title = " .
$ilDB->quote($a_title,
"text") .
259 " WHERE obj_id = " .
$ilDB->quote($a_node_id,
"integer")
269 if ($a_parent_id == 0) {
270 $a_parent_id = $tax_tree->readRootId();
272 $childs = $tax_tree->getChilds($a_parent_id);
275 foreach ($childs as
$c) {
276 if ((
int) $c[
"order_nr"] > $max) {
277 $max = (
int) $c[
"order_nr"] + 10;
288 if ($a_parent_id == 0) {
289 $a_parent_id = $tax_tree->readRootId();
291 $childs = $tax_tree->getChilds($a_parent_id);
295 foreach ($childs as
$c) {
296 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...
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)