ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilECSCmsTree.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Tree/classes/class.ilTree.php';
5
12class ilECSCmsTree extends ilTree
13{
14 public function __construct($a_tree_id)
15 {
16 parent::__construct($a_tree_id, self::lookupRootId($a_tree_id));
17
18 $this->setObjectTablePK('obj_id');
19 $this->setTableNames('ecs_cms_tree', 'ecs_cms_data');
20 $this->useCache(false);
21 }
22
23 public function insertRootNode($tree, $a_child)
24 {
25 global $ilDB;
26
27 $query = 'INSERT INTO ecs_cms_tree '.
28 '(tree,child,parent,lft,rgt,depth) '.
29 'VALUES ( '.
30 $ilDB->quote($tree,'integer').', '.
31 $ilDB->quote($a_child,'integer').', '.
32 $ilDB->quote(0,'integer').', '.
33 $ilDB->quote(1,'integer').', '.
34 $ilDB->quote(100,'integer').', '.
35 $ilDB->quote(1,'integer').' )';
36
37 $ilDB->manipulate($query);
38
39
40 return true;
41 }
42
46 public static function deleteByTreeId($a_tree_id)
47 {
48 global $ilDB;
49
50 $query = 'DELETE FROM ecs_cms_tree '.
51 'WHERE tree = '.$ilDB->quote($a_tree_id,'integer');
52 $ilDB->manipulate($query);
53 return true;
54 }
55
60 public function treeExists($a_tree_id)
61 {
62 global $ilDB;
63
64 $query = 'SELECT COUNT(*) num FROM ecs_cms_tree WHERE tree = '.$ilDB->quote($a_tree_id,'integer');
65 $res = $ilDB->query($query);
66 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
67 {
68 return $row->num > 0 ? true : false;
69 }
70 return false;
71 }
72
73
77 public static function lookupRootId($a_tree_id)
78 {
79 global $ilDB;
80
81 $query = 'SELECT child FROM ecs_cms_tree WHERE tree = '.$ilDB->quote($a_tree_id,'integer');
82 $res = $ilDB->query($query);
83 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
84 {
85 return $row->child;
86 }
87 return 0;
88 }
89}
90?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static lookupRootId($a_tree_id)
lookup root id
insertRootNode($tree, $a_child)
treeExists($a_tree_id)
Check if tree exists.
static deleteByTreeId($a_tree_id)
Delete tree by tree_id.
__construct($a_tree_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setObjectTablePK($a_column_name)
set column containing primary key in object table @access public
useCache($a_use=true)
Use Cache (usually activated)
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 'obj_id' You may use...
global $ilDB