ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLMExplorerGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
18 protected $user;
19
20 protected $lp_cache; // [array]
21 protected $cnt_lmobj; // number of items (chapters and pages) in the explorer
22
30 public function __construct($a_parent_obj, $a_parent_cmd, ilObjContentObject $a_lm, $a_id = "")
31 {
32 global $DIC;
33
34 $this->user = $DIC->user();
35 $this->lm = $a_lm;
36
37 $tree = ilLMTree::getInstance($this->lm->getId());
38
39 $this->cnt_lmobj = ilLMObject::preloadDataByLM($this->lm->getId());
40
42
43 if ($a_id == "") {
44 $a_id = "lm_exp";
45
46 // this does not work, since it is not set yet
47 if ($this->getOfflineMode()) {
48 $a_id = "lm_exp_off";
49 }
50 }
51
52 parent::__construct($a_id, $a_parent_obj, $a_parent_cmd, $tree);
53
54 $this->setSkipRootNode(false);
55 $this->setAjax(false);
56 $this->setPreloadChilds(true);
57
58 $this->setPathOpen($tree->readRootId());
59
60 if ((int) $_GET["obj_id"] > 0) {
61 $this->setPathOpen((int) $_GET["obj_id"]);
62 }
63 }
64
68 public function beforeRendering()
69 {
70 if ($this->cnt_lmobj > 200 && !$this->getOfflineMode()) {
71 $class = (is_object($this->parent_obj))
72 ? get_class($this->parent_obj)
74 $this->ctrl->setParameterByClass($class, "obj_id", $_GET["obj_id"]);
75 $this->setAjax(true);
76 }
77 }
78
79
86 public function getNodeContent($a_node)
87 {
88 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
89 return $this->lm->getTitle();
90 }
91
92 $lang = ($_GET["transl"] != "")
93 ? $_GET["transl"]
94 : "-";
96 $a_node,
98 $this->lm->isActiveNumbering(),
99 false,
100 false,
101 $this->lm->getId(),
102 $lang
103 );
104 }
105
112 public function isNodeHighlighted($a_node)
113 {
114 if ($a_node["child"] == $_GET["obj_id"] ||
115 ($_GET["obj_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) {
116 return true;
117 }
118 return false;
119 }
120
127 protected function checkLPIcon($a_id)
128 {
130
131 // do it once for all chapters
132 if ($this->lp_cache[$this->lm->getId()] === null) {
133 $this->lp_cache[$this->lm->getId()] = false;
134
135 if (ilLearningProgressAccess::checkAccess($this->lm->getRefId())) {
136 $info = null;
137
138 $olp = ilObjectLP::getInstance($this->lm->getId());
139 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
140 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
141 $class = ilLPStatusFactory::_getClassById($this->lm->getId(), $olp->getCurrentMode());
142 $info = $class::_getStatusInfo($this->lm->getId());
143 }
144
145 // parse collection items
146 if (is_array($info["items"])) {
147 foreach ($info["items"] as $item_id) {
149 if (is_array($info["in_progress"][$item_id]) &&
150 in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
152 } elseif (is_array($info["completed"][$item_id]) &&
153 in_array($ilUser->getId(), $info["completed"][$item_id])) {
155 }
156 $this->lp_cache[$this->lm->getId()][$item_id] = $status;
157 }
158 }
159 }
160 }
161
162 if (is_array($this->lp_cache[$this->lm->getId()]) &&
163 isset($this->lp_cache[$this->lm->getId()][$a_id])) {
164 return ilLearningProgressBaseGUI::_getImagePathForStatus($this->lp_cache[$this->lm->getId()][$a_id]);
165 }
166
167 return "";
168 }
169}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
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=self::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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilUser
Definition: imgupload.php:18
$lang
Definition: xapiexit.php:8
$DIC
Definition: xapitoken.php:46