ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLMTree.php
Go to the documentation of this file.
1<?php
2
22class ilLMTree extends ilTree
23{
24 public static array $instances = [];
25 protected ?array $complete_tree = null;
26
27 public function __construct(
28 int $a_tree_id,
29 bool $read_root_id = true
30 ) {
31 parent::__construct($a_tree_id);
32 $this->setTableNames('lm_tree', 'lm_data');
33 $this->setTreeTablePK("lm_id");
34 $this->useCache(true);
35 if ($read_root_id) {
36 $this->readRootId();
37 }
38 }
39
40 public static function getInstance(
41 int $a_tree_id
42 ): self {
43 if (isset(self::$instances[$a_tree_id])) {
44 return self::$instances[$a_tree_id];
45 }
46 $tree = new ilLMTree($a_tree_id);
47 self::$instances[$a_tree_id] = $tree;
48
49 return $tree;
50 }
51
52 public function isCacheUsed(): bool
53 {
54 return $this->use_cache;
55 }
56
57 public function getLastActivePage(): int
58 {
59 $ilDB = $this->db;
60
61 $ilDB->setLimit(1, 0);
62
63 $sql = "SELECT lm_data.obj_id" .
64 " FROM lm_data" .
65 " JOIN lm_tree ON (lm_tree.child = lm_data.obj_id)" .
66 " JOIN page_object ON (page_object.page_id = lm_data.obj_id AND page_object.parent_type = " . $ilDB->quote("lm", "text") . ")" .
67 " WHERE lm_tree.lm_id = " . $ilDB->quote($this->tree_id, "integer") .
68 " AND lm_data.type = " . $ilDB->quote("pg", "text") .
69 " AND page_object.active = " . $ilDB->quote(1, "integer") .
70 " ORDER BY lm_tree.rgt DESC";
71 $set = $ilDB->query($sql);
72 $row = $ilDB->fetchAssoc($set);
73 return (int) ($row["obj_id"] ?? 0);
74 }
75
79 public function getCompleteTree(): array
80 {
81 if (is_null($this->complete_tree)) {
82 $this->complete_tree = $this->getSubTree($this->getNodeData($this->readRootId()));
83 }
84 return $this->complete_tree;
85 }
86}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_tree_id, bool $read_root_id=true)
isCacheUsed()
Check if cache is active.
static array $instances
getCompleteTree()
Get complete tree.
static getInstance(int $a_tree_id)
array $complete_tree
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)
setTreeTablePK(string $a_column_name)
set column containing primary key in tree 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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))