ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
26
27 $ilDB = $DIC['ilDB'];
28
29 $query = 'INSERT INTO ecs_cms_tree ' .
30 '(tree,child,parent,lft,rgt,depth) ' .
31 'VALUES ( ' .
32 $ilDB->quote($tree, 'integer') . ', ' .
33 $ilDB->quote($a_child, 'integer') . ', ' .
34 $ilDB->quote(0, 'integer') . ', ' .
35 $ilDB->quote(1, 'integer') . ', ' .
36 $ilDB->quote(100, 'integer') . ', ' .
37 $ilDB->quote(1, 'integer') . ' )';
38
39 $ilDB->manipulate($query);
40
41
42 return true;
43 }
44
48 public static function deleteByTreeId($a_tree_id)
49 {
50 global $DIC;
51
52 $ilDB = $DIC['ilDB'];
53
54 $GLOBALS['DIC']->logger()->wsrv()->debug('Deleting cms tree: ' . $a_tree_id);
55 $query = 'DELETE FROM ecs_cms_tree ' .
56 'WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
57 $ilDB->manipulate($query);
58 return true;
59 }
60
65 public function treeExists($a_tree_id)
66 {
67 global $DIC;
68
69 $ilDB = $DIC['ilDB'];
70
71 $query = 'SELECT COUNT(*) num FROM ecs_cms_tree WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
72 $res = $ilDB->query($query);
73 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
74 return $row->num > 0 ? true : false;
75 }
76 return false;
77 }
78
79
83 public static function lookupRootId($a_tree_id)
84 {
85 global $DIC;
86
87 $ilDB = $DIC['ilDB'];
88
89 $query = 'SELECT child FROM ecs_cms_tree WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
90 $res = $ilDB->query($query);
91 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
92 return $row->child;
93 }
94 return 0;
95 }
96}
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...
$row
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB