ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
47 protected $fav_manager;
48
49 public function __construct($a_parent_obj, $a_parent_cmd, ilContainerStartObjects $a_start_objects, $a_enable_desktop = true)
50 {
51 global $DIC;
52
53 $this->user = $DIC->user();
54 $this->obj_data_cache = $DIC["ilObjDataCache"];
55 $this->access = $DIC->access();
56 $this->obj_definition = $DIC["objDefinition"];
57 $lng = $DIC->language();
58 $ilCtrl = $DIC->ctrl();
59
60 $this->lng = $lng;
61 $this->lng->loadLanguageModule('rep');
62 $this->ctrl = $ilCtrl;
63
64 $this->start_object = $a_start_objects;
65 $this->enable_desktop = (bool) $a_enable_desktop;
66
67 parent::__construct($a_parent_obj, $a_parent_cmd);
68
69 $this->addColumn($this->lng->txt('crs_nr'), 'nr');
70 $this->addColumn($this->lng->txt('title'), 'title');
71 $this->addColumn($this->lng->txt('crs_objective_accomplished'), 'status');
72 $this->addColumn($this->lng->txt('actions'), '');
73
74 $this->setTitle($this->lng->txt('crs_table_start_objects'));
75 $this->setDescription($this->lng->txt('crs_info_start'));
76
77 $this->setRowTemplate("tpl.start_objects_content_row.html", "Services/Container");
78 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
79
80 $this->setDefaultOrderField('nr');
81 $this->setDefaultOrderDirection('asc');
82 $this->fav_manager = new ilFavouritesManager();
83
84 $this->getItems();
85 }
86
87 protected function getItems()
88 {
90 $ilObjDataCache = $this->obj_data_cache;
91 $ilAccess = $this->access;
92
93 include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
94 include_once './Services/Link/classes/class.ilLink.php';
95
96 $lm_continue = new ilCourseLMHistory($this->start_object->getRefId(), $ilUser->getId());
97 $continue_data = $lm_continue->getLMHistory();
98
99 $items = array();
100 $counter = 0;
101 foreach ($this->start_object->getStartObjects() as $start) {
102 $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
103 $ref_id = $start['item_ref_id'];
104 $type = $ilObjDataCache->lookupType($obj_id);
105
106 if (!$ilAccess->checkAccess("visible", "", $ref_id)) {
107 continue;
108 }
109
110 // start object status
111 if ($this->start_object->isFullfilled($ilUser->getId(), $ref_id)) {
112 $accomplished = 'accomplished';
113 } else {
114 $accomplished = 'not_accomplished';
115 }
116
117 // add/remove desktop
118 $actions = array();
119 if ((bool) $this->enable_desktop) {
120 // add to desktop link
121 if (!$this->fav_manager->ifIsFavourite($ilUser->getId(), $ref_id)) {
122 if ($ilAccess->checkAccess('read', '', $ref_id)) {
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(), 'addToDesk');
127 $actions[$url] = $this->lng->txt("rep_add_to_favourites");
128 }
129 } else {
130 $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id);
131 $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id);
132 $this->ctrl->setParameter($this->getParentObject(), 'type', $type);
133 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'removeFromDesk');
134 $actions[$url] = $this->lng->txt("rep_remove_from_favourites");
135 }
136 }
137
138 $default_params = null;
139 if ($type == "tst") {
140 $default_params["crs_show_result"] = $ref_id;
141 }
142 /* continue is currently inactive
143 if(isset($continue_data[$ref_id]))
144 {
145 // :TODO: should "continue" be default or 2nd link/action?
146 // $this->lng->txt('continue_work')
147 $default_params["obj_id"] = $continue_data[$ref_id]['lm_page_id'];
148 }
149 */
150
151 if ($accomplished == 'accomplished') {
152 $icon = ilUtil::getImagePath("icon_ok.svg");
153 } else {
154 $icon = ilUtil::getImagePath("icon_not_ok.svg");
155 }
156
157 $items[] = array("nr" => ++$counter,
158 "obj_id" => $obj_id,
159 "ref_id" => $ref_id,
160 "type" => $type,
161 "append_default" => $default_params,
162 "title" => $ilObjDataCache->lookupTitle($obj_id),
163 "description" => $ilObjDataCache->lookupDescription($obj_id),
164 "status" => $this->lng->txt('crs_objective_' . $accomplished),
165 "status_img" => $icon,
166 "actions" => $actions);
167 }
168
169 include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
171 foreach ($items as $item) {
172 $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
173 }
174 $preloader->preload();
175 unset($preloader);
176
177 reset($items);
178 $this->setData($items);
179 }
180
189 protected function getItemListGUI($a_type)
190 {
191 $objDefinition = $this->obj_definition;
192
193 if (!isset($this->item_list_guis[$a_type])) {
194 $class = $objDefinition->getClassName($a_type);
195 // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
196 if (!$class) {
197 return null;
198 }
199 // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
200 $location = $objDefinition->getLocation($a_type);
201 if (!$location) {
202 return null;
203 }
204 $full_class = "ilObj" . $class . "ListGUI";
205 include_once($location . "/class." . $full_class . ".php");
206 $item_list_gui = new $full_class();
207 $this->item_list_guis[$a_type] = $item_list_gui;
208 } else {
209 $item_list_gui = $this->item_list_guis[$a_type];
210 }
211
212 $item_list_gui->setDefaultCommandParameters(array());
213
214 return $item_list_gui;
215 }
216
223 protected function getListItem($a_item)
224 {
225 $item_list_gui = $this->getItemListGUI($a_item["type"]);
226 if (!$item_list_gui) {
227 return;
228 }
229
230 $item_list_gui->setContainerObject($this);
231 $item_list_gui->enableCommands(true, true);
232
233 // ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item);
234
235 // notes, comment currently do not work properly
236 $item_list_gui->enableNotes(false);
237 $item_list_gui->enableComments(false);
238 $item_list_gui->enableTags(false);
239
240 $item_list_gui->enableIcon(true);
241 $item_list_gui->enableDelete(false);
242 $item_list_gui->enableCut(false);
243 $item_list_gui->enableCopy(false);
244 $item_list_gui->enableLink(false);
245 $item_list_gui->enableInfoScreen(true);
246 $item_list_gui->enableSubscribe(false);
247
248 $level = 3;
249
250 if ($level < 3) {
251 $item_list_gui->enableDescription(false);
252 $item_list_gui->enableProperties(false);
253 $item_list_gui->enablePreconditions(false);
254 }
255
256 if ($a_item["append_default"]) {
257 $item_list_gui->setDefaultCommandParameters($a_item["append_default"]);
258 }
259 if (is_object($item_list_gui)) {
260 return $item_list_gui->getListItemHTML(
261 $a_item["ref_id"],
262 $a_item["obj_id"],
263 $a_item["title"],
264 $a_item["description"]
265 );
266 }
267 }
268
269 public function fillRow($a_set)
270 {
271 $this->tpl->setVariable("VAL_NR", $a_set["nr"]);
272
273 // begin-patch lok
274 $this->tpl->setVariable("TXT_TITLE", $this->getListItem($a_set));
275 /*
276 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
277 if(ilLOSettings::getInstanceByObjId($this->getParentObject()->object->getId())->isObjectiveTest($a_set['ref_id']))
278 {
279 $this->ctrl->setParameter($this->getParentObject(),'tid',$a_set['ref_id']);
280 $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'], $a_set['obj_id'], 'small'));
281 $this->tpl->setVariable('TITLE_MANUAL_LINK',$this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'redirectLocToTest'));
282 $this->tpl->setVariable('VAL_TITLE_MANUAL',$a_set['title']);
283 }
284 else
285 {
286 $this->tpl->setVariable('TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'], $a_set['obj_id'], 'small'));
287 include_once './Services/Link/classes/class.ilLink.php';
288 $this->tpl->setVariable('TITLE_MANUAL_LINK',ilLink::_getLink($a_set['ref_id']));
289 $this->tpl->setVariable('VAL_TITLE_MANUAL',$a_set['title']);
290 }
291 // end-patch lok
292 */
293
294 $this->tpl->setVariable("TXT_STATUS", $a_set["status"]);
295 $this->tpl->setVariable("IMG_STATUS", $a_set["status_img"]);
296
297 if ($a_set["actions"]) {
298 $this->tpl->setCurrentBlock("link");
299 foreach ($a_set["actions"] as $url => $caption) {
300 $this->tpl->setVariable("LINK_HREF", $url);
301 $this->tpl->setVariable("LINK_NAME", $caption);
302 }
303 $this->tpl->parseCurrentBlock();
304 }
305 }
306}
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
Manages favourites, currently the interface for other components, needs discussion.
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)
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46