ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMTree.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12class ilLMTree extends ilTree
13{
17 protected $db;
18
19 public static $instances = array();
20
24 protected $complete_tree;
25
31 public function __construct($a_tree_id)
32 {
33 global $DIC;
34
35 $this->db = $DIC->database();
36 parent::__construct($a_tree_id);
37 $this->setTableNames('lm_tree', 'lm_data');
38 $this->setTreeTablePK("lm_id");
39 $this->useCache(true);
40 }
41
48 public static function getInstance($a_tree_id)
49 {
50 if (isset(self::$instances[$a_tree_id])) {
51 return self::$instances[$a_tree_id];
52 }
53 $tree = new ilLMTree($a_tree_id);
54 self::$instances[$a_tree_id] = $tree;
55
56 return $tree;
57 }
58
59
64 public function isCacheUsed()
65 {
66 return $this->use_cache;
67 }
68
69
70 public function getLastActivePage()
71 {
73
74 $ilDB->setLimit(1);
75
76 $sql = "SELECT lm_data.obj_id" .
77 " FROM lm_data" .
78 " JOIN lm_tree ON (lm_tree.child = lm_data.obj_id)" .
79 " JOIN page_object ON (page_object.page_id = lm_data.obj_id AND page_object.parent_type = " . $ilDB->quote("lm", "text") . ")" .
80 " WHERE lm_tree.lm_id = " . $ilDB->quote($this->tree_id, "integer") .
81 " AND lm_data.type = " . $ilDB->quote("pg", "text") .
82 " AND page_object.active = " . $ilDB->quote(1, "integer") .
83 " ORDER BY lm_tree.rgt DESC";
84 $set = $ilDB->query($sql);
85 $row = $ilDB->fetchAssoc($set);
86 return (int) $row["obj_id"];
87 }
88
92 public function getCompleteTree()
93 {
94 if (is_null($this->complete_tree)) {
95 $this->complete_tree = $this->getSubTree($this->getNodeData($this->readRootId()));
96 }
98 }
99}
An exception for terminatinating execution or to throw for unit testing.
static getInstance($a_tree_id)
Get Instance.
__construct($a_tree_id)
Constructor.
isCacheUsed()
Check if cache is active.
static $instances
getCompleteTree()
Get complete tree.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getSubTree($a_node, $a_with_data=true, $a_type="")
get all nodes in the subtree under specified node
useCache($a_use=true)
Use Cache (usually activated)
setTreeTablePK($a_column_name)
set column containing primary key in tree table @access public
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...
readRootId()
read root id from database
getNodeData($a_node_id, $a_tree_pk=null)
get all information of a node.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB