ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once('./Services/Table/classes/class.ilTable2GUI.php');
5
14{
18 protected $ctrl;
19
23 protected $user;
24
28 protected $obj_data_cache;
29
33 protected $access;
34
38 protected $obj_definition;
39
40 protected $start_object; // [ilContainerStartObjects]
41 protected $item_list_guis; // [array]
42 protected $enable_desktop; // [bool]
43
44 public function __construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects, $a_enable_desktop = true)
45 {
46 global $DIC;
47
48 $this->user = $DIC->user();
49 $this->obj_data_cache = $DIC["ilObjDataCache"];
50 $this->access = $DIC->access();
51 $this->obj_definition = $DIC["objDefinition"];
52 $lng = $DIC->language();
53 $ilCtrl = $DIC->ctrl();
54
55 $this->lng = $lng;
56 $this->ctrl = $ilCtrl;
57
58 $this->start_object = $a_start_objects;
59 $this->enable_desktop = (bool) $a_enable_desktop;
60
61 parent::__construct($a_parent_obj, $a_parent_cmd);
62
63 $this->addColumn($this->lng->txt('crs_nr'), 'nr');
64 $this->addColumn($this->lng->txt('title'), 'title');
65 $this->addColumn($this->lng->txt('crs_objective_accomplished'), 'status');
66 $this->addColumn($this->lng->txt('actions'), '');
67
68 $this->setTitle($this->lng->txt('crs_table_start_objects'));
69 $this->setDescription($this->lng->txt('crs_info_start'));
70
71 $this->setRowTemplate("tpl.start_objects_content_row.html", "Services/Container");
72 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
73
74 $this->setDefaultOrderField('nr');
75 $this->setDefaultOrderDirection('asc');
76
77 $this->getItems();
78 }
79
80 protected function getItems()
81 {
83 $ilObjDataCache = $this->obj_data_cache;
84 $ilAccess = $this->access;
85
86 include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
87 include_once './Services/Link/classes/class.ilLink.php';
88
89 $lm_continue = new ilCourseLMHistory($this->start_object->getRefId(), $ilUser->getId());
90 $continue_data = $lm_continue->getLMHistory();
91
92 $items = array();
93 $counter = 0;
94 foreach ($this->start_object->getStartObjects() as $start) {
95 $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
96 $ref_id = $start['item_ref_id'];
97 $type = $ilObjDataCache->lookupType($obj_id);
98
99 if (!$ilAccess->checkAccess("visible", "", $ref_id)) {
100 continue;
101 }
102
103 // start object status
104 if ($this->start_object->isFullfilled($ilUser->getId(), $ref_id)) {
105 $accomplished = 'accomplished';
106 } else {
107 $accomplished = 'not_accomplished';
108 }
109
110 // add/remove desktop
111 $actions = array();
112 if ((bool) $this->enable_desktop) {
113 // add to desktop link
114 if (!$ilUser->isDesktopItem($ref_id, $type)) {
115 if ($ilAccess->checkAccess('read', '', $ref_id)) {
116 $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id);
117 $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id);
118 $this->ctrl->setParameter($this->getParentObject(), 'type', $type);
119 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'addToDesk');
120 $actions[$url] = $this->lng->txt("to_desktop");
121 }
122 } else {
123 $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id);
124 $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id);
125 $this->ctrl->setParameter($this->getParentObject(), 'type', $type);
126 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'removeFromDesk');
127 $actions[$url] = $this->lng->txt("unsubscribe");
128 }
129 }
130
131 $default_params = null;
132 if ($type == "tst") {
133 $default_params["crs_show_result"] = $ref_id;
134 }
135 /* continue is currently inactive
136 if(isset($continue_data[$ref_id]))
137 {
138 // :TODO: should "continue" be default or 2nd link/action?
139 // $this->lng->txt('continue_work')
140 $default_params["obj_id"] = $continue_data[$ref_id]['lm_page_id'];
141 }
142 */
143
144 if ($accomplished == 'accomplished') {
145 $icon = ilUtil::getImagePath("icon_ok.svg");
146 } else {
147 $icon = ilUtil::getImagePath("icon_not_ok.svg");
148 }
149
150 $items[] = array("nr" => ++$counter,
151 "obj_id" => $obj_id,
152 "ref_id" => $ref_id,
153 "type" => $type,
154 "append_default" => $default_params,
155 "title" => $ilObjDataCache->lookupTitle($obj_id),
156 "description" => $ilObjDataCache->lookupDescription($obj_id),
157 "status" => $this->lng->txt('crs_objective_' . $accomplished),
158 "status_img" => $icon,
159 "actions" => $actions);
160 }
161
162 include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
164 foreach ($items as $item) {
165 $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
166 }
167 $preloader->preload();
168 unset($preloader);
169
170 reset($items);
171 $this->setData($items);
172 }
173
182 protected function getItemListGUI($a_type)
183 {
184 $objDefinition = $this->obj_definition;
185
186 if (!isset($this->item_list_guis[$a_type])) {
187 $class = $objDefinition->getClassName($a_type);
188 // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
189 if (!$class) {
190 return null;
191 }
192 // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
193 $location = $objDefinition->getLocation($a_type);
194 if (!$location) {
195 return null;
196 }
197 $full_class = "ilObj" . $class . "ListGUI";
198 include_once($location . "/class." . $full_class . ".php");
199 $item_list_gui = new $full_class();
200 $this->item_list_guis[$a_type] = $item_list_gui;
201 } else {
202 $item_list_gui = $this->item_list_guis[$a_type];
203 }
204
205 $item_list_gui->setDefaultCommandParameters(array());
206
207 return $item_list_gui;
208 }
209
216 protected function getListItem($a_item)
217 {
218 $item_list_gui = $this->getItemListGUI($a_item["type"]);
219 if (!$item_list_gui) {
220 return;
221 }
222
223 $item_list_gui->setContainerObject($this);
224 $item_list_gui->enableCommands(true, true);
225
226 // ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item);
227
228 // notes, comment currently do not work properly
229 $item_list_gui->enableNotes(false);
230 $item_list_gui->enableComments(false);
231 $item_list_gui->enableTags(false);
232
233 $item_list_gui->enableIcon(true);
234 $item_list_gui->enableDelete(false);
235 $item_list_gui->enableCut(false);
236 $item_list_gui->enableCopy(false);
237 $item_list_gui->enableLink(false);
238 $item_list_gui->enableInfoScreen(true);
239 $item_list_gui->enableSubscribe(false);
240
241 $level = 3;
242
243 if ($level < 3) {
244 $item_list_gui->enableDescription(false);
245 $item_list_gui->enableProperties(false);
246 $item_list_gui->enablePreconditions(false);
247 }
248
249 if ($a_item["append_default"]) {
250 $item_list_gui->setDefaultCommandParameters($a_item["append_default"]);
251 }
252 if (is_object($item_list_gui)) {
253 return $item_list_gui->getListItemHTML(
254 $a_item["ref_id"],
255 $a_item["obj_id"],
256 $a_item["title"],
257 $a_item["description"]
258 );
259 }
260 }
261
262 public function fillRow($a_set)
263 {
264 $this->tpl->setVariable("VAL_NR", $a_set["nr"]);
265
266 // begin-patch lok
267 $this->tpl->setVariable("TXT_TITLE", $this->getListItem($a_set));
268 /*
269 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
270 if(ilLOSettings::getInstanceByObjId($this->getParentObject()->object->getId())->isObjectiveTest($a_set['ref_id']))
271 {
272 $this->ctrl->setParameter($this->getParentObject(),'tid',$a_set['ref_id']);
273 $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'], $a_set['obj_id'], 'small'));
274 $this->tpl->setVariable('TITLE_MANUAL_LINK',$this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'redirectLocToTest'));
275 $this->tpl->setVariable('VAL_TITLE_MANUAL',$a_set['title']);
276 }
277 else
278 {
279 $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'], $a_set['obj_id'], 'small'));
280 include_once './Services/Link/classes/class.ilLink.php';
281 $this->tpl->setVariable('TITLE_MANUAL_LINK',ilLink::_getLink($a_set['ref_id']));
282 $this->tpl->setVariable('VAL_TITLE_MANUAL',$a_set['title']);
283 }
284 // end-patch lok
285 */
286
287 $this->tpl->setVariable("TXT_STATUS", $a_set["status"]);
288 $this->tpl->setVariable("IMG_STATUS", $a_set["status_img"]);
289
290 if ($a_set["actions"]) {
291 $this->tpl->setCurrentBlock("link");
292 foreach ($a_set["actions"] as $url => $caption) {
293 $this->tpl->setVariable("LINK_HREF", $url);
294 $this->tpl->setVariable("LINK_NAME", $caption);
295 }
296 $this->tpl->parseCurrentBlock();
297 }
298 }
299}
user()
Definition: user.php:4
$location
Definition: buildRTE.php:44
An exception for terminatinating execution or to throw for unit testing.
__construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects, $a_enable_desktop=true)
class ilCourseLMHistory
Preloader for object list GUIs.
Class ilTable2GUI.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setDescription($a_val)
Set description.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$counter
global $ilCtrl
Definition: ilias.php:18
$type
$url
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92