ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
62 
63  if (!isset($a_node_id)) {
64  $message = "No node_id given!";
65  $this->log->error($message);
67  }
68 
69  // init childs
70  $childs = array();
71 
72  // number of childs
73  $count = 0;
74 
75  // init order_clause
76  $order_clause = "";
77 
78  // set order_clause if sort order parameter is given
79  if (!empty($a_order)) {
80  $order_clause = "ORDER BY " . $a_order . " " . $a_direction;
81  } else {
82  $order_clause = "ORDER BY " . $this->table_tree . ".lft";
83  }
84 
85  //666
86 
87  $r = $ilDB->queryF(
88  "
89  SELECT * FROM " . $this->table_tree . " " .
90  $this->buildJoin() .
91  "WHERE parent = %s " .
92  "AND " . $this->table_tree . "." . $this->tree_pk . " = %s " .
93  $order_clause,
94  array('integer','integer'),
95  array($a_node_id,$this->tree_id)
96  );
97 
98  $count = $ilDB->numRows($r);
99 
100  if ($count > 0) {
101  while ($row = $ilDB->fetchAssoc($r)) {
102  $childs[] = $this->fetchNodeData($row);
103  }
104 
105  // mark the last child node (important for display)
106  $childs[$count - 1]["last"] = true;
107 
108  return $childs;
109  } else {
110  return $childs;
111  }
112  }
113 }
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...
Create styles array
The data for the language used.
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
global $ilDB