ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $GLOBALS['DIC']->logger()->wsrv()->debug('Deleting cms tree: ' . $a_tree_id);
51 $query = 'DELETE FROM ecs_cms_tree '.
52 'WHERE tree = '.$ilDB->quote($a_tree_id,'integer');
53 $ilDB->manipulate($query);
54 return true;
55 }
56
61 public function treeExists($a_tree_id)
62 {
63 global $ilDB;
64
65 $query = 'SELECT COUNT(*) num FROM ecs_cms_tree WHERE tree = '.$ilDB->quote($a_tree_id,'integer');
66 $res = $ilDB->query($query);
67 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
68 {
69 return $row->num > 0 ? true : false;
70 }
71 return false;
72 }
73
74
78 public static function lookupRootId($a_tree_id)
79 {
80 global $ilDB;
81
82 $query = 'SELECT child FROM ecs_cms_tree WHERE tree = '.$ilDB->quote($a_tree_id,'integer');
83 $res = $ilDB->query($query);
84 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
85 {
86 return $row->child;
87 }
88 return 0;
89 }
90}
91?>
An exception for terminatinating execution or to throw for unit testing.
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...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilDB