ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerStartObjectsContentTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('./Services/Table/classes/class.ilTable2GUI.php');
5 
14 {
15  protected $start_object; // [ilContainerStartObjects]
16  protected $item_list_guis; // [array]
17  protected $enable_desktop; // [bool]
18 
19  public function __construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects, $a_enable_desktop = true)
20  {
21  global $lng, $ilCtrl;
22 
23  $this->lng = $lng;
24  $this->ctrl = $ilCtrl;
25 
26  $this->start_object = $a_start_objects;
27  $this->enable_desktop = (bool)$a_enable_desktop;
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30 
31  $this->addColumn($this->lng->txt('crs_nr'),'nr');
32  $this->addColumn($this->lng->txt('title'),'title');
33  $this->addColumn($this->lng->txt('crs_objective_accomplished'), 'status');
34  $this->addColumn($this->lng->txt('actions'), '');
35 
36  $this->setTitle($this->lng->txt('crs_table_start_objects'));
37  $this->setDescription($this->lng->txt('crs_info_start'));
38 
39  $this->setRowTemplate("tpl.start_objects_content_row.html", "Services/Container");
40  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
41 
42  $this->setDefaultOrderField('nr');
43  $this->setDefaultOrderDirection('asc');
44 
45  $this->getItems();
46  }
47 
48  protected function getItems()
49  {
50  global $ilUser, $ilObjDataCache, $ilAccess;
51 
52  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
53  include_once './Services/Link/classes/class.ilLink.php';
54 
55  $lm_continue = new ilCourseLMHistory($this->start_object->getRefId(),$ilUser->getId());
56  $continue_data = $lm_continue->getLMHistory();
57 
58  $items = array();
59  $counter = 0;
60  foreach($this->start_object->getStartObjects() as $start)
61  {
62  $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
63  $ref_id = $start['item_ref_id'];
64  $type = $ilObjDataCache->lookupType($obj_id);
65 
66  if(!$ilAccess->checkAccess("visible", "", $ref_id))
67  {
68  continue;
69  }
70 
71  // start object status
72  if($this->start_object->isFullfilled($ilUser->getId(), $ref_id))
73  {
74  $accomplished = 'accomplished';
75  }
76  else
77  {
78  $accomplished = 'not_accomplished';
79  }
80 
81  // add/remove desktop
82  $actions = array();
83  if((bool)$this->enable_desktop)
84  {
85  // add to desktop link
86  if(!$ilUser->isDesktopItem($ref_id,$type))
87  {
88  if ($ilAccess->checkAccess('read','',$ref_id))
89  {
90  $this->ctrl->setParameter($this->getParentObject(),'item_ref_id',$ref_id);
91  $this->ctrl->setParameter($this->getParentObject(),'item_id',$ref_id);
92  $this->ctrl->setParameter($this->getParentObject(),'type',$type);
93  $url = $this->ctrl->getLinkTarget($this->getParentObject(),'addToDesk');
94  $actions[$url] = $this->lng->txt("to_desktop");
95  }
96  }
97  else
98  {
99  $this->ctrl->setParameter($this->getParentObject(),'item_ref_id',$ref_id);
100  $this->ctrl->setParameter($this->getParentObject(),'item_id',$ref_id);
101  $this->ctrl->setParameter($this->getParentObject(),'type',$type);
102  $url = $this->ctrl->getLinkTarget($this->getParentObject(),'removeFromDesk');
103  $actions[$url] = $this->lng->txt("unsubscribe");
104  }
105  }
106 
107  $default_params = null;
108  if($type == "tst")
109  {
110  $default_params["crs_show_result"] = $ref_id;
111  }
112  /* continue is currently inactive
113  if(isset($continue_data[$ref_id]))
114  {
115  // :TODO: should "continue" be default or 2nd link/action?
116  // $this->lng->txt('continue_work')
117  $default_params["obj_id"] = $continue_data[$ref_id]['lm_page_id'];
118  }
119  */
120 
121  if ($accomplished == 'accomplished')
122  {
123  $icon = ilUtil::getImagePath("icon_ok.svg");
124  }
125  else
126  {
127  $icon = ilUtil::getImagePath("icon_not_ok.svg");
128  }
129 
130  $items[] = array("nr" => ++$counter,
131  "obj_id" => $obj_id,
132  "ref_id" => $ref_id,
133  "type" => $type,
134  "append_default" => $default_params,
135  "title" => $ilObjDataCache->lookupTitle($obj_id),
136  "description" => $ilObjDataCache->lookupDescription($obj_id),
137  "status" => $this->lng->txt('crs_objective_'.$accomplished),
138  "status_img" => $icon,
139  "actions" => $actions);
140  }
141 
142  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
144  foreach($items as $item)
145  {
146  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
147  }
148  $preloader->preload();
149  unset($preloader);
150 
151  reset($items);
152  $this->setData($items);
153  }
154 
163  protected function getItemListGUI($a_type)
164  {
165  global $objDefinition;
166 
167  if (!isset($this->item_list_guis[$a_type]))
168  {
169  $class = $objDefinition->getClassName($a_type);
170  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
171  if(!$class)
172  {
173  return NULL;
174  }
175  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
176  $location = $objDefinition->getLocation($a_type);
177  if(!$location)
178  {
179  return NULL;
180  }
181  $full_class = "ilObj".$class."ListGUI";
182  include_once($location."/class.".$full_class.".php");
183  $item_list_gui = new $full_class();
184  $this->item_list_guis[$a_type] = $item_list_gui;
185  }
186  else
187  {
188  $item_list_gui = $this->item_list_guis[$a_type];
189  }
190 
191  $item_list_gui->setDefaultCommandParameters(array());
192 
193  return $item_list_gui;
194  }
195 
202  protected function getListItem($a_item)
203  {
204  $item_list_gui = $this->getItemListGUI($a_item["type"]);
205  if(!$item_list_gui)
206  {
207  return;
208  }
209 
210  $item_list_gui->setContainerObject($this);
211  $item_list_gui->enableCommands(true, true);
212 
213  // ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item);
214 
215  // notes, comment currently do not work properly
216  $item_list_gui->enableNotes(false);
217  $item_list_gui->enableComments(false);
218  $item_list_gui->enableTags(false);
219 
220  $item_list_gui->enableIcon(true);
221  $item_list_gui->enableDelete(false);
222  $item_list_gui->enableCut(false);
223  $item_list_gui->enableCopy(false);
224  $item_list_gui->enablePayment(false);
225  $item_list_gui->enableLink(false);
226  $item_list_gui->enableInfoScreen(true);
227  $item_list_gui->enableSubscribe(false);
228 
229  $level = 3;
230 
231  if ($level < 3)
232  {
233  $item_list_gui->enableDescription(false);
234  $item_list_gui->enableProperties(false);
235  $item_list_gui->enablePreconditions(false);
236  }
237 
238  if($a_item["append_default"])
239  {
240  $item_list_gui->setDefaultCommandParameters($a_item["append_default"]);
241  }
242  if (is_object($item_list_gui))
243  {
244  return $item_list_gui->getListItemHTML($a_item["ref_id"],
245  $a_item["obj_id"], $a_item["title"], $a_item["description"]);
246  }
247  }
248 
249  public function fillRow($a_set)
250  {
251  $this->tpl->setVariable("VAL_NR", $a_set["nr"]);
252 
253  // begin-patch lok
254  $this->tpl->setVariable("TXT_TITLE", $this->getListItem($a_set));
255  /*
256  include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
257  if(ilLOSettings::getInstanceByObjId($this->getParentObject()->object->getId())->isObjectiveTest($a_set['ref_id']))
258  {
259  $this->ctrl->setParameter($this->getParentObject(),'tid',$a_set['ref_id']);
260  $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'], $a_set['obj_id'], 'small'));
261  $this->tpl->setVariable('TITLE_MANUAL_LINK',$this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'redirectLocToTest'));
262  $this->tpl->setVariable('VAL_TITLE_MANUAL',$a_set['title']);
263  }
264  else
265  {
266  $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'], $a_set['obj_id'], 'small'));
267  include_once './Services/Link/classes/class.ilLink.php';
268  $this->tpl->setVariable('TITLE_MANUAL_LINK',ilLink::_getLink($a_set['ref_id']));
269  $this->tpl->setVariable('VAL_TITLE_MANUAL',$a_set['title']);
270  }
271  // end-patch lok
272  */
273 
274  $this->tpl->setVariable("TXT_STATUS", $a_set["status"]);
275  $this->tpl->setVariable("IMG_STATUS", $a_set["status_img"]);
276 
277  if($a_set["actions"])
278  {
279  $this->tpl->setCurrentBlock("link");
280  foreach($a_set["actions"] as $url => $caption)
281  {
282  $this->tpl->setVariable("LINK_HREF", $url);
283  $this->tpl->setVariable("LINK_NAME", $caption);
284  }
285  $this->tpl->parseCurrentBlock();
286  }
287  }
288 }
289 
290 ?>