19 declare(strict_types=1);
42 $main_tpl = $DIC->ui()->mainTemplate();
43 $this->
ctrl = $DIC->ctrl();
44 $this->
lng = $DIC->language();
45 $this->tpl = $DIC->ui()->mainTemplate();
46 $this->
tabs = $DIC->tabs();
47 $this->
toolbar = $DIC->toolbar();
48 $this->
http = $DIC->http();
50 $this->ui_factory = $DIC->ui()->factory();
51 $this->
renderer = $DIC->ui()->renderer();
53 $this->
tabs->setSetupMode(
true);
54 $DIC->help()->setScreenId(
'dcl_tables');
56 $this->parent_obj = $a_parent_obj;
59 $main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
60 $this->
ctrl->redirectByClass(ilDclRecordListGUI::class,
'listRecords');
66 return $this->parent_obj->getObjectId();
71 return $this->parent_obj->getRefId();
80 $cmd = $this->
ctrl->getCmd(
'listTables');
82 $next_class = $this->
ctrl->getNextClass($this);
84 $ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $this->
refinery->kindlyTo()->int());
86 switch ($next_class) {
87 case 'ildcltableeditgui':
88 $this->
tabs->clearTargets();
89 if ($cmd !=
'create') {
92 $this->
tabs->setBackTarget(
93 $this->
lng->txt(
'back'),
94 $this->
ctrl->getLinkTarget($this,
'listTables')
98 $this->
ctrl->forwardCommand($ilDclTableEditGUI);
101 case 'ildclfieldlistgui':
102 $this->
tabs->clearTargets();
105 $this->
ctrl->forwardCommand($ilDclFieldListGUI);
108 case "ildclfieldeditgui":
109 $this->
tabs->clearTargets();
112 $this->
ctrl->forwardCommand($ilDclFieldEditGUI);
115 case 'ildcltableviewgui':
116 $this->
tabs->clearTargets();
119 $this->
ctrl->forwardCommand($ilDclTableViewGUI);
123 $this->
ctrl->clearParameterByClass(ilObjDataCollectionGUI::class,
'table_id');
131 $add_new = $this->ui_factory->button()->primary(
132 $this->
lng->txt(
"dcl_add_new_table"),
133 $this->
ctrl->getLinkTargetByClass(
'ilDclTableEditGUI',
'create')
135 $this->
toolbar->addStickyItem($add_new);
137 $this->tpl->setContent(
139 $this->ui_factory->panel()->listing()->standard(
140 $this->
lng->txt(
'dcl_tables'),
141 [$this->ui_factory->item()->group(
'', $this->
getItems())]
150 foreach ($this->parent_obj->getDataCollectionObject()->getTables() as $table) {
152 $this->
ctrl->setParameterByClass(ilObjDataCollectionGUI::class,
'table_id', $table->getId());
153 $item = $this->ui_factory->item()->standard(
154 $this->ui_factory->link()->standard(
156 $this->
ctrl->getLinkTargetByClass(ilDclFieldListGUI::class,
'listFields')
160 $this->
lng->txt(
'visible') => $this->
lng->txt($table->getIsVisible() ?
'yes' :
'no'),
161 $this->
lng->txt(
'comments') => $this->
lng->txt($table->getPublicCommentsEnabled() ?
'active' :
'inactive')
164 $this->ui_factory->dropdown()->standard(
169 if ($table->getOrder() === 10) {
170 $item = $item->withDescription($this->
lng->txt(
'default'));
183 $this->
ctrl->setParameterByClass(ilObjDataCollectionGUI::class,
'table_id', $table->
getId());
186 $actions[] = $this->ui_factory->button()->shy(
187 $this->
lng->txt(
'settings'),
188 $this->
ctrl->getLinkTargetByClass(ilDclTableEditGUI::class,
'edit'),
191 $actions[] = $this->ui_factory->button()->shy(
192 $this->
lng->txt(
'dcl_list_fields'),
193 $this->
ctrl->getLinkTargetByClass(ilDclFieldListGUI::class,
'listFields')
196 $actions[] = $this->ui_factory->button()->shy(
197 $this->
lng->txt(
'dcl_tableviews'),
198 $this->
ctrl->getLinkTargetByClass(ilDclTableViewGUI::class,
'show')
201 $actions[] = $this->ui_factory->button()->shy(
202 $this->
lng->txt(
'delete'),
203 $this->
ctrl->getLinkTargetByClass(ilDclTableEditGUI::class,
'confirmDelete')
207 $actions[] = $this->ui_factory->button()->shy(
208 $this->
lng->txt(
'set_as_default'),
209 $this->
ctrl->getLinkTargetByClass(ilDclTableEditGUI::class,
'setAsDefault')
216 protected function setTabs(
string $active): void
218 $this->
tabs->setBackTarget($this->
lng->txt(
'dcl_tables'), $this->
ctrl->getLinkTarget($this,
'listTables'));
221 $this->
lng->txt(
'settings'),
222 $this->
ctrl->getLinkTargetByClass(
'ilDclTableEditGUI',
'edit')
226 $this->
lng->txt(
'dcl_list_fields'),
227 $this->
ctrl->getLinkTargetByClass(
'ilDclFieldListGUI',
'listFields')
231 $this->
lng->txt(
'dcl_tableviews'),
232 $this->
ctrl->getLinkTargetByClass(
'ilDclTableViewGUI')
234 $this->
tabs->activateTab($active);
237 protected function save(): void
239 if ($this->
http->wrapper()->post()->has(
"comments")) {
245 if ($this->
http->wrapper()->post()->has(
"visible")) {
246 $visible = $this->
http->wrapper()->post()->retrieve(
251 $orders = $this->
http->wrapper()->post()->retrieve(
257 foreach (array_keys($orders) as $table_id) {
259 $table->setOrder($order);
260 $table->setPublicCommentsEnabled(isset(
$comments[$table_id]));
261 $table->setIsVisible(isset($visible[$table_id]));
265 $this->
ctrl->redirect($this);
270 $ref_id = $this->parent_obj->getRefId();
277 return $this->parent_obj->getDataCollectionObject();
ilObjDataCollectionGUI $parent_obj
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDataCollectionObject()
ilDclTableViewGUI: ilDclTableViewEditGUI
ilDclTableListGUI: ilDclFieldListGUI, ilDclFieldEditGUI, ilDclTableViewGUI, ilDclTableEditGUI ...
getActions(ilDclTable $table)
ilObjDataCollectionGUI: ilInfoScreenGUI, ilNoteGUI, ilCommonActionDispatcherGUI ilObjDataCollectionG...
__construct(ilObjDataCollectionGUI $a_parent_obj)
static http()
Fetches the global http state from ILIAS.
executeCommand()
execute command
static getTableCache(?int $table_id=null)
static hasWriteAccess(int $ref, ?int $user_id=0)
ILIAS Refinery Factory $refinery
ILIAS HTTP Services $http
ilGlobalTemplateInterface $tpl
ILIAS UI Factory $ui_factory
ILIAS UI Renderer $renderer