ILIAS  release_8 Revision v8.24
class.ilCourseGroupingTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
25{
26 public function __construct(object $a_parent_obj, string $a_parent_cmd, ilObject $a_content_obj)
27 {
28 parent::__construct($a_parent_obj, $a_parent_cmd);
29 $type = ilObject::_lookupType($a_content_obj->getId());
30 $this->lng->loadLanguageModule($type);
31
32 $this->addColumn('', '', '1');
33 $this->addColumn($this->lng->txt('title'), 'title');
34 $this->addColumn($this->lng->txt('description'), 'description');
35 $this->addColumn($this->lng->txt('unambiguousness'), 'unique');
36 $this->addColumn($this->lng->txt('groupings_assigned_obj_' . $type), 'assigned_sortable');
37 $this->addColumn('', '');
38
39 $this->setTitle($this->lng->txt('groupings'));
40
41 $this->addMultiCommand('askDeleteGrouping', $this->lng->txt('delete'));
42 $this->setSelectAllCheckbox('grouping');
43
44 $this->setRowTemplate("tpl.groupings.html", "Modules/Course");
45 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
46
47 $this->setDefaultOrderField('title');
48 $this->setDefaultOrderDirection('asc');
49
50 $this->getItems($a_content_obj);
51 }
52
53 protected function getItems(ilObject $a_content_obj): void
54 {
55 $items = ilObjCourseGrouping::_getVisibleGroupings($a_content_obj->getId());
56
57 $data = array();
58 foreach ($items as $grouping_id) {
59 $tmp_obj = new ilObjCourseGrouping($grouping_id);
60
61 $data[$grouping_id]['id'] = $grouping_id;
62 $data[$grouping_id]['source_ref_id'] = $tmp_obj->getContainerRefId();
63 $data[$grouping_id]['assigned'] = [];
64 $data[$grouping_id]['title'] = $tmp_obj->getTitle();
65 $data[$grouping_id]['unique'] = $this->lng->txt($tmp_obj->getUniqueField());
66 $data[$grouping_id]['description'] = $tmp_obj->getDescription();
67
68 // Assigned items
69 $assigned_items = $tmp_obj->getAssignedItems();
70 $data[$grouping_id]['assigned'] = [];
71 foreach ($assigned_items as $condition) {
72 $data[$grouping_id]['assigned'][] = ilObject::_lookupTitle($condition['target_obj_id']);
73 }
74 $data[$grouping_id]['assigned_sortable'] = implode(' ', $data[$grouping_id]['assigned']);
75 }
76
77 $this->setData($data);
78 }
79
80 protected function fillRow(array $a_set): void
81 {
82 if (is_array($a_set["assigned"]) && count($a_set["assigned"]) > 0) {
83 foreach ($a_set["assigned"] as $item) {
84 $this->tpl->setCurrentBlock("assigned");
85 $this->tpl->setVariable("ITEM_TITLE", $item);
86 $this->tpl->parseCurrentBlock();
87 }
88 } else {
89 $this->tpl->setCurrentBlock("assigned");
90 $this->tpl->setVariable("ITEM_TITLE", $this->lng->txt('crs_grp_no_courses_assigned'));
91 $this->tpl->parseCurrentBlock();
92 }
93
94 if (array_key_exists('source_ref_id', $a_set) && $a_set['source_ref_id']) {
95 $path = new \ilPathGUI();
96 $path->enableHideLeaf(false);
97 $path->enableTextOnly(false);
98 $path->setUseImages(true);
99
100 $this->tpl->setCurrentBlock('path');
101 $this->tpl->setVariable('OBJ_PATH', $path->getPath(ROOT_FOLDER_ID, (int) $a_set['source_ref_id']));
102 $this->tpl->parseCurrentBlock();
103 }
104
105 $this->tpl->setVariable("ID", $a_set["id"]);
106 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
107 $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
108 $this->tpl->setVariable("TXT_UNIQUE", $a_set["unique"]);
109
110 $this->ctrl->setParameter($this->parent_obj, 'obj_id', $a_set["id"]);
111 $this->tpl->setVariable(
112 "EDIT_LINK",
113 $this->ctrl->getLinkTarget($this->parent_obj, 'edit')
114 );
115 $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
116 }
117}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilObject $a_content_obj)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getVisibleGroupings(int $a_obj_id)
Returns a list of all groupings for which the current user hast write permission on all assigned obje...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
const ROOT_FOLDER_ID
Definition: constants.php:32
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type