ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPObjectsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
5 
16 {
20  function __construct($a_parent_obj, $a_parent_cmd, $a_type = "")
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng;
23 
24  $this->setId("lpobjtbl");
25 
26  parent::__construct($a_parent_obj, $a_parent_cmd);
27  $this->setTitle($this->lng->txt("learning_progress"));
28  $this->setDescription($this->lng->txt("trac_learning_progress_objects_description"));
29  $this->setLimit(9999);
30 
31  $this->addColumn("", "", "1", true);
32  $this->addColumn($this->lng->txt("trac_title"), "title", "30%");
33 
34  include_once("Services/Tracking/classes/class.ilLPStatus.php");
35  $all_status = array(LP_STATUS_NOT_ATTEMPTED_NUM => "status_not_attempted",
36  LP_STATUS_IN_PROGRESS_NUM => "status_in_progress",
37  LP_STATUS_COMPLETED_NUM => "status_completed",
38  LP_STATUS_FAILED_NUM => "status_failed");
39  foreach($all_status as $status => $column)
40  {
42  $caption = "<img src=\"".ilLearningProgressBaseGUI::_getImagePathForStatus($status)."\" alt=\"".$caption."\" title=\"".$caption."\" /> ".$caption;
43 
44  $this->addColumn($caption, $column, "10%");
45  }
46 
47  $this->addColumn($this->lng->txt("path"), "", "20%");
48  $this->addColumn($this->lng->txt("actions"), "", "10%");
49 
50  $this->setEnableHeader(true);
51  $this->setFormAction($ilCtrl->getFormActionByClass(get_class($this)));
52  $this->setRowTemplate("tpl.lp_object_list_row.html", "Services/Tracking");
53  #$this->disable("footer");
54  $this->setEnableHeader(true);
55  $this->setEnableNumInfo(true);
56  $this->setEnableTitle(true);
57  $this->setShowTemplates(true);
58 
59  $this->initFilter();
60 
61  $this->setSelectAllCheckbox("item_id");
62 
63  $this->addMultiCommand("hideSelected", $lng->txt("trac_hide_selected"));
64 
65  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
66 
67  $this->getItems();
68  }
69 
70  function getItems()
71  {
72  $obj_ids = $this->obj_ids;
73  if(!$obj_ids)
74  {
75  $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "edit_learning_progress");
76  }
77  if($obj_ids)
78  {
79  $this->is_anonymized = !ilObjUserTracking::_enabledUserRelatedData();
80 
81  include_once("./Services/Tracking/classes/class.ilTrQuery.php");
83  foreach($data as $idx => $item)
84  {
85  $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]);
86  }
87 
88  $this->setData($data);
89  }
90  }
91 
95  protected function fillRow($a_set)
96  {
97  global $lng, $ilObjDataCache, $ilCtrl;
98 
99  $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
100  $this->tpl->setVariable("ICON_SRC", ilUtil::getTypeIconPath($a_set["type"], $a_set["obj_id"], "tiny"));
101  $this->tpl->setVariable("ICON_ALT", $lng->txt($a_set["type"]));
102  $this->tpl->setVariable("TITLE_TEXT", $a_set["title"]);
103 
104  if($a_set["offline"])
105  {
106  $this->tpl->setCurrentBlock("offline");
107  $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("status"));
108  $this->tpl->setVariable("TEXT_OFFLINE", $this->lng->txt("offline"));
109  $this->tpl->parseCurrentBlock();
110  }
111 
112  $this->tpl->setVariable("STATUS_NOT_ATTEMPTED_VALUE", $a_set["status_not_attempted"]);
113  $this->tpl->setVariable("STATUS_IN_PROGRESS_VALUE", $a_set["status_in_progress"]);
114  $this->tpl->setVariable("STATUS_COMPLETED_VALUE", $a_set["status_completed"]);
115  $this->tpl->setVariable("STATUS_FAILED_VALUE", $a_set["status_failed"]);
116 
117  // path
118  $path = $this->buildPath($a_set["ref_ids"]);
119  if($path)
120  {
121  $this->tpl->setCurrentBlock("item_path");
122  foreach($path as $path_item)
123  {
124  $this->tpl->setVariable("PATH_ITEM", $path_item);
125  $this->tpl->parseCurrentBlock();
126  }
127  }
128 
129  // hide / unhide?!
130  $this->tpl->setCurrentBlock("item_command");
131  $ilCtrl->setParameterByClass(get_class($this),'hide', $a_set["obj_id"]);
132  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass(get_class($this),'hide'));
133  $this->tpl->setVariable("TXT_COMMAND", $lng->txt('trac_hide'));
134  $this->tpl->parseCurrentBlock();
135 
136  if(!$this->is_anonymized)
137  {
138  $ref_id = $a_set["ref_ids"];
139  $ref_id = array_shift($ref_id);
140  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', $ref_id);
141  $this->tpl->setVariable("HREF_COMMAND", $ilCtrl->getLinkTargetByClass($ilCtrl->getCmdClass(), 'details'));
142  $ilCtrl->setParameterByClass($ilCtrl->getCmdClass(), 'details_id', '');
143  $this->tpl->setVariable("TXT_COMMAND", $lng->txt('trac_participants'));
144  $this->tpl->parseCurrentBlock();
145  }
146  }
147 
148  protected function fillHeaderExcel($worksheet, &$a_row)
149  {
150  $worksheet->write($a_row, 0, $this->lng->txt("type"));
151  $worksheet->write($a_row, 1, $this->lng->txt("trac_title"));
156  // $worksheet->write($a_row, 6, $this->lng->txt("path"));
157  }
158 
159  protected function fillRowExcel($worksheet, &$a_row, $a_set)
160  {
161  $worksheet->write($a_row, 0, $this->lng->txt($a_set["type"]));
162  $worksheet->write($a_row, 1, $a_set["title"]);
163  $worksheet->write($a_row, 2, $a_set["status_not_attempted"]);
164  $worksheet->write($a_row, 3, $a_set["status_in_progress"]);
165  $worksheet->write($a_row, 4, $a_set["status_completed"]);
166  $worksheet->write($a_row, 5, $a_set["status_failed"]);
167 
168  /*
169  // path
170  $path = $this->buildPath($a_set["ref_ids"]);
171  if($path)
172  {
173  $col = 6;
174  foreach($path as $path_item)
175  {
176  $worksheet->write($a_row, $col, strip_tags($path_item));
177  $col++;
178  }
179  }
180  */
181 
182  }
183 
184  protected function fillHeaderCSV($a_csv)
185  {
186  $a_csv->addColumn($this->lng->txt("type"));
187  $a_csv->addColumn($this->lng->txt("trac_title"));
192  // $a_csv->addColumn($this->lng->txt("path"));
193  $a_csv->addRow();
194  }
195 
196  protected function fillRowCSV($a_csv, $a_set)
197  {
198  $a_csv->addColumn($this->lng->txt($a_set["type"]));
199  $a_csv->addColumn($a_set["title"]);
200  $a_csv->addColumn($a_set["status_not_attempted"]);
201  $a_csv->addColumn($a_set["status_in_progress"]);
202  $a_csv->addColumn($a_set["status_completed"]);
203  $a_csv->addColumn($a_set["status_failed"]);
204 
205  /*
206  // path
207  $path = $this->buildPath($a_set["ref_ids"]);
208  if($path)
209  {
210  $col = 6;
211  foreach($path as $path_item)
212  {
213  $a_csv->addColumn(strip_tags($path_item));
214  $col++;
215  }
216  }
217  */
218 
219  $a_csv->addRow();
220  }
221 }
222 
223 ?>