ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
12 class ilLMTree extends ilTree
13 {
17  protected $db;
18 
19  public static $instances = array();
20 
26  public function __construct($a_tree_id)
27  {
28  global $DIC;
29 
30  $this->db = $DIC->database();
31  parent::__construct($a_tree_id);
32  $this->setTableNames('lm_tree', 'lm_data');
33  $this->setTreeTablePK("lm_id");
34  $this->useCache(true);
35  }
36 
43  public static function getInstance($a_tree_id)
44  {
45  if (isset(self::$instances[$a_tree_id])) {
46  return self::$instances[$a_tree_id];
47  }
48  $tree = new ilLMTree($a_tree_id);
49  self::$instances[$a_tree_id] = $tree;
50 
51  return $tree;
52  }
53 
54 
59  public function isCacheUsed()
60  {
61  return $this->use_cache;
62  }
63 
64 
65  public function getLastActivePage()
66  {
67  $ilDB = $this->db;
68 
69  $ilDB->setLimit(1);
70 
71  $sql = "SELECT lm_data.obj_id" .
72  " FROM lm_data" .
73  " JOIN lm_tree ON (lm_tree.child = lm_data.obj_id)" .
74  " JOIN page_object ON (page_object.page_id = lm_data.obj_id AND page_object.parent_type = " . $ilDB->quote("lm", "text") . ")" .
75  " WHERE lm_tree.lm_id = " . $ilDB->quote($this->tree_id, "integer") .
76  " AND lm_data.type = " . $ilDB->quote("pg", "text") .
77  " AND page_object.active = " . $ilDB->quote(1, "integer") .
78  " ORDER BY lm_tree.rgt DESC";
79  $set = $ilDB->query($sql);
80  $row = $ilDB->fetchAssoc($set);
81  return (int) $row["obj_id"];
82  }
83 }
global $DIC
Definition: saml.php:7
isCacheUsed()
Check if cache is active.
static $instances
static getInstance($a_tree_id)
Get Instance.
__construct($a_tree_id)
Constructor.
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 &#39;obj_id&#39; You may use...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
global $ilDB
useCache($a_use=true)
Use Cache (usually activated)