ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTaxonomyNode Class Reference

Taxonomy node. More...

+ Collaboration diagram for ilTaxonomyNode:

Public Member Functions

 __construct ($a_id=0)
 Constructor 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...
 

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 public.

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

References read(), and setType().

25  {
26  $this->id = $a_id;
27 
28 // include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
29 // $this->taxonomy_tree = new ilTaxonomyTree();
30 
31  if($a_id != 0)
32  {
33  $this->read();
34  }
35 
36  $this->setType("taxn");
37  }
read()
Read data from database.
setType($a_type)
Set type.
+ 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 246 of file class.ilTaxonomyNode.php.

References $ilDB, and $query.

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

◆ _lookupTitle()

static ilTaxonomyNode::_lookupTitle (   $a_obj_id)
static

Lookup Title.

Parameters
intnode ID
Returns
string title

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

References $ilDB.

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

265  {
266  global $ilDB;
267 
268  return self::_lookup($a_obj_id, "title");
269  }
global $ilDB
+ Here is the caller graph for this function:

◆ copy()

ilTaxonomyNode::copy (   $a_tax_id = 0)

Copy taxonomy node.

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

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

222  {
223  $taxn = new ilTaxonomyNode();
224  $taxn->setTitle($this->getTitle());
225  $taxn->setType($this->getType());
226  $taxn->setOrderNr($this->getOrderNr());
227  if ($a_tax_id == 0)
228  {
229  $taxn->setTaxonomyId($this->getTaxonomyId());
230  }
231  else
232  {
233  $taxn->setTaxonomyId($a_tax_id);
234  }
235 
236  $taxn->create();
237 
238  return $taxn;
239  }
getTaxonomyId()
Get taxonomy id.
getOrderNr()
Get order nr.
+ Here is the call graph for this function:

◆ create()

ilTaxonomyNode::create ( )

Create taxonomy node.

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

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

163  {
164  global $ilDB;
165 
166  if ($this->getTaxonomyId() <= 0)
167  {
168  die("ilTaxonomyNode->create: No taxonomy ID given");
169  }
170 
171  // insert object data
172  $id = $ilDB->nextId("tax_node");
173  $query = "INSERT INTO tax_node (obj_id, title, type, create_date, order_nr, tax_id) ".
174  "VALUES (".
175  $ilDB->quote($id, "integer").",".
176  $ilDB->quote($this->getTitle(), "text").",".
177  $ilDB->quote($this->getType(), "text").", ".
178  $ilDB->now().", ".
179  $ilDB->quote((int) $this->getOrderNr(), "integer").", ".
180  $ilDB->quote((int) $this->getTaxonomyId(), "integer").
181  ")";
182  $ilDB->manipulate($query);
183  $this->setId($id);
184 
185  }
getTaxonomyId()
Get taxonomy id.
getOrderNr()
Get order nr.
setId($a_id)
Set Node ID.
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilTaxonomyNode::delete ( )

Delete taxonomy node.

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

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

206  {
207  global $ilDB;
208 
209  // delete all assignments of the node
210  include_once("./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php");
212 
213  $query = "DELETE FROM tax_node WHERE obj_id= ".
214  $ilDB->quote($this->getId(), "integer");
215  $ilDB->manipulate($query);
216  }
getId()
Get Node ID.
global $ilDB
static deleteAllAssignmentsOfNode($a_node_id)
Delete assignments of node.
+ Here is the call graph for this function:

◆ fixOrderNumbers()

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

Fix order numbers.

Parameters

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

References ilUtil\sortArray().

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

375  {
376  include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
377  $tax_tree = new ilTaxonomyTree($a_tax_id);
378  if ($a_parent_id == 0)
379  {
380  $a_parent_id = $tax_tree->readRootId();
381  }
382  $childs = $tax_tree->getChilds($a_parent_id);
383  $childs = ilUtil::sortArray($childs, "order_nr", "asc", true);
384 
385  $cnt = 10;
386  foreach ($childs as $c)
387  {
388  self::writeOrderNr($c["child"], $cnt);
389  $cnt += 10;
390  }
391  }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
+ 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 94 of file class.ilTaxonomyNode.php.

References $id.

Referenced by delete(), and update().

95  {
96  return $this->id;
97  }
+ 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 346 of file class.ilTaxonomyNode.php.

Referenced by ilObjTaxonomyGUI\saveTaxNode().

347  {
348  include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
349  $tax_tree = new ilTaxonomyTree($a_tax_id);
350  if ($a_parent_id == 0)
351  {
352  $a_parent_id = $tax_tree->readRootId();
353  }
354  $childs = $tax_tree->getChilds($a_parent_id);
355  $max = 0;
356 
357  foreach ($childs as $c)
358  {
359  if ($c["order_nr"] > $max)
360  {
361  $max = $c["order_nr"] + 10;
362  }
363  }
364 
365  return $max;
366  }
+ Here is the caller graph for this function:

◆ getOrderNr()

ilTaxonomyNode::getOrderNr ( )

Get order nr.

Returns
int order nr

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

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

115  {
116  return $this->order_nr;
117  }
+ Here is the caller graph for this function:

◆ getTaxonomyId()

ilTaxonomyNode::getTaxonomyId ( )

Get taxonomy id.

Returns
int taxonomy id

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

Referenced by copy(), and create().

135  {
136  return $this->taxonomy_id;
137  }
+ Here is the caller graph for this function:

◆ getTitle()

ilTaxonomyNode::getTitle ( )

Get title.

Returns
string title

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

References $title.

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

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

◆ getType()

ilTaxonomyNode::getType ( )

Get type.

Returns
string Type

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

References $type.

Referenced by copy(), and create().

75  {
76  return $this->type;
77  }
+ 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 274 of file class.ilTaxonomyNode.php.

References $target, and IL_FIRST_NODE.

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

276  {
277  include_once("./Services/Taxonomy/classes/class.ilTaxonomyTree.php");
278  $tax_tree = new ilTaxonomyTree($a_tax_id);
279 
280  // determine parent
281  $parent_id = ($a_parent_id != "")
282  ? $a_parent_id
283  : $tax_tree->readRootId();
284 
285  // determine target
286  if ($a_target_node_id != "")
287  {
288  $target = $a_target_node_id;
289  }
290  else
291  {
292  // determine last child that serves as predecessor
293  $childs = $tax_tree->getChilds($parent_id);
294 
295  if (count($childs) == 0)
296  {
298  }
299  else
300  {
301  $target = $childs[count($childs) - 1]["obj_id"];
302  }
303  }
304 
305  if ($tax_tree->isInTree($parent_id) && !$tax_tree->isInTree($a_node->getId()))
306  {
307  $tax_tree->insertNode($a_node->getId(), $parent_id, $target);
308  }
309  }
const IL_FIRST_NODE
Definition: class.ilTree.php:5
+ Here is the caller graph for this function:

◆ read()

ilTaxonomyNode::read ( )

Read data from database.

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

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

Referenced by __construct().

143  {
144  global $ilDB;
145 
146  if(!isset($this->data_record))
147  {
148  $query = "SELECT * FROM tax_node WHERE obj_id = ".
149  $ilDB->quote($this->id, "integer");
150  $obj_set = $ilDB->query($query);
151  $this->data_record = $ilDB->fetchAssoc($obj_set);
152  }
153  $this->setType($this->data_record["type"]);
154  $this->setTitle($this->data_record["title"]);
155  $this->setOrderNr($this->data_record["order_nr"]);
156  $this->setTaxonomyId($this->data_record["tax_id"]);
157  }
setTitle($a_title)
Set title.
setTaxonomyId($a_val)
Set taxonomy id.
setType($a_type)
Set type.
setOrderNr($a_val)
Set order nr.
global $ilDB
+ 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 84 of file class.ilTaxonomyNode.php.

Referenced by create().

85  {
86  $this->id = $a_id;
87  }
+ Here is the caller graph for this function:

◆ setOrderNr()

ilTaxonomyNode::setOrderNr (   $a_val)

Set order nr.

Parameters
int$a_valorder nr

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

Referenced by read().

105  {
106  $this->order_nr = $a_val;
107  }
+ Here is the caller graph for this function:

◆ setTaxonomyId()

ilTaxonomyNode::setTaxonomyId (   $a_val)

Set taxonomy id.

Parameters
int$a_valtaxonomy id

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

Referenced by read().

125  {
126  $this->taxonomy_id = $a_val;
127  }
+ Here is the caller graph for this function:

◆ setTitle()

ilTaxonomyNode::setTitle (   $a_title)

Set title.

Parameters
string$a_titletitle

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

Referenced by read().

45  {
46  $this->title = $a_title;
47  }
+ Here is the caller graph for this function:

◆ setType()

ilTaxonomyNode::setType (   $a_type)

Set type.

Parameters
stringType

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

References $a_type.

Referenced by __construct(), and read().

65  {
66  $this->type = $a_type;
67  }
$a_type
Definition: workflow.php:93
+ Here is the caller graph for this function:

◆ update()

ilTaxonomyNode::update ( )

Update Node.

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

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

191  {
192  global $ilDB;
193 
194  $query = "UPDATE tax_node SET ".
195  " title = ".$ilDB->quote($this->getTitle(), "text").
196  " ,order_nr = ".$ilDB->quote((int) $this->getOrderNr(), "integer").
197  " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
198 
199  $ilDB->manipulate($query);
200  }
getId()
Get Node ID.
getOrderNr()
Get order nr.
global $ilDB
+ Here is the call graph for this function:

◆ writeOrderNr()

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

Write order nr.

Parameters

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

References $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

318  {
319  global $ilDB;
320 
321  $ilDB->manipulate("UPDATE tax_node SET ".
322  " order_nr = ".$ilDB->quote($a_order_nr, "integer").
323  " WHERE obj_id = ".$ilDB->quote($a_node_id, "integer")
324  );
325  }
global $ilDB
+ Here is the caller graph for this function:

◆ writeTitle()

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

Write title.

Parameters

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

References $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

334  {
335  global $ilDB;
336 
337  $ilDB->manipulate("UPDATE tax_node SET ".
338  " title = ".$ilDB->quote($a_title, "text").
339  " WHERE obj_id = ".$ilDB->quote($a_node_id, "integer")
340  );
341  }
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $id

ilTaxonomyNode::$id

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

Referenced by getId().

◆ $title

ilTaxonomyNode::$title

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

Referenced by getTitle().

◆ $type

ilTaxonomyNode::$type

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

Referenced by getType().


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