ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSCORMTree.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
28class ilSCORMTree extends ilTree
29{
34 public function __construct(int $a_id = 0)
35 {
37 $this->setTableNames('scorm_tree', 'scorm_object');
38 $this->setTreeTablePK('slm_id');
39 }
40
48 public function getChilds(int $a_node_id, string $a_order = "", string $a_direction = "ASC"): array
49 {
50 global $DIC;
51 $ilDB = $DIC->database();
52
53 if (!isset($a_node_id)) {
54 $message = "No node_id given!";
55 $this->logger->error($message);
56 throw new InvalidArgumentException($message);
57 }
58
59 // init childs
60 $childs = array();
61
62 // number of childs
63 $count = 0;
64
65 // init order_clause
66 $order_clause = "";
67
68 // set order_clause if sort order parameter is given
69 if (!empty($a_order)) {
70 $order_clause = "ORDER BY " . $a_order . " " . $a_direction;
71 } else {
72 $order_clause = "ORDER BY " . $this->table_tree . ".lft";
73 }
74
75 $r = $ilDB->queryF(
76 "
77 SELECT * FROM " . $this->table_tree . " " .
78 $this->buildJoin() .
79 "WHERE parent = %s " .
80 "AND " . $this->table_tree . "." . $this->tree_pk . " = %s " .
81 $order_clause,
82 array('integer','integer'),
83 array($a_node_id,$this->tree_id)
84 );
85
86 $count = $ilDB->numRows($r);
87
88 if ($count > 0) {
89 while ($row = $ilDB->fetchAssoc($r)) {
90 $childs[] = $this->fetchNodeData($row);
91 }
92
93 // mark the last child node (important for display)
94 $childs[$count - 1]["last"] = true;
95
96 return $childs;
97 }
98
99 return $childs;
100 }
101}
SCORM Object Tree.
__construct(int $a_id=0)
Constructor.
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
fetchNodeData(array $a_row)
get data of parent node from tree and object_data
setTreeTablePK(string $a_column_name)
set column containing primary key in tree table
setTableNames(string $a_table_tree, string $a_table_obj_data, string $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
buildJoin()
build join depending on table settings @access private
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31