ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCORMTree.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/Tree/classes/class.ilTree.php");
25 
34 class ilSCORMTree extends ilTree
35 {
36 
43  public function __construct($a_id = 0)
44  {
45  parent::__construct($a_id);
46  $this->setTableNames('scorm_tree', 'scorm_object');
47  $this->setTreeTablePK('slm_id');
48  }
49 
59  public function getChilds($a_node_id, $a_order = "", $a_direction = "ASC")
60  {
61  global $DIC;
62  $ilDB = $DIC['ilDB'];
63 
64  if (!isset($a_node_id)) {
65  $message = "No node_id given!";
66  $this->log->error($message);
68  }
69 
70  // init childs
71  $childs = array();
72 
73  // number of childs
74  $count = 0;
75 
76  // init order_clause
77  $order_clause = "";
78 
79  // set order_clause if sort order parameter is given
80  if (!empty($a_order)) {
81  $order_clause = "ORDER BY " . $a_order . " " . $a_direction;
82  } else {
83  $order_clause = "ORDER BY " . $this->table_tree . ".lft";
84  }
85 
86  //666
87 
88  $r = $ilDB->queryF(
89  "
90  SELECT * FROM " . $this->table_tree . " " .
91  $this->buildJoin() .
92  "WHERE parent = %s " .
93  "AND " . $this->table_tree . "." . $this->tree_pk . " = %s " .
94  $order_clause,
95  array('integer','integer'),
96  array($a_node_id,$this->tree_id)
97  );
98 
99  $count = $ilDB->numRows($r);
100 
101  if ($count > 0) {
102  while ($row = $ilDB->fetchAssoc($r)) {
103  $childs[] = $this->fetchNodeData($row);
104  }
105 
106  // mark the last child node (important for display)
107  $childs[$count - 1]["last"] = true;
108 
109  return $childs;
110  } else {
111  return $childs;
112  }
113  }
114 }
global $DIC
Definition: saml.php:7
fetchNodeData($a_row)
get data of parent node from tree and object_data private
buildJoin()
build join depending on table settings private
$r
Definition: example_031.php:79
catch(Exception $e) $message
__construct($a_id=0)
Constructor.
getChilds($a_node_id, $a_order="", $a_direction="ASC")
get child nodes of given node public
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be &#39;obj_id&#39; You may use...
SCORM Object Tree.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
$row
global $ilDB