ILIAS  release_8 Revision v8.24
class.ilBiblAdminFieldGUI.php
Go to the documentation of this file.
1<?php
2
24abstract class ilBiblAdminFieldGUI
25{
26 use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
27
28 public const CMD_INIT_DEFAULT_FIELDS_AND_SORTING = 'initDefaultFieldsAndSorting';
29 public const SUBTAB_RIS = 'subtab_ris';
30 public const SUBTAB_BIBTEX = 'subtab_bibtex';
31 public const FIELD_IDENTIFIER = 'field_id';
32 public const DATA_TYPE = 'data_type';
33 public const CMD_STANDARD = 'index';
34 public const CMD_CANCEL = 'cancel';
35 public const CMD_EDIT = 'edit';
36 public const CMD_UPDATE = 'update';
37 public const CMD_APPLY_FILTER = 'applyFilter';
38 public const CMD_RESET_FILTER = 'resetFilter';
39 public const CMD_SAVE = 'save';
40 protected \ilBiblAdminFactoryFacadeInterface $facade;
41 private \ilGlobalTemplateInterface $main_tpl;
42
47 {
48 global $DIC;
49 $this->main_tpl = $DIC->ui()->mainTemplate();
50 $this->facade = $facade;
51 }
52
53 public function executeCommand(): void
54 {
55 $nextClass = $this->ctrl()->getNextClass();
56 $this->tabs()->activateTab(ilObjBibliographicAdminGUI::TAB_FIELDS);
57 switch ($nextClass) {
58 case strtolower(ilBiblTranslationGUI::class):
59 $this->tabs()->clearTargets();
60 $target = $this->ctrl()->getLinkTarget($this);
61 $this->tabs()->setBackTarget($this->lng()->txt('back'), $target);
62
63 $field_id = $this->http()->request()->getQueryParams()[self::FIELD_IDENTIFIER];
64 if (!$field_id) {
65 throw new ilException("Field not found");
66 }
67 $this->ctrl()->saveParameter($this, self::FIELD_IDENTIFIER);
68 $field = $this->facade->fieldFactory()->findById($field_id);
69
70 $gui = new ilBiblTranslationGUI($this->facade, $field);
71 $this->ctrl()->forwardCommand($gui);
72 break;
73
74 default:
75 $this->performCommand();
76 }
77 }
78
79 protected function performCommand(): void
80 {
81 $cmd = $this->ctrl()->getCmd(self::CMD_STANDARD);
82 switch ($cmd) {
84 if ($this->checkPermissionBoolAndReturn('read')) {
85 $this->{$cmd}();
86 }
87 break;
88 case self::CMD_EDIT:
90 case self::CMD_SAVE:
93 if ($this->checkPermissionBoolAndReturn('write')) {
94 $this->{$cmd}();
95 }
96 break;
97 }
98 }
99
100 protected function index(): void
101 {
102 $this->setSubTabs();
103
104 $table = new ilBiblAdminFieldTableGUI($this, $this->facade);
105 $this->tpl()->setContent($table->getHTML());
106 }
107
108 protected function setSubTabs(): void
109 {
110 $this->tabs()->addSubTab(
111 self::SUBTAB_RIS,
112 $this->lng()->txt('ris'),
113 $this->ctrl()->getLinkTargetByClass(
114 array(
115 ilObjBibliographicAdminGUI::class,
116 ilBiblAdminRisFieldGUI::class,
117 ),
119 )
120 );
121 $this->tabs()->activateSubTab(self::SUBTAB_RIS);
122
123 $this->tabs()->addSubTab(
124 self::SUBTAB_BIBTEX,
125 $this->lng()->txt('bibtex'),
126 $this->ctrl()->getLinkTargetByClass(
127 array(
128 ilObjBibliographicAdminGUI::class,
129 ilBiblAdminBibtexFieldGUI::class,
130 ),
132 )
133 );
134 switch ($this->facade->type()->getId()) {
136 $this->tabs()->activateSubTab(self::SUBTAB_BIBTEX);
137 break;
139 $this->tabs()->activateSubTab(self::SUBTAB_RIS);
140 break;
141 }
142 }
143
144 protected function save(): void
145 {
146 // I currently did not find a way to use the wrapper here
147 $positions = $this->http()->request()->getParsedBody()['position'];
148
149 foreach ($positions as $set) {
150 $field_id = (int) key($set);
151 $position = (int) current($set);
152
153 $ilBiblField = $this->facade->fieldFactory()->findById($field_id);
154 $ilBiblField->setPosition($position);
155 $ilBiblField->store();
156 }
157
158 $this->main_tpl->setOnScreenMessage('success', $this->lng()->txt('changes_successfully_saved'));
159 $this->ctrl()->redirect($this, self::CMD_STANDARD);
160 }
161
162 protected function applyFilter(): void
163 {
164 $ilBiblAdminFieldTableGUI = new ilBiblAdminFieldTableGUI($this, $this->facade);
165 $ilBiblAdminFieldTableGUI->writeFilterToSession();
166 $this->ctrl()->redirect($this, self::CMD_STANDARD);
167 }
168
169 protected function resetFilter(): void
170 {
171 $ilBiblAdminFieldTableGUI = new ilBiblAdminFieldTableGUI($this, $this->facade);
172 $ilBiblAdminFieldTableGUI->resetFilter();
173 $ilBiblAdminFieldTableGUI->resetOffset();
174 $this->ctrl()->redirect($this, self::CMD_STANDARD);
175 }
176}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblAdminFactoryFacadeInterface $facade
ilGlobalTemplateInterface $main_tpl
__construct(ilBiblAdminFactoryFacadeInterface $facade)
ilBiblAdminFieldGUI constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilBiblTranslationGUI.
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...
static http()
Fetches the global http state from ILIAS.