ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 
4 include_once("./Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php");
5 include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
6 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
7 
17 {
18  protected $lp_cache; // [array]
19  protected $cnt_lmobj; // number of items (chapters and pages) in the explorer
20 
28  public function __construct($a_parent_obj, $a_parent_cmd, ilObjContentObject $a_lm, $a_id = "")
29  {
30  $this->lm = $a_lm;
31 
32  include_once("./Modules/LearningModule/classes/class.ilLMTree.php");
33  $tree = ilLMTree::getInstance($this->lm->getId());
34 
35 //echo "+".$tree->isCacheUsed()."+";
36 
37 // $tree = new ilTree($this->lm->getId());
38 // $tree->setTableNames('lm_tree','lm_data');
39 // $tree->setTreeTablePK("lm_id");
40 
41  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
42  $this->cnt_lmobj = ilLMObject::preloadDataByLM($this->lm->getId());
43 
44  include_once("./Services/COPage/classes/class.ilPageObject.php");
46 
47  if ($a_id == "")
48  {
49  $a_id = "lm_exp";
50 
51  // this does not work, since it is not set yet
52  if ($this->getOfflineMode())
53  {
54  $a_id = "lm_exp_off";
55  }
56  }
57 
58  parent::__construct($a_id, $a_parent_obj, $a_parent_cmd, $tree);
59 
60  $this->setSkipRootNode(false);
61  $this->setAjax(false);
62  $this->setPreloadChilds(true);
63 
64  if ((int) $_GET["obj_id"] > 0)
65  {
66  $this->setPathOpen((int) $_GET["obj_id"]);
67  }
68  }
69 
73  function beforeRendering()
74  {
75  if ($this->cnt_lmobj > 200 && !$this->getOfflineMode())
76  {
77  $this->setAjax(true);
78  }
79  }
80 
81 
88  function getNodeContent($a_node)
89  {
90  if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
91  {
92  return $this->lm->getTitle();
93  }
94 
95  $lang = ($_GET["transl"] != "")
96  ? $_GET["transl"]
97  : "-";
99  $this->lm->isActiveNumbering(), false, false, $this->lm->getId(), $lang);
100  }
101 
108  function isNodeHighlighted($a_node)
109  {
110  if ($a_node["child"] == $_GET["obj_id"] ||
111  ($_GET["obj_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode())))
112  {
113  return true;
114  }
115  return false;
116  }
117 
124  protected function checkLPIcon($a_id)
125  {
126  global $ilUser;
127 
128  // do it once for all chapters
129  if($this->lp_cache[$this->lm->getId()] === null)
130  {
131  $this->lp_cache[$this->lm->getId()] = false;
132 
133  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
134  if(ilLearningProgressAccess::checkAccess($this->lm->getRefId()))
135  {
136  $info = null;
137 
138  include_once './Services/Object/classes/class.ilObjectLP.php';
139  $olp = ilObjectLP::getInstance($this->lm->getId());
140  if($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
141  $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT)
142  {
143  include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
144  $class = ilLPStatusFactory::_getClassById($this->lm->getId(), $olp->getCurrentMode());
145  $info = $class::_getStatusInfo($this->lm->getId());
146  }
147 
148  // parse collection items
149  if(is_array($info["items"]))
150  {
151  foreach($info["items"] as $item_id)
152  {
154  if(is_array($info["in_progress"][$item_id]) &&
155  in_array($ilUser->getId(), $info["in_progress"][$item_id]))
156  {
158  }
159  else if(is_array($info["completed"][$item_id]) &&
160  in_array($ilUser->getId(), $info["completed"][$item_id]))
161  {
163  }
164  $this->lp_cache[$this->lm->getId()][$item_id] =$status;
165  }
166  }
167  }
168 
169  include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
170  }
171 
172  if(is_array($this->lp_cache[$this->lm->getId()]) &&
173  isset($this->lp_cache[$this->lm->getId()][$a_id]))
174  {
175  return ilLearningProgressBaseGUI::_getImagePathForStatus($this->lp_cache[$this->lm->getId()][$a_id]);
176  }
177 
178  return "";
179  }
180 
181 }
182 
183 ?>
const LP_STATUS_COMPLETED_NUM
beforeRendering()
Before rendering.
const IL_PAGE_TITLE
$_GET["client_id"]
setSkipRootNode($a_val)
Set skip root node.
const LP_STATUS_IN_PROGRESS_NUM
_getImagePathForStatus($a_status)
Get image path for status.
setPathOpen($a_id)
Set node path to be opened.
isNodeHighlighted($a_node)
Is node highlighted?
setPreloadChilds($a_val)
Set preload childs.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
$info
Definition: example_052.php:80
checkLPIcon($a_id)
Check learning progress icon.
static getInstance($a_tree_id)
Get Instance.
static preloadDataByLM($a_lm_id)
Preload data records by lm.
LM editor explorer GUI class.
getNodeId($a_node)
Get id for node.
getOfflineMode()
Get offline mode.
const LP_STATUS_NOT_ATTEMPTED_NUM
getRootNode()
Get root node.
global $ilUser
Definition: imgupload.php:15
Explorer class that works on tree objects (Services/Tree)
static preloadActivationDataByParentId($a_parent_id)
Preload activation data by Parent Id.
__construct($a_parent_obj, $a_parent_cmd, ilObjContentObject $a_lm, $a_id="")
Constructor.
Class ilObjContentObject.
getNodeContent($a_node)
Get node content.
static getInstance($a_obj_id)
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.
_getClassById($a_obj_id, $a_mode=NULL)