ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  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  function getChilds($a_node_id, $a_order = "", $a_direction = "ASC")
60  {
61  global $ilDB;
62 
63  if (!isset($a_node_id))
64  {
65  $message = "No node_id given!";
66  $this->log->error($message);
67  throw new InvalidArgumentException($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  {
82  $order_clause = "ORDER BY ".$a_order." ".$a_direction;
83  }
84  else
85  {
86  $order_clause = "ORDER BY ".$this->table_tree.".lft";
87  }
88 
89  //666
90 
91  $r = $ilDB->queryF("
92  SELECT * FROM ".$this->table_tree." ".
93  $this->buildJoin().
94  "WHERE parent = %s ".
95  "AND ".$this->table_tree.".".$this->tree_pk." = %s ".
96  $order_clause,
97  array('integer','integer'),array($a_node_id,$this->tree_id));
98 
99  $count = $ilDB->numRows($r);
100 
101  if ($count > 0)
102  {
103  while ($row = $ilDB->fetchAssoc($r))
104  {
105  $childs[] = $this->fetchNodeData($row);
106  }
107 
108  // mark the last child node (important for display)
109  $childs[$count - 1]["last"] = true;
110 
111  return $childs;
112  }
113  else
114  {
115  return $childs;
116  }
117  }
118 }
119 ?>
fetchNodeData($a_row)
get data of parent node from tree and object_data private
$r
Definition: example_031.php:79
__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...
Create styles array
The data for the language used.
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
global $ilDB