ILIAS  release_8 Revision v8.24
class.ilBiblLibraryGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
27 public const F_LIB_ID = 'lib_id';
28 public const CMD_DELETE = 'delete';
29 public const CMD_EDIT = 'edit';
30 public const CMD_INDEX = 'index';
31 public const CMD_ADD = 'add';
32 protected \ilBiblAdminLibraryFacadeInterface $facade;
33 private \ilGlobalTemplateInterface $main_tpl;
34 protected \ILIAS\Refinery\Factory $refinery;
35 protected \ILIAS\HTTP\Wrapper\WrapperFactory $wrapper;
36
41 {
42 global $DIC;
43 $this->main_tpl = $DIC->ui()->mainTemplate();
44 $this->facade = $facade;
45 $this->wrapper = $DIC->http()->wrapper();
46 $this->refinery = $DIC->refinery();
47 }
48
49
56 public function executeCommand(): void
57 {
58 switch ($this->ctrl()->getNextClass()) {
59 case null:
60 $cmd = $this->ctrl()->getCmd(self::CMD_INDEX);
61 $this->{$cmd}();
62 break;
63 }
64 }
65
66
71 public function index(): bool
72 {
73 if ($this->checkPermissionBoolAndReturn('write')) {
75 $b->setCaption(self::CMD_ADD);
76 $b->setUrl($this->ctrl()->getLinkTarget($this, self::CMD_ADD));
77 $b->setPrimary(true);
78
79 $this->toolbar()->addButtonInstance($b);
80 }
81
82 $a_table = $this->initTable();
83 $this->tpl()->setContent($a_table->getHTML());
84
85 return true;
86 }
87
88
89 protected function initTable(): \ilBiblLibraryTableGUI
90 {
91 $table = new ilBiblLibraryTableGUI($this, $this->checkPermissionBoolAndReturn('write'));
92 $settings = $this->facade->libraryFactory()->getAll();
93 $result = array();
94 foreach ($settings as $set) {
95 $result[] = array(
96 "id" => $set->getId(),
97 "name" => $set->getName(),
98 "url" => $set->getUrl(),
99 "img" => $set->getImg(),
100 );
101 }
102 $table->setData($result);
103
104 return $table;
105 }
106
107
111 public function add(): void
112 {
113 $this->checkPermissionAndFail('write');
114 $form = new ilBiblLibraryFormGUI($this->facade->libraryFactory()->getEmptyInstance());
115 $this->tpl()->setContent($form->getHTML());
116 }
117
118
122 public function delete(): void
123 {
124 $this->checkPermissionAndFail('write');
125 $ilBibliographicSetting = $this->getInstanceFromRequest();
126 $ilBibliographicSetting->delete();
127 $this->ctrl()->redirect($this, self::CMD_INDEX);
128 }
129
130
134 public function cancel(): void
135 {
136 $this->ctrl()->redirect($this, self::CMD_INDEX);
137 }
138
139
143 public function update(): void
144 {
145 $this->checkPermissionAndFail('write');
146 $ilBibliographicSetting = $this->getInstanceFromRequest();
147 $form = new ilBiblLibraryFormGUI($ilBibliographicSetting);
148 $form->setValuesByPost();
149 if ($form->saveObject()) {
150 $this->main_tpl->setOnScreenMessage('success', $this->lng()->txt("settings_saved"), true);
151 $this->ctrl()->redirect($this, self::CMD_INDEX);
152 }
153 $this->tpl()->setContent($form->getHTML());
154 }
155
156
160 public function create(): void
161 {
162 $this->checkPermissionAndFail('write');
163 $form = new ilBiblLibraryFormGUI($this->facade->libraryFactory()->getEmptyInstance());
164 $form->setValuesByPost();
165 if ($form->saveObject()) {
166 $this->main_tpl->setOnScreenMessage('success', $this->lng()->txt("settings_saved"), true);
167 $this->ctrl()->redirect($this, self::CMD_INDEX);
168 }
169 $this->tpl()->setContent($form->getHTML());
170 }
171
172
176 public function edit(): void
177 {
178 $this->checkPermissionAndFail('write');
179 $this->ctrl()->saveParameter($this, self::F_LIB_ID);
180 $ilBibliographicSetting = $this->getInstanceFromRequest();
181 $form = new ilBiblLibraryFormGUI($ilBibliographicSetting);
182 $this->tpl()->setContent($form->getHTML());
183 }
184
186 {
187 // check Query
188 if ($this->wrapper->query()->has(self::F_LIB_ID)) {
189 return $this->facade->libraryFactory()
190 ->findById(
191 $this->wrapper->query()->retrieve(
192 self::F_LIB_ID,
193 $this->refinery->kindlyTo()->int()
194 )
195 );
196 }
197 // check post
198 if ($this->wrapper->post()->has(self::F_LIB_ID)) {
199 return $this->facade->libraryFactory()
200 ->findById(
201 $this->wrapper->post()->retrieve(
202 self::F_LIB_ID,
203 $this->refinery->kindlyTo()->int()
204 )
205 );
206 }
207 throw new ilException('library not found');
208 }
209}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $main_tpl
__construct(ilBiblAdminLibraryFacadeInterface $facade)
ilBiblLibraryGUI constructor.
ILIAS Refinery Factory $refinery
update()
save changes in library
ilBiblAdminLibraryFacadeInterface $facade
ILIAS HTTP Wrapper WrapperFactory $wrapper
executeCommand()
Execute command.
index()
@global $ilToolbar ilToolbarGUI;
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200