ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTaxonomyNode Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilTaxonomyNode:

Public Member Functions

 __construct ($a_id=0)
 Constructor public. More...
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setType (string $a_type)
 
 getType ()
 
 setId (int $a_id)
 
 getId ()
 
 setOrderNr (int $a_val)
 
 getOrderNr ()
 
 setTaxonomyId (int $a_val)
 
 getTaxonomyId ()
 
 read ()
 
 create ()
 
 update ()
 
 delete ()
 
 copy (int $a_tax_id=0)
 

Static Public Member Functions

static _lookupTitle (int $a_obj_id)
 
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 writeTitle (int $a_node_id, string $a_title)
 Write title. More...
 
static getNextOrderNr (int $a_tax_id, int $a_parent_id)
 Put this node into the taxonomy tree. More...
 
static fixOrderNumbers (int $a_tax_id, int $a_parent_id)
 

Data Fields

string $type
 
int $id
 
string $title
 

Static Protected Member Functions

static _lookup (int $a_obj_id, string $a_field)
 

Protected Attributes

ilDBInterface $db
 
int $order_nr = 0
 
int $taxonomy_id
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Taxonomy node

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilTaxonomyNode.php.

Constructor & Destructor Documentation

◆ __construct()

ilTaxonomyNode::__construct (   $a_id = 0)

Constructor public.

Definition at line 36 of file class.ilTaxonomyNode.php.

References $DIC, read(), and setType().

37  {
38  global $DIC;
39 
40  $this->db = $DIC->database();
41  $this->id = $a_id;
42 
43  if ($a_id != 0) {
44  $this->read();
45  }
46 
47  $this->setType("taxn");
48  }
global $DIC
Definition: feed.php:28
setType(string $a_type)
+ Here is the call graph for this function:

Member Function Documentation

◆ _lookup()

static ilTaxonomyNode::_lookup ( int  $a_obj_id,
string  $a_field 
)
staticprotected

Definition at line 180 of file class.ilTaxonomyNode.php.

References $DIC, $ilDB, and $query.

180  : string
181  {
182  global $DIC;
183 
184  $ilDB = $DIC->database();
185 
186  $query = "SELECT $a_field FROM tax_node WHERE obj_id = " .
187  $ilDB->quote($a_obj_id, "integer");
188  $obj_set = $ilDB->query($query);
189  if ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
190  return $obj_rec[$a_field];
191  }
192  return "";
193  }
global $DIC
Definition: feed.php:28
$query

◆ _lookupTitle()

static ilTaxonomyNode::_lookupTitle ( int  $a_obj_id)
static

Definition at line 195 of file class.ilTaxonomyNode.php.

Referenced by ilObjTaxonomyGUI\deleteItems(), and ilTaxSelectInputGUI\getTitleForNodeId().

195  : string
196  {
197  return self::_lookup($a_obj_id, "title");
198  }
+ Here is the caller graph for this function:

◆ copy()

ilTaxonomyNode::copy ( int  $a_tax_id = 0)

Definition at line 163 of file class.ilTaxonomyNode.php.

References getOrderNr(), getTaxonomyId(), getTitle(), and getType().

164  {
165  $taxn = new ilTaxonomyNode();
166  $taxn->setTitle($this->getTitle());
167  $taxn->setType($this->getType());
168  $taxn->setOrderNr($this->getOrderNr());
169  if ($a_tax_id == 0) {
170  $taxn->setTaxonomyId($this->getTaxonomyId());
171  } else {
172  $taxn->setTaxonomyId($a_tax_id);
173  }
174 
175  $taxn->create();
176 
177  return $taxn;
178  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ create()

ilTaxonomyNode::create ( )

Definition at line 116 of file class.ilTaxonomyNode.php.

References $db, $ilDB, $query, getOrderNr(), getTaxonomyId(), getTitle(), getType(), and setId().

116  : void
117  {
118  $ilDB = $this->db;
119 
120  if ($this->getTaxonomyId() <= 0) {
121  die("ilTaxonomyNode->create: No taxonomy ID given");
122  }
123 
124  // insert object data
125  $id = $ilDB->nextId("tax_node");
126  $query = "INSERT INTO tax_node (obj_id, title, type, create_date, order_nr, tax_id) " .
127  "VALUES (" .
128  $ilDB->quote($id, "integer") . "," .
129  $ilDB->quote($this->getTitle(), "text") . "," .
130  $ilDB->quote($this->getType(), "text") . ", " .
131  $ilDB->now() . ", " .
132  $ilDB->quote((int) $this->getOrderNr(), "integer") . ", " .
133  $ilDB->quote((int) $this->getTaxonomyId(), "integer") .
134  ")";
135  $ilDB->manipulate($query);
136  $this->setId($id);
137  }
$query
+ Here is the call graph for this function:

◆ delete()

ilTaxonomyNode::delete ( )

Definition at line 151 of file class.ilTaxonomyNode.php.

References $db, $ilDB, $query, ilTaxNodeAssignment\deleteAllAssignmentsOfNode(), and getId().

151  : void
152  {
153  $ilDB = $this->db;
154 
155  // delete all assignments of the node
157 
158  $query = "DELETE FROM tax_node WHERE obj_id= " .
159  $ilDB->quote($this->getId(), "integer");
160  $ilDB->manipulate($query);
161  }
static deleteAllAssignmentsOfNode(int $a_node_id)
$query
+ Here is the call graph for this function:

◆ fixOrderNumbers()

static ilTaxonomyNode::fixOrderNumbers ( int  $a_tax_id,
int  $a_parent_id 
)
static

Definition at line 285 of file class.ilTaxonomyNode.php.

References $c, and ilArrayUtil\sortArray().

Referenced by ilObjTaxonomyGUI\confirmedDelete(), ilObjTaxonomyGUI\pasteItems(), ilObjTaxonomyGUI\saveSorting(), and ilObjTaxonomyGUI\saveTaxNode().

285  : void
286  {
287  $tax_tree = new ilTaxonomyTree($a_tax_id);
288  if ($a_parent_id == 0) {
289  $a_parent_id = $tax_tree->readRootId();
290  }
291  $childs = $tax_tree->getChilds($a_parent_id);
292  $childs = ilArrayUtil::sortArray($childs, "order_nr", "asc", true);
293 
294  $cnt = 10;
295  foreach ($childs as $c) {
296  self::writeOrderNr((int) $c["child"], $cnt);
297  $cnt += 10;
298  }
299  }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilTaxonomyNode::getId ( )

Definition at line 75 of file class.ilTaxonomyNode.php.

References $id.

Referenced by delete(), putInTree(), and update().

75  : int
76  {
77  return $this->id;
78  }
+ Here is the caller graph for this function:

◆ getNextOrderNr()

static ilTaxonomyNode::getNextOrderNr ( int  $a_tax_id,
int  $a_parent_id 
)
static

Put this node into the taxonomy tree.

Definition at line 266 of file class.ilTaxonomyNode.php.

References $c, and ILIAS\Repository\int().

Referenced by ilObjTaxonomyGUI\saveTaxNode().

266  : int
267  {
268  $tax_tree = new ilTaxonomyTree($a_tax_id);
269  if ($a_parent_id == 0) {
270  $a_parent_id = $tax_tree->readRootId();
271  }
272  $childs = $tax_tree->getChilds($a_parent_id);
273  $max = 0;
274 
275  foreach ($childs as $c) {
276  if ((int) $c["order_nr"] > $max) {
277  $max = (int) $c["order_nr"] + 10;
278  }
279  }
280 
281  return $max;
282  }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrderNr()

ilTaxonomyNode::getOrderNr ( )

Definition at line 85 of file class.ilTaxonomyNode.php.

References $order_nr.

Referenced by copy(), create(), and update().

85  : int
86  {
87  return $this->order_nr;
88  }
+ Here is the caller graph for this function:

◆ getTaxonomyId()

ilTaxonomyNode::getTaxonomyId ( )

Definition at line 95 of file class.ilTaxonomyNode.php.

References $taxonomy_id.

Referenced by copy(), and create().

95  : int
96  {
97  return $this->taxonomy_id;
98  }
+ Here is the caller graph for this function:

◆ getTitle()

ilTaxonomyNode::getTitle ( )

Definition at line 55 of file class.ilTaxonomyNode.php.

References $title.

Referenced by copy(), create(), and update().

55  : string
56  {
57  return $this->title;
58  }
+ Here is the caller graph for this function:

◆ getType()

ilTaxonomyNode::getType ( )

Definition at line 65 of file class.ilTaxonomyNode.php.

References $type.

Referenced by copy(), and create().

65  : string
66  {
67  return $this->type;
68  }
+ Here is the caller graph for this function:

◆ putInTree()

static ilTaxonomyNode::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

Definition at line 200 of file class.ilTaxonomyNode.php.

References getId(), and ilTree\POS_FIRST_NODE.

Referenced by ilObjTaxonomy\cloneNodes(), ilTaxonomyDataSet\importRecord(), and ilObjTaxonomyGUI\saveTaxNode().

206  : void {
207  $tax_tree = new ilTaxonomyTree($a_tax_id);
208 
209  // determine parent
210  $parent_id = ($a_parent_id != 0)
211  ? $a_parent_id
212  : $tax_tree->readRootId();
213 
214  // determine target
215  if ($a_target_node_id != 0) {
216  $target = $a_target_node_id;
217  } else {
218  // determine last child that serves as predecessor
219  $childs = $tax_tree->getChilds($parent_id);
220 
221  if (count($childs) == 0) {
222  $target = ilTree::POS_FIRST_NODE;
223  } else {
224  $target = $childs[count($childs) - 1]["obj_id"];
225  }
226  }
227 
228  if ($tax_tree->isInTree($parent_id) && !$tax_tree->isInTree($a_node->getId())) {
229  $tax_tree->insertNode($a_node->getId(), $parent_id, $target);
230  }
231  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_FIRST_NODE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilTaxonomyNode::read ( )

Definition at line 100 of file class.ilTaxonomyNode.php.

References $db, $ilDB, $query, setOrderNr(), setTaxonomyId(), setTitle(), and setType().

Referenced by __construct().

100  : void
101  {
102  $ilDB = $this->db;
103 
104  if (!isset($this->data_record)) {
105  $query = "SELECT * FROM tax_node WHERE obj_id = " .
106  $ilDB->quote($this->id, "integer");
107  $obj_set = $ilDB->query($query);
108  $this->data_record = $ilDB->fetchAssoc($obj_set);
109  }
110  $this->setType($this->data_record["type"]);
111  $this->setTitle($this->data_record["title"]);
112  $this->setOrderNr((int) $this->data_record["order_nr"]);
113  $this->setTaxonomyId((int) $this->data_record["tax_id"]);
114  }
setTitle(string $a_title)
setTaxonomyId(int $a_val)
setType(string $a_type)
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setId()

ilTaxonomyNode::setId ( int  $a_id)

Definition at line 70 of file class.ilTaxonomyNode.php.

Referenced by create().

70  : void
71  {
72  $this->id = $a_id;
73  }
+ Here is the caller graph for this function:

◆ setOrderNr()

ilTaxonomyNode::setOrderNr ( int  $a_val)

Definition at line 80 of file class.ilTaxonomyNode.php.

Referenced by read().

80  : void
81  {
82  $this->order_nr = $a_val;
83  }
+ Here is the caller graph for this function:

◆ setTaxonomyId()

ilTaxonomyNode::setTaxonomyId ( int  $a_val)

Definition at line 90 of file class.ilTaxonomyNode.php.

Referenced by read().

90  : void
91  {
92  $this->taxonomy_id = $a_val;
93  }
+ Here is the caller graph for this function:

◆ setTitle()

ilTaxonomyNode::setTitle ( string  $a_title)

Definition at line 50 of file class.ilTaxonomyNode.php.

Referenced by read().

50  : void
51  {
52  $this->title = $a_title;
53  }
+ Here is the caller graph for this function:

◆ setType()

ilTaxonomyNode::setType ( string  $a_type)

Definition at line 60 of file class.ilTaxonomyNode.php.

Referenced by __construct(), and read().

60  : void
61  {
62  $this->type = $a_type;
63  }
+ Here is the caller graph for this function:

◆ update()

ilTaxonomyNode::update ( )

Definition at line 139 of file class.ilTaxonomyNode.php.

References $db, $ilDB, $query, getId(), getOrderNr(), and getTitle().

139  : void
140  {
141  $ilDB = $this->db;
142 
143  $query = "UPDATE tax_node SET " .
144  " title = " . $ilDB->quote($this->getTitle(), "text") .
145  " ,order_nr = " . $ilDB->quote((int) $this->getOrderNr(), "integer") .
146  " WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
147 
148  $ilDB->manipulate($query);
149  }
$query
+ Here is the call graph for this function:

◆ writeOrderNr()

static ilTaxonomyNode::writeOrderNr ( int  $a_node_id,
int  $a_order_nr 
)
static

Definition at line 234 of file class.ilTaxonomyNode.php.

References $DIC, and $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

234  : void
235  {
236  global $DIC;
237 
238  $ilDB = $DIC->database();
239 
240  $ilDB->manipulate(
241  "UPDATE tax_node SET " .
242  " order_nr = " . $ilDB->quote($a_order_nr, "integer") .
243  " WHERE obj_id = " . $ilDB->quote($a_node_id, "integer")
244  );
245  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ writeTitle()

static ilTaxonomyNode::writeTitle ( int  $a_node_id,
string  $a_title 
)
static

Write title.

Definition at line 250 of file class.ilTaxonomyNode.php.

References $DIC, and $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

250  : void
251  {
252  global $DIC;
253 
254  $ilDB = $DIC->database();
255 
256  $ilDB->manipulate(
257  "UPDATE tax_node SET " .
258  " title = " . $ilDB->quote($a_title, "text") .
259  " WHERE obj_id = " . $ilDB->quote($a_node_id, "integer")
260  );
261  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilTaxonomyNode::$db
protected

Definition at line 25 of file class.ilTaxonomyNode.php.

Referenced by create(), delete(), read(), and update().

◆ $id

int ilTaxonomyNode::$id

Definition at line 27 of file class.ilTaxonomyNode.php.

Referenced by getId().

◆ $order_nr

int ilTaxonomyNode::$order_nr = 0
protected

Definition at line 29 of file class.ilTaxonomyNode.php.

Referenced by getOrderNr().

◆ $taxonomy_id

int ilTaxonomyNode::$taxonomy_id
protected

Definition at line 30 of file class.ilTaxonomyNode.php.

Referenced by getTaxonomyId().

◆ $title

string ilTaxonomyNode::$title

Definition at line 28 of file class.ilTaxonomyNode.php.

Referenced by getTitle().

◆ $type

string ilTaxonomyNode::$type

Definition at line 26 of file class.ilTaxonomyNode.php.

Referenced by getType().


The documentation for this class was generated from the following file: