ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLMExplorerGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php");
5include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
6include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
7
17{
21 protected $user;
22
23 protected $lp_cache; // [array]
24 protected $cnt_lmobj; // number of items (chapters and pages) in the explorer
25
33 public function __construct($a_parent_obj, $a_parent_cmd, ilObjContentObject $a_lm, $a_id = "")
34 {
35 global $DIC;
36
37 $this->user = $DIC->user();
38 $this->lm = $a_lm;
39
40 include_once("./Modules/LearningModule/classes/class.ilLMTree.php");
41 $tree = ilLMTree::getInstance($this->lm->getId());
42
43 //echo "+".$tree->isCacheUsed()."+";
44
45 // $tree = new ilTree($this->lm->getId());
46 // $tree->setTableNames('lm_tree','lm_data');
47 // $tree->setTreeTablePK("lm_id");
48
49 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
50 $this->cnt_lmobj = ilLMObject::preloadDataByLM($this->lm->getId());
51
52 include_once("./Services/COPage/classes/class.ilPageObject.php");
54
55 if ($a_id == "") {
56 $a_id = "lm_exp";
57
58 // this does not work, since it is not set yet
59 if ($this->getOfflineMode()) {
60 $a_id = "lm_exp_off";
61 }
62 }
63
64 parent::__construct($a_id, $a_parent_obj, $a_parent_cmd, $tree);
65
66 $this->setSkipRootNode(false);
67 $this->setAjax(false);
68 $this->setPreloadChilds(true);
69
70 if ((int) $_GET["obj_id"] > 0) {
71 $this->setPathOpen((int) $_GET["obj_id"]);
72 }
73 }
74
78 public function beforeRendering()
79 {
80 if ($this->cnt_lmobj > 200 && !$this->getOfflineMode()) {
81 $this->setAjax(true);
82 }
83 }
84
85
92 public function getNodeContent($a_node)
93 {
94 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
95 return $this->lm->getTitle();
96 }
97
98 $lang = ($_GET["transl"] != "")
99 ? $_GET["transl"]
100 : "-";
102 $a_node,
104 $this->lm->isActiveNumbering(),
105 false,
106 false,
107 $this->lm->getId(),
108 $lang
109 );
110 }
111
118 public function isNodeHighlighted($a_node)
119 {
120 if ($a_node["child"] == $_GET["obj_id"] ||
121 ($_GET["obj_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) {
122 return true;
123 }
124 return false;
125 }
126
133 protected function checkLPIcon($a_id)
134 {
136
137 // do it once for all chapters
138 if ($this->lp_cache[$this->lm->getId()] === null) {
139 $this->lp_cache[$this->lm->getId()] = false;
140
141 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
142 if (ilLearningProgressAccess::checkAccess($this->lm->getRefId())) {
143 $info = null;
144
145 include_once './Services/Object/classes/class.ilObjectLP.php';
146 $olp = ilObjectLP::getInstance($this->lm->getId());
147 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
148 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
149 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
150 $class = ilLPStatusFactory::_getClassById($this->lm->getId(), $olp->getCurrentMode());
151 $info = $class::_getStatusInfo($this->lm->getId());
152 }
153
154 // parse collection items
155 if (is_array($info["items"])) {
156 foreach ($info["items"] as $item_id) {
158 if (is_array($info["in_progress"][$item_id]) &&
159 in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
161 } elseif (is_array($info["completed"][$item_id]) &&
162 in_array($ilUser->getId(), $info["completed"][$item_id])) {
164 }
165 $this->lp_cache[$this->lm->getId()][$item_id] =$status;
166 }
167 }
168 }
169
170 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
171 }
172
173 if (is_array($this->lp_cache[$this->lm->getId()]) &&
174 isset($this->lp_cache[$this->lm->getId()][$a_id])) {
175 return ilLearningProgressBaseGUI::_getImagePathForStatus($this->lp_cache[$this->lm->getId()][$a_id]);
176 }
177
178 return "";
179 }
180}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_PAGE_TITLE
getOfflineMode()
Get offline mode.
setSkipRootNode($a_val)
Set skip root node.
LM editor explorer GUI class.
getNodeContent($a_node)
Get node content.
beforeRendering()
Before rendering.
__construct($a_parent_obj, $a_parent_cmd, ilObjContentObject $a_lm, $a_id="")
Constructor.
checkLPIcon($a_id)
Check learning progress icon.
isNodeHighlighted($a_node)
Is node highlighted?
static preloadDataByLM($a_lm_id)
Preload data records by lm.
static _getPresentationTitle( $a_node, $a_mode=IL_PAGE_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-")
Get affective title.
static getInstance($a_tree_id)
Get Instance.
static _getClassById($a_obj_id, $a_mode=null)
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
static _getImagePathForStatus($a_status)
Get image path for status.
Class ilObjContentObject.
static getInstance($a_obj_id)
static preloadActivationDataByParentId($a_parent_id)
Preload activation data by Parent Id.
Explorer class that works on tree objects (Services/Tree)
setPathOpen($a_id)
Set node path to be opened.
getNodeId($a_node)
Get id for node.
setPreloadChilds($a_val)
Set preload childs.
$lang
Definition: consent.php:3
$info
Definition: index.php:5
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18