ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSCmsTree.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24class ilECSCmsTree extends ilTree
25{
26 public function __construct(int $a_tree_id)
27 {
28 parent::__construct($a_tree_id, self::lookupRootId($a_tree_id));
29
30 $this->setObjectTablePK('obj_id');
31 $this->setTableNames('ecs_cms_tree', 'ecs_cms_data');
32 $this->useCache(false);
33 }
34
35 public function insertRootNode(int $tree, int $a_child): bool
36 {
37 $query = 'INSERT INTO ecs_cms_tree ' .
38 '(tree,child,parent,lft,rgt,depth) ' .
39 'VALUES ( ' .
40 $this->db->quote($tree, 'integer') . ', ' .
41 $this->db->quote($a_child, 'integer') . ', ' .
42 $this->db->quote(0, 'integer') . ', ' .
43 $this->db->quote(1, 'integer') . ', ' .
44 $this->db->quote(100, 'integer') . ', ' .
45 $this->db->quote(1, 'integer') . ' )';
46
47 $this->db->manipulate($query);
48
49 return true;
50 }
51
55 public static function deleteByTreeId(int $a_tree_id): bool
56 {
57 global $DIC;
58
59 $ilDB = $DIC['ilDB'];
60
61 $DIC->logger()->wsrv()->debug('Deleting cms tree: ' . $a_tree_id);
62 $query = 'DELETE FROM ecs_cms_tree ' .
63 'WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
64 $ilDB->manipulate($query);
65 return true;
66 }
67
71 public function treeExists(int $a_tree_id): bool
72 {
73 $query = 'SELECT COUNT(*) num FROM ecs_cms_tree WHERE tree = ' . $this->db->quote($a_tree_id, 'integer');
74 $res = $this->db->query($query);
75 if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
76 return $row->num > 0;
77 }
78 return false;
79 }
80
81
85 public static function lookupRootId($a_tree_id): int
86 {
87 global $DIC;
88
89 $ilDB = $DIC['ilDB'];
90
91 $query = 'SELECT child FROM ecs_cms_tree WHERE tree = ' . $ilDB->quote($a_tree_id, 'integer');
92 $res = $ilDB->query($query);
93 if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
94 return (int) $row->child;
95 }
96 return 0;
97 }
98}
static lookupRootId($a_tree_id)
lookup root id
static deleteByTreeId(int $a_tree_id)
Delete tree by tree_id.
__construct(int $a_tree_id)
insertRootNode(int $tree, int $a_child)
treeExists(int $a_tree_id)
Check if tree exists.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
useCache(bool $a_use=true)
Use Cache (usually activated)
setObjectTablePK(string $a_column_name)
set column containing primary key in object table
setTableNames(string $a_table_tree, string $a_table_obj_data, string $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26