ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilTaxonomyNode Class Reference

Taxonomy node. More...

+ Collaboration diagram for ilTaxonomyNode:

Public Member Functions

 __construct ($a_id=0)
 Constructor @access public. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setType ($a_type)
 Set type. More...
 
 getType ()
 Get type. More...
 
 setId ($a_id)
 Set Node ID. More...
 
 getId ()
 Get Node ID. More...
 
 setOrderNr ($a_val)
 Set order nr. More...
 
 getOrderNr ()
 Get order nr. More...
 
 setTaxonomyId ($a_val)
 Set taxonomy id. More...
 
 getTaxonomyId ()
 Get taxonomy id. More...
 
 read ()
 Read data from database. More...
 
 create ()
 Create taxonomy node. More...
 
 update ()
 Update Node. More...
 
 delete ()
 Delete taxonomy node. More...
 
 copy ($a_tax_id=0)
 Copy taxonomy node. More...
 

Static Public Member Functions

static _lookupTitle ($a_obj_id)
 Lookup Title. More...
 
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. More...
 
static writeOrderNr ($a_node_id, $a_order_nr)
 Write order nr. More...
 
static writeTitle ($a_node_id, $a_title)
 Write title. More...
 
static getNextOrderNr ($a_tax_id, $a_parent_id)
 Put this node into the taxonomy tree. More...
 
static fixOrderNumbers ($a_tax_id, $a_parent_id)
 Fix order numbers. More...
 

Data Fields

 $type
 
 $id
 
 $title
 

Static Protected Member Functions

static _lookup ($a_obj_id, $a_field)
 Lookup. More...
 

Protected Attributes

 $db
 

Detailed Description

Taxonomy node.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilTaxonomyNode::__construct (   $a_id = 0)

Constructor @access public.

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

30 {
31 global $DIC;
32
33 $this->db = $DIC->database();
34 $this->id = $a_id;
35
36 // include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
37 // $this->taxonomy_tree = new ilTaxonomyTree();
38
39 if ($a_id != 0) {
40 $this->read();
41 }
42
43 $this->setType("taxn");
44 }
read()
Read data from database.
setType($a_type)
Set type.
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _lookup()

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

Lookup.

Parameters
intNode ID

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

248 {
249 global $DIC;
250
251 $ilDB = $DIC->database();
252
253 $query = "SELECT $a_field FROM tax_node WHERE obj_id = " .
254 $ilDB->quote($a_obj_id, "integer");
255 $obj_set = $ilDB->query($query);
256 $obj_rec = $ilDB->fetchAssoc($obj_set);
257
258 return $obj_rec[$a_field];
259 }
$query
global $ilDB

References $DIC, $ilDB, and $query.

Referenced by _lookupTitle().

+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilTaxonomyNode::_lookupTitle (   $a_obj_id)
static

Lookup Title.

Parameters
intnode ID
Returns
string title

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

268 {
269 global $DIC;
270
271 $ilDB = $DIC->database();
272
273 return self::_lookup($a_obj_id, "title");
274 }
static _lookup($a_obj_id, $a_field)
Lookup.

References $DIC, $ilDB, and _lookup().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copy()

ilTaxonomyNode::copy (   $a_tax_id = 0)

Copy taxonomy node.

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

226 {
227 $taxn = new ilTaxonomyNode();
228 $taxn->setTitle($this->getTitle());
229 $taxn->setType($this->getType());
230 $taxn->setOrderNr($this->getOrderNr());
231 if ($a_tax_id == 0) {
232 $taxn->setTaxonomyId($this->getTaxonomyId());
233 } else {
234 $taxn->setTaxonomyId($a_tax_id);
235 }
236
237 $taxn->create();
238
239 return $taxn;
240 }
getTaxonomyId()
Get taxonomy id.
getOrderNr()
Get order nr.

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

+ Here is the call graph for this function:

◆ create()

ilTaxonomyNode::create ( )

Create taxonomy node.

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

169 {
171
172 if ($this->getTaxonomyId() <= 0) {
173 die("ilTaxonomyNode->create: No taxonomy ID given");
174 }
175
176 // insert object data
177 $id = $ilDB->nextId("tax_node");
178 $query = "INSERT INTO tax_node (obj_id, title, type, create_date, order_nr, tax_id) " .
179 "VALUES (" .
180 $ilDB->quote($id, "integer") . "," .
181 $ilDB->quote($this->getTitle(), "text") . "," .
182 $ilDB->quote($this->getType(), "text") . ", " .
183 $ilDB->now() . ", " .
184 $ilDB->quote((int) $this->getOrderNr(), "integer") . ", " .
185 $ilDB->quote((int) $this->getTaxonomyId(), "integer") .
186 ")";
187 $ilDB->manipulate($query);
188 $this->setId($id);
189 }
setId($a_id)
Set Node ID.

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

+ Here is the call graph for this function:

◆ delete()

ilTaxonomyNode::delete ( )

Delete taxonomy node.

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

210 {
212
213 // delete all assignments of the node
214 include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
216
217 $query = "DELETE FROM tax_node WHERE obj_id= " .
218 $ilDB->quote($this->getId(), "integer");
219 $ilDB->manipulate($query);
220 }
static deleteAllAssignmentsOfNode($a_node_id)
Delete assignments of node.

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

+ Here is the call graph for this function:

◆ fixOrderNumbers()

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

Fix order numbers.

Parameters

return

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

380 {
381 include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
382 $tax_tree = new ilTaxonomyTree($a_tax_id);
383 if ($a_parent_id == 0) {
384 $a_parent_id = $tax_tree->readRootId();
385 }
386 $childs = $tax_tree->getChilds($a_parent_id);
387 $childs = ilUtil::sortArray($childs, "order_nr", "asc", true);
388
389 $cnt = 10;
390 foreach ($childs as $c) {
391 self::writeOrderNr($c["child"], $cnt);
392 $cnt += 10;
393 }
394 }
static writeOrderNr($a_node_id, $a_order_nr)
Write order nr.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References Vendor\Package\$c, ilUtil\sortArray(), and writeOrderNr().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilTaxonomyNode::getId ( )

Get Node ID.

Parameters
intNode ID

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

102 {
103 return $this->id;
104 }

References $id.

Referenced by delete(), and update().

+ Here is the caller graph for this function:

◆ getNextOrderNr()

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

Put this node into the taxonomy tree.

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

355 {
356 include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
357 $tax_tree = new ilTaxonomyTree($a_tax_id);
358 if ($a_parent_id == 0) {
359 $a_parent_id = $tax_tree->readRootId();
360 }
361 $childs = $tax_tree->getChilds($a_parent_id);
362 $max = 0;
363
364 foreach ($childs as $c) {
365 if ($c["order_nr"] > $max) {
366 $max = $c["order_nr"] + 10;
367 }
368 }
369
370 return $max;
371 }

References Vendor\Package\$c.

Referenced by ilObjTaxonomyGUI\saveTaxNode().

+ Here is the caller graph for this function:

◆ getOrderNr()

ilTaxonomyNode::getOrderNr ( )

Get order nr.

Returns
int order nr

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

122 {
123 return $this->order_nr;
124 }

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

+ Here is the caller graph for this function:

◆ getTaxonomyId()

ilTaxonomyNode::getTaxonomyId ( )

Get taxonomy id.

Returns
int taxonomy id

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

142 {
143 return $this->taxonomy_id;
144 }

Referenced by copy(), and create().

+ Here is the caller graph for this function:

◆ getTitle()

ilTaxonomyNode::getTitle ( )

Get title.

Returns
string title

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

62 {
63 return $this->title;
64 }

References $title.

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

+ Here is the caller graph for this function:

◆ getType()

ilTaxonomyNode::getType ( )

Get type.

Returns
string Type

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

82 {
83 return $this->type;
84 }

References $type.

Referenced by copy(), and create().

+ Here is the caller graph for this function:

◆ putInTree()

static ilTaxonomyNode::putInTree (   $a_tax_id,
  $a_node,
  $a_parent_id = "",
  $a_target_node_id = "",
  $a_order_nr = 0 
)
static

Put this node into the taxonomy tree.

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

285 {
286 include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
287 $tax_tree = new ilTaxonomyTree($a_tax_id);
288
289 // determine parent
290 $parent_id = ($a_parent_id != "")
291 ? $a_parent_id
292 : $tax_tree->readRootId();
293
294 // determine target
295 if ($a_target_node_id != "") {
296 $target = $a_target_node_id;
297 } else {
298 // determine last child that serves as predecessor
299 $childs = $tax_tree->getChilds($parent_id);
300
301 if (count($childs) == 0) {
302 $target = IL_FIRST_NODE;
303 } else {
304 $target = $childs[count($childs) - 1]["obj_id"];
305 }
306 }
307
308 if ($tax_tree->isInTree($parent_id) && !$tax_tree->isInTree($a_node->getId())) {
309 $tax_tree->insertNode($a_node->getId(), $parent_id, $target);
310 }
311 }
const IL_FIRST_NODE
Definition: class.ilTree.php:5

References IL_FIRST_NODE.

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

+ Here is the caller graph for this function:

◆ read()

ilTaxonomyNode::read ( )

Read data from database.

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

150 {
152
153 if (!isset($this->data_record)) {
154 $query = "SELECT * FROM tax_node WHERE obj_id = " .
155 $ilDB->quote($this->id, "integer");
156 $obj_set = $ilDB->query($query);
157 $this->data_record = $ilDB->fetchAssoc($obj_set);
158 }
159 $this->setType($this->data_record["type"]);
160 $this->setTitle($this->data_record["title"]);
161 $this->setOrderNr($this->data_record["order_nr"]);
162 $this->setTaxonomyId($this->data_record["tax_id"]);
163 }
setTaxonomyId($a_val)
Set taxonomy id.
setTitle($a_title)
Set title.
setOrderNr($a_val)
Set order nr.

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setId()

ilTaxonomyNode::setId (   $a_id)

Set Node ID.

Parameters
intNode ID

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

92 {
93 $this->id = $a_id;
94 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setOrderNr()

ilTaxonomyNode::setOrderNr (   $a_val)

Set order nr.

Parameters
int$a_valorder nr

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

112 {
113 $this->order_nr = $a_val;
114 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTaxonomyId()

ilTaxonomyNode::setTaxonomyId (   $a_val)

Set taxonomy id.

Parameters
int$a_valtaxonomy id

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

132 {
133 $this->taxonomy_id = $a_val;
134 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilTaxonomyNode::setTitle (   $a_title)

Set title.

Parameters
string$a_titletitle

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

52 {
53 $this->title = $a_title;
54 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilTaxonomyNode::setType (   $a_type)

Set type.

Parameters
stringType

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

72 {
73 $this->type = $a_type;
74 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by __construct(), and read().

+ Here is the caller graph for this function:

◆ update()

ilTaxonomyNode::update ( )

Update Node.

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

195 {
197
198 $query = "UPDATE tax_node SET " .
199 " title = " . $ilDB->quote($this->getTitle(), "text") .
200 " ,order_nr = " . $ilDB->quote((int) $this->getOrderNr(), "integer") .
201 " WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
202
203 $ilDB->manipulate($query);
204 }

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

+ Here is the call graph for this function:

◆ writeOrderNr()

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

Write order nr.

Parameters

return

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

320 {
321 global $DIC;
322
323 $ilDB = $DIC->database();
324
325 $ilDB->manipulate(
326 "UPDATE tax_node SET " .
327 " order_nr = " . $ilDB->quote($a_order_nr, "integer") .
328 " WHERE obj_id = " . $ilDB->quote($a_node_id, "integer")
329 );
330 }

References $DIC, and $ilDB.

Referenced by fixOrderNumbers(), and ilObjTaxonomyGUI\saveSorting().

+ Here is the caller graph for this function:

◆ writeTitle()

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

Write title.

Parameters

return

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

339 {
340 global $DIC;
341
342 $ilDB = $DIC->database();
343
344 $ilDB->manipulate(
345 "UPDATE tax_node SET " .
346 " title = " . $ilDB->quote($a_title, "text") .
347 " WHERE obj_id = " . $ilDB->quote($a_node_id, "integer")
348 );
349 }

References $DIC, and $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilTaxonomyNode::$db
protected

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

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

◆ $id

ilTaxonomyNode::$id

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

Referenced by create(), and getId().

◆ $title

ilTaxonomyNode::$title

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

Referenced by getTitle().

◆ $type

ilTaxonomyNode::$type

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

Referenced by getType().


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