ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 @access 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
 
array $data_record = null
 

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

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

38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42 $this->id = $a_id;
43
44 if ($a_id != 0) {
45 $this->read();
46 }
47
48 $this->setType("taxn");
49 }
setType(string $a_type)
global $DIC
Definition: shib_login.php:26

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

+ 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 181 of file class.ilTaxonomyNode.php.

181 : string
182 {
183 global $DIC;
184
185 $ilDB = $DIC->database();
186
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];
192 }
193 return "";
194 }

References $DIC, and $ilDB.

Referenced by _lookupTitle().

+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilTaxonomyNode::_lookupTitle ( int  $a_obj_id)
static

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

196 : string
197 {
198 return self::_lookup($a_obj_id, "title");
199 }
static _lookup(int $a_obj_id, string $a_field)

References _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 ( int  $a_tax_id = 0)

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

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

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

+ Here is the call graph for this function:

◆ create()

ilTaxonomyNode::create ( )

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

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

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

+ Here is the call graph for this function:

◆ delete()

ilTaxonomyNode::delete ( )

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

152 : void
153 {
155
156 // delete all assignments of the node
158
159 $query = "DELETE FROM tax_node WHERE obj_id= " .
160 $ilDB->quote($this->getId(), "integer");
161 $ilDB->manipulate($query);
162 }
static deleteAllAssignmentsOfNode(int $a_node_id)

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

+ Here is the call graph for this function:

◆ fixOrderNumbers()

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

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

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

References $c, and ilArrayUtil\sortArray().

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 ( )

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

76 : int
77 {
78 return $this->id;
79 }

References $id.

Referenced by delete(), and update().

+ 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 267 of file class.ilTaxonomyNode.php.

267 : int
268 {
269 $tax_tree = new ilTaxonomyTree($a_tax_id);
270 if ($a_parent_id == 0) {
271 $a_parent_id = $tax_tree->readRootId();
272 }
273 $childs = $tax_tree->getChilds($a_parent_id);
274 $max = 0;
275
276 foreach ($childs as $c) {
277 if ((int) $c["order_nr"] > $max) {
278 $max = (int) $c["order_nr"] + 10;
279 }
280 }
281
282 return $max;
283 }

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

Referenced by ilObjTaxonomyGUI\saveTaxNode().

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

◆ getOrderNr()

ilTaxonomyNode::getOrderNr ( )

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

86 : int
87 {
88 return $this->order_nr;
89 }

References $order_nr.

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

+ Here is the caller graph for this function:

◆ getTaxonomyId()

ilTaxonomyNode::getTaxonomyId ( )

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

96 : int
97 {
98 return $this->taxonomy_id;
99 }

References $taxonomy_id.

Referenced by copy(), and create().

+ Here is the caller graph for this function:

◆ getTitle()

ilTaxonomyNode::getTitle ( )

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

56 : string
57 {
58 return $this->title;
59 }

References $title.

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

+ Here is the caller graph for this function:

◆ getType()

ilTaxonomyNode::getType ( )

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

66 : string
67 {
68 return $this->type;
69 }

References $type.

Referenced by copy(), and create().

+ 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 201 of file class.ilTaxonomyNode.php.

207 : void {
208 $tax_tree = new ilTaxonomyTree($a_tax_id);
209
210 // determine parent
211 $parent_id = ($a_parent_id != 0)
212 ? $a_parent_id
213 : $tax_tree->readRootId();
214
215 // determine target
216 if ($a_target_node_id != 0) {
217 $target = $a_target_node_id;
218 } else {
219 // determine last child that serves as predecessor
220 $childs = $tax_tree->getChilds($parent_id);
221
222 if (count($childs) == 0) {
223 $target = ilTree::POS_FIRST_NODE;
224 } else {
225 $target = $childs[count($childs) - 1]["obj_id"];
226 }
227 }
228
229 if ($tax_tree->isInTree($parent_id) && !$tax_tree->isInTree($a_node->getId())) {
230 $tax_tree->insertNode($a_node->getId(), $parent_id, $target);
231 }
232 }
const POS_FIRST_NODE

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

+ Here is the caller graph for this function:

◆ read()

ilTaxonomyNode::read ( )

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

101 : void
102 {
104
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);
110 }
111 $this->setType($this->data_record["type"]);
112 $this->setTitle($this->data_record["title"]);
113 $this->setOrderNr((int) $this->data_record["order_nr"]);
114 $this->setTaxonomyId((int) $this->data_record["tax_id"]);
115 }
setTaxonomyId(int $a_val)
setTitle(string $a_title)

References $db, $ilDB, 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 ( int  $a_id)

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

71 : void
72 {
73 $this->id = $a_id;
74 }

Referenced by create().

+ Here is the caller graph for this function:

◆ setOrderNr()

ilTaxonomyNode::setOrderNr ( int  $a_val)

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

81 : void
82 {
83 $this->order_nr = $a_val;
84 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTaxonomyId()

ilTaxonomyNode::setTaxonomyId ( int  $a_val)

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

91 : void
92 {
93 $this->taxonomy_id = $a_val;
94 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilTaxonomyNode::setTitle ( string  $a_title)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilTaxonomyNode::setType ( string  $a_type)

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

61 : void
62 {
63 $this->type = $a_type;
64 }

Referenced by __construct(), and read().

+ Here is the caller graph for this function:

◆ update()

ilTaxonomyNode::update ( )

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

140 : void
141 {
143
144 $query = "UPDATE tax_node SET " .
145 " title = " . $ilDB->quote($this->getTitle(), "text") .
146 " ,order_nr = " . $ilDB->quote((int) $this->getOrderNr(), "integer") .
147 " WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
148
149 $ilDB->manipulate($query);
150 }

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

+ Here is the call graph for this function:

◆ writeOrderNr()

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

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

235 : void
236 {
237 global $DIC;
238
239 $ilDB = $DIC->database();
240
241 $ilDB->manipulate(
242 "UPDATE tax_node SET " .
243 " order_nr = " . $ilDB->quote($a_order_nr, "integer") .
244 " WHERE obj_id = " . $ilDB->quote($a_node_id, "integer")
245 );
246 }

References $DIC, and $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

+ 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 251 of file class.ilTaxonomyNode.php.

251 : void
252 {
253 global $DIC;
254
255 $ilDB = $DIC->database();
256
257 $ilDB->manipulate(
258 "UPDATE tax_node SET " .
259 " title = " . $ilDB->quote($a_title, "text") .
260 " WHERE obj_id = " . $ilDB->quote($a_node_id, "integer")
261 );
262 }

References $DIC, and $ilDB.

Referenced by ilObjTaxonomyGUI\saveSorting().

+ Here is the caller graph for this function:

Field Documentation

◆ $data_record

array ilTaxonomyNode::$data_record = null
protected

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

◆ $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 create(), and 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: