ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $this->setPathOpen($tree->readRootId());
71
72 if ((int) $_GET["obj_id"] > 0) {
73 $this->setPathOpen((int) $_GET["obj_id"]);
74 }
75 }
76
80 public function beforeRendering()
81 {
82 if ($this->cnt_lmobj > 200 && !$this->getOfflineMode()) {
83 $this->ctrl->setParameter($this->parent_obj, "obj_id", $_GET["obj_id"]);
84 $this->setAjax(true);
85 }
86 }
87
88
95 public function getNodeContent($a_node)
96 {
97 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
98 return $this->lm->getTitle();
99 }
100
101 $lang = ($_GET["transl"] != "")
102 ? $_GET["transl"]
103 : "-";
105 $a_node,
107 $this->lm->isActiveNumbering(),
108 false,
109 false,
110 $this->lm->getId(),
111 $lang
112 );
113 }
114
121 public function isNodeHighlighted($a_node)
122 {
123 if ($a_node["child"] == $_GET["obj_id"] ||
124 ($_GET["obj_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) {
125 return true;
126 }
127 return false;
128 }
129
136 protected function checkLPIcon($a_id)
137 {
139
140 // do it once for all chapters
141 if ($this->lp_cache[$this->lm->getId()] === null) {
142 $this->lp_cache[$this->lm->getId()] = false;
143
144 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
145 if (ilLearningProgressAccess::checkAccess($this->lm->getRefId())) {
146 $info = null;
147
148 include_once './Services/Object/classes/class.ilObjectLP.php';
149 $olp = ilObjectLP::getInstance($this->lm->getId());
150 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
151 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
152 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
153 $class = ilLPStatusFactory::_getClassById($this->lm->getId(), $olp->getCurrentMode());
154 $info = $class::_getStatusInfo($this->lm->getId());
155 }
156
157 // parse collection items
158 if (is_array($info["items"])) {
159 foreach ($info["items"] as $item_id) {
161 if (is_array($info["in_progress"][$item_id]) &&
162 in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
164 } elseif (is_array($info["completed"][$item_id]) &&
165 in_array($ilUser->getId(), $info["completed"][$item_id])) {
167 }
168 $this->lp_cache[$this->lm->getId()][$item_id] = $status;
169 }
170 }
171 }
172
173 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
174 }
175
176 if (is_array($this->lp_cache[$this->lm->getId()]) &&
177 isset($this->lp_cache[$this->lm->getId()][$a_id])) {
178 return ilLearningProgressBaseGUI::_getImagePathForStatus($this->lp_cache[$this->lm->getId()][$a_id]);
179 }
180
181 return "";
182 }
183}
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.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$info
Definition: index.php:5
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18