ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCalendarManageTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Factory as UIFactory;
22use ILIAS\UI\Renderer as UIRenderer;
23
30{
32 protected ilObjUser $user;
33
34 private UIRenderer $renderer;
35 private UIFactory $ui_factory;
36
37 public function __construct(object $a_parent_obj)
38 {
39 global $DIC;
40
41 $this->setId("calmng");
42 parent::__construct($a_parent_obj, 'manage');
43
44 $this->user = $DIC->user();
45 $this->renderer = $DIC->ui()->renderer();
46 $this->ui_factory = $DIC->ui()->factory();
47
48 $this->actions = ilCalendarActions::getInstance();
49 $this->lng->loadLanguageModule('dateplaner');
50 $this->setFormName('categories');
51 $this->addColumn('', '', '1px', true);
52 $this->addColumn($this->lng->txt('type'), 'type_sortable', '1%');
53 $this->addColumn($this->lng->txt('title'), 'title', '79%');
54 $this->addColumn('', '', '20%');
55
56 $this->setRowTemplate("tpl.manage_row.html", "components/ILIAS/Calendar");
57 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, "manage"));
58
59 $this->enable('select_all');
60 $this->enable('sort');
61 $this->enable('header');
62 $this->enable('num_info');
63
64 $this->setSelectAllCheckbox('selected_cat_ids');
65 $this->setShowRowsSelector(true);
66 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
67 $this->setDefaultOrderDirection('asc');
68 $this->setDefaultOrderField('type_sortable');
69 }
70
74 public function resetToDefaults(): void
75 {
76 $this->resetOffset();
77 $this->setOrderField('type_sortable');
78 $this->setOrderDirection('asc');
79 }
80
81 protected function fillRow(array $a_set): void
82 {
83 $dropDownItems = array();
84
85 $this->ctrl->setParameter($this->getParentObject(), 'category_id', $a_set['id']);
86
87 // edit
88 if ($this->actions->checkSettingsCal($a_set['id'])) {
89 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'edit');
90 $dropDownItems[] = $this->ui_factory->button()->shy(
91 $this->lng->txt('settings'),
92 $url
93 );
94 }
95
96 // import (ics appointments)
97 if ($this->actions->checkAddEvent($a_set['id'])) {
98 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'importAppointments');
99 $dropDownItems[] = $this->ui_factory->button()->shy(
100 $this->lng->txt('cal_import_appointments'),
101 $url
102 );
103 }
104
105 // unshare
106 if ($this->actions->checkUnshareCal($a_set['id'])) {
107 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'unshare');
108 $dropDownItems[] = $this->ui_factory->button()->shy(
109 $this->lng->txt('cal_unshare'),
110 $url
111 );
112 }
113
114 // share
115 if ($this->actions->checkShareCal($a_set['id'])) {
116 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'shareSearch');
117 $dropDownItems[] = $this->ui_factory->button()->shy(
118 $this->lng->txt('cal_share'),
119 $url
120 );
121 }
122
123 // synchronize
124 if ($this->actions->checkSynchronizeCal($a_set['id'])) {
125 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'synchroniseCalendar');
126 $dropDownItems[] = $this->ui_factory->button()->shy(
127 $this->lng->txt('cal_cal_synchronize'),
128 $url
129 );
130 }
131
132 // delete
133 if ($this->actions->checkDeleteCal($a_set['id'])) {
134 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDelete');
135 $dropDownItems[] = $this->ui_factory->button()->shy(
136 $this->lng->txt('delete'),
137 $url
138 );
139
140 $this->tpl->setCurrentBlock("checkbox");
141 $this->tpl->setVariable('VAL_ID', $a_set['id']);
142 $this->tpl->parseCurrentBlock();
143 }
144
145 $this->ctrl->setParameter($this->getParentObject(), 'category_id', '');
146
147 switch ($a_set['type']) {
149 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('standard/icon_calg.svg'));
150 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_system'));
151 break;
152
154 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('standard/icon_usr.svg'));
155 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_personal'));
156 break;
157
159 $type = ilObject::_lookupType($a_set['obj_id']);
160 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('standard/icon_' . $type . '.svg'));
161 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_' . $type));
162 break;
163
165 $type = ilObject::_lookupType($a_set['obj_id']);
166 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('standard/icon_book.svg'));
167 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_' . $type));
168 break;
169
171 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('standard/icon_calch.svg'));
172 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_ch_ch'));
173 break;
174 }
175
176 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
177 $this->ctrl->setParameterByClass(ilCalendarPresentationGUI::class, 'backvm', 1);
178 $this->ctrl->setParameterByClass(
179 "ilcalendarpresentationgui",
180 'category_id',
181 $a_set['id']
182 );
183 $this->tpl->setVariable(
184 'EDIT_LINK',
185 $this->ctrl->getLinkTargetByClass(
186 "ilcalendarpresentationgui",
187 ''
188 )
189 );
190 $this->ctrl->clearParameterByClass(
191 "ilcalendarpresentationgui",
192 'category_id'
193 );
194
195 $dropDown = $this->ui_factory->dropdown()->standard($dropDownItems)
196 ->withLabel($this->lng->txt("actions"));
197
198 $this->tpl->setVariable('BGCOLOR', $a_set['color']);
199 $this->tpl->setVariable("ACTIONS", $this->renderer->render($dropDown));
200 }
201
202 public function parse(): void
203 {
204 $cats = ilCalendarCategories::_getInstance($this->user->getId());
205
206 $tmp_title_counter = array();
207 $categories = array();
208 foreach ($cats->getCategoriesInfo() as $category) {
209 $tmp_arr['obj_id'] = $category['obj_id'];
210 $tmp_arr['id'] = $category['cat_id'];
211 $tmp_arr['title'] = $category['title'];
212 $tmp_arr['type'] = $category['type'];
213
214 // Append object type to make type sortable
215 $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
216 if ($category['type'] == ilCalendarCategory::TYPE_OBJ) {
217 $tmp_arr['type_sortable'] .= ('_' . ilObject::_lookupType($category['obj_id']));
218 }
219
220 $tmp_arr['color'] = $category['color'];
221 $tmp_arr['editable'] = $category['editable'];
222 $tmp_arr['accepted'] = $category['accepted'];
223 $tmp_arr['remote'] = $category['remote'];
224
225 $categories[] = $tmp_arr;
226
227 // count title for appending the parent container if there is more than one entry.
228 if ($tmp_title_counter[$category['type'] . '_' . $category['title']] ?? false) {
229 $tmp_title_counter[$category['type'] . '_' . $category['title']]++;
230 } else {
231 $tmp_title_counter[$category['type'] . '_' . $category['title']] = 1;
232 }
233 }
234
235 $path_categories = array();
236 foreach ($categories as $cat) {
237 if ($cat['type'] == ilCalendarCategory::TYPE_OBJ) {
238 if (($tmp_title_counter[$cat['type'] . '_' . $cat['title']] ?? 1) > 1) {
239 foreach (ilObject::_getAllReferences($cat['obj_id']) as $ref_id) {
240 $path = new ilPathGUI();
241 $path->setUseImages(false);
242 $path->enableTextOnly(false);
243 $cat['path'] = $path->getPath(ROOT_FOLDER_ID, $ref_id);
244 break;
245 }
246 }
247 }
248 $path_categories[] = $cat;
249 }
250 $this->setData($path_categories);
251 }
252}
renderer()
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Checks if certain actions can be performed.
static getInstance()
Get instance.
static _getInstance($a_usr_id=0)
get singleton instance
static lookupCategorySortIndex(int $a_type_id)
Lookup sort index of calendar type.
show list of alle calendars to manage
resetToDefaults()
reset table to defaults
fillRow(array $a_set)
Standard Version of Fill Row.
User class.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setOrderField(string $a_order_field)
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
resetOffset(bool $a_in_determination=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.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
enable(string $a_module_name)
setOrderDirection(string $a_order_direction)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
An entity that renders components to a string output.
Definition: Renderer.php:31
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68