ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilContainerStartObjectsContentTableGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  protected ilObjUser $user;
30  protected array $item_list_guis;
31  protected bool $enable_desktop;
33 
34  public function __construct(
35  ?object $a_parent_obj,
36  string $a_parent_cmd,
37  ilContainerStartObjects $a_start_objects,
38  bool $a_enable_desktop = true
39  ) {
40  global $DIC;
41 
42  $this->user = $DIC->user();
43  $this->obj_data_cache = $DIC["ilObjDataCache"];
44  $this->access = $DIC->access();
45  $this->obj_definition = $DIC["objDefinition"];
46  $lng = $DIC->language();
47  $ilCtrl = $DIC->ctrl();
48 
49  $this->lng = $lng;
50  $this->lng->loadLanguageModule('rep');
51  $this->ctrl = $ilCtrl;
52 
53  $this->start_object = $a_start_objects;
54  $this->enable_desktop = $a_enable_desktop;
55 
56  parent::__construct($a_parent_obj, $a_parent_cmd);
57 
58  $this->addColumn($this->lng->txt('crs_nr'), 'nr');
59  $this->addColumn($this->lng->txt('title'), 'title');
60  $this->addColumn($this->lng->txt('crs_objective_accomplished'), 'status');
61  $this->addColumn($this->lng->txt('actions'), '');
62 
63  $this->setTitle($this->lng->txt('crs_table_start_objects'));
64  $this->setDescription($this->lng->txt('crs_info_start'));
65 
66  $this->setRowTemplate("tpl.start_objects_content_row.html", "Services/Container");
67  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
68 
69  $this->setDefaultOrderField('nr');
70  $this->setDefaultOrderDirection('asc');
71  $this->fav_manager = new ilFavouritesManager();
72 
73  $this->getItems();
74  }
75 
76  protected function getItems(): void
77  {
79  $ilObjDataCache = $this->obj_data_cache;
80  $ilAccess = $this->access;
81 
82  $lm_continue = new ilCourseLMHistory($this->start_object->getRefId(), $ilUser->getId());
83  $continue_data = $lm_continue->getLMHistory();
84 
85  $items = [];
86  $counter = 0;
87  foreach ($this->start_object->getStartObjects() as $start) {
88  $obj_id = $ilObjDataCache->lookupObjId((int) $start['item_ref_id']);
89  $ref_id = $start['item_ref_id'];
90  $type = $ilObjDataCache->lookupType($obj_id);
91 
92  if (!$ilAccess->checkAccess("visible", "", $ref_id)) {
93  continue;
94  }
95 
96  // start object status
97  if ($this->start_object->isFullfilled($ilUser->getId(), $ref_id)) {
98  $accomplished = 'accomplished';
99  } else {
100  $accomplished = 'not_accomplished';
101  }
102 
103  // add/remove desktop
104  $actions = [];
105  if ($this->enable_desktop) {
106  // add to desktop link
107  if (!$this->fav_manager->ifIsFavourite($ilUser->getId(), $ref_id)) {
108  if ($ilAccess->checkAccess('read', '', $ref_id)) {
109  $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id);
110  $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id);
111  $this->ctrl->setParameter($this->getParentObject(), 'type', $type);
112  $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'addToDesk');
113  $actions[$url] = $this->lng->txt("rep_add_to_favourites");
114  }
115  } else {
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(), 'removeFromDesk');
120  $actions[$url] = $this->lng->txt("rep_remove_from_favourites");
121  }
122  }
123 
124  $default_params = null;
125  if ($type === "tst") {
126  $default_params["crs_show_result"] = $ref_id;
127  }
128  /* continue is currently inactive
129  if(isset($continue_data[$ref_id]))
130  {
131  // :TODO: should "continue" be default or 2nd link/action?
132  // $this->lng->txt('continue_work')
133  $default_params["obj_id"] = $continue_data[$ref_id]['lm_page_id'];
134  }
135  */
136 
137  if ($accomplished === 'accomplished') {
138  $icon = ilUtil::getImagePath("icon_ok.svg");
139  } else {
140  $icon = ilUtil::getImagePath("icon_not_ok.svg");
141  }
142 
143  $items[] = [
144  "nr" => ++$counter,
145  "obj_id" => $obj_id,
146  "ref_id" => $ref_id,
147  "type" => $type,
148  "append_default" => $default_params,
149  "title" => $ilObjDataCache->lookupTitle($obj_id),
150  "description" => $ilObjDataCache->lookupDescription($obj_id),
151  "status" => $this->lng->txt('crs_objective_' . $accomplished),
152  "status_img" => $icon,
153  "actions" => $actions
154  ];
155  }
156 
158  foreach ($items as $item) {
159  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
160  }
161  $preloader->preload();
162  unset($preloader);
163 
164  $this->setData($items);
165  }
166 
167  protected function getItemListGUI(string $a_type): ?ilObjectListGUI
168  {
169  $objDefinition = $this->obj_definition;
170 
171  if (!isset($this->item_list_guis[$a_type])) {
172  $class = $objDefinition->getClassName($a_type);
173  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
174  if (!$class) {
175  return null;
176  }
177  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
178  $location = $objDefinition->getLocation($a_type);
179  if (!$location) {
180  return null;
181  }
182  $full_class = "ilObj" . $class . "ListGUI";
183  $item_list_gui = new $full_class();
184  $this->item_list_guis[$a_type] = $item_list_gui;
185  } else {
186  $item_list_gui = $this->item_list_guis[$a_type];
187  }
188 
189  $item_list_gui->setDefaultCommandParameters([]);
190 
191  return $item_list_gui;
192  }
193 
194  // Get list gui html
195  protected function getListItem(array $a_item): string
196  {
197  $item_list_gui = $this->getItemListGUI($a_item["type"]);
198  if (!$item_list_gui) {
199  return "";
200  }
201 
202  $item_list_gui->setContainerObject($this);
203  $item_list_gui->enableCommands(true, true);
204 
205  // ilObjectActivation::addListGUIActivationProperty($item_list_gui, $a_item);
206 
207  // notes, comment currently do not work properly
208  $item_list_gui->enableNotes(false);
209  $item_list_gui->enableComments(false);
210  $item_list_gui->enableTags(false);
211 
212  $item_list_gui->enableIcon(true);
213  $item_list_gui->enableDelete(false);
214  $item_list_gui->enableCut(false);
215  $item_list_gui->enableCopy(false);
216  $item_list_gui->enableLink(false);
217  $item_list_gui->enableInfoScreen(true);
218  $item_list_gui->enableSubscribe(false);
219 
220  $level = 3;
221 
222  if ($level < 3) {
223  $item_list_gui->enableDescription(false);
224  $item_list_gui->enableProperties(false);
225  $item_list_gui->enablePreconditions(false);
226  }
227 
228  if ($a_item["append_default"]) {
229  $item_list_gui->setDefaultCommandParameters($a_item["append_default"]);
230  }
231  if (is_object($item_list_gui)) {
232  return $item_list_gui->getListItemHTML(
233  $a_item["ref_id"],
234  $a_item["obj_id"],
235  $a_item["title"],
236  $a_item["description"]
237  );
238  }
239  return "";
240  }
241 
242  protected function fillRow(array $a_set): void
243  {
244  $this->tpl->setVariable("VAL_NR", $a_set["nr"]);
245 
246  // begin-patch lok
247  $this->tpl->setVariable("TXT_TITLE", $this->getListItem($a_set));
248  $this->tpl->setVariable("TXT_STATUS", $a_set["status"]);
249  $this->tpl->setVariable("IMG_STATUS", $a_set["status_img"]);
250 
251  if ($a_set["actions"]) {
252  $this->tpl->setCurrentBlock("link");
253  foreach ($a_set["actions"] as $url => $caption) {
254  $this->tpl->setVariable("LINK_HREF", $url);
255  $this->tpl->setVariable("LINK_NAME", $caption);
256  }
257  $this->tpl->parseCurrentBlock();
258  }
259  }
260 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
$type
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDescription(string $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
$ref_id
Definition: ltiauth.php:67
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
getClassName(string $obj_name)
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(?object $a_parent_obj, string $a_parent_cmd, ilContainerStartObjects $a_start_objects, bool $a_enable_desktop=true)
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
$url
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...