19 declare(strict_types=1);
44 private \ILIAS\HTTP\Wrapper\WrapperFactory
$wrapper;
47 private \ILIAS\ResourceStorage\Services
$storage;
54 $this->
ctrl = $DIC->ctrl();
55 $this->
lng = $DIC->language();
56 $this->
lng->loadLanguageModule(
'file');
57 $this->
toolbar = $DIC->toolbar();
58 $this->main_tpl = $DIC->ui()->mainTemplate();
59 $this->ui_factory = $DIC->ui()->factory();
60 $this->ui_renderer = $DIC->ui()->renderer();
61 $this->http_request = $DIC->http()->request();
62 $this->wrapper = $DIC->http()->wrapper();
64 $this->storage = $DIC->resourceStorage();
66 $this->file_service_settings = $DIC->fileServiceSettings();
71 $next_class = $this->
ctrl->getNextClass(self::class);
72 if ($next_class === strtolower(ilIconUploadHandlerGUI::class)) {
74 $this->
ctrl->forwardCommand($upload_handler);
77 match ($cmd = $this->
ctrl->getCmd(self::CMD_INDEX)) {
81 self::CMD_CREATE => $this->
create(),
82 self::CMD_UPDATE => $this->
update(),
83 self::CMD_DELETE => $this->
delete(),
84 default => $this->
index(),
91 $btn_new_icon = $this->ui_factory->button()->standard(
92 $this->
lng->txt(
'add_icon'),
93 $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_OPEN_CREATION_FORM)
95 $this->
toolbar->addComponent($btn_new_icon);
104 $content[] = $listing->getFilter();
105 $content[] = $listing->getIconList();
106 $content[] = $listing->getDeletionModals();
108 $this->main_tpl->setContent(
109 $this->ui_renderer->render($content)
116 $icon_form = $icon_form_ui->getIconForm();
117 $this->main_tpl->setContent(
118 $this->ui_renderer->render($icon_form)
124 $to_str = $this->
refinery->to()->string();
125 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
129 $this->
ctrl->setParameter($this, self::P_RID, $rid);
130 $icon = $this->icon_repo->getIconByRid($rid);
132 $icon_form = $icon_form_ui->getIconForm();
133 $this->main_tpl->setContent(
134 $this->ui_renderer->render($icon_form)
140 $to_str = $this->
refinery->to()->string();
141 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
145 $icon = $this->icon_repo->getIconByRid($rid);
146 $suffixes = $icon->getSuffixes();
148 $is_default_icon = $icon->isDefaultIcon();
150 if (!$icon->isActive()) {
152 if ($this->icon_repo->causesNoActiveSuffixesConflict($suffixes,
true, $icon)) {
153 $this->icon_repo->updateIcon($rid,
true, $is_default_icon, $suffixes);
155 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_activated'),
true);
157 $this->main_tpl->setOnScreenMessage(
159 $this->
lng->txt(
'msg_error_active_suffixes_conflict'),
164 $this->icon_repo->updateIcon($rid,
false, $is_default_icon, $suffixes);
165 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_deactivated'),
true);
168 $this->
ctrl->redirect($this, self::CMD_INDEX);
174 $form = $ui->getIconForm();
176 if ($this->http_request->getMethod() ===
"POST") {
177 $form = $form->withRequest($this->http_request);
178 $result = $form->getData();
180 if ($result !== null) {
185 $this->icon_repo->createIcon($rid, $active,
false, $suffixes);
188 if (array_diff($suffixes, $this->file_service_settings->getWhiteListedSuffixes()) !== []) {
189 $this->main_tpl->setOnScreenMessage(
191 $this->
lng->txt(
'msg_error_active_suffixes_not_whitelisted'),
197 if (array_intersect($suffixes, $this->file_service_settings->getBlackListedSuffixes()) !== []) {
198 $this->main_tpl->setOnScreenMessage(
200 $this->
lng->txt(
'msg_error_active_suffixes_blacklisted'),
205 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_created'),
true);
206 $this->
ctrl->redirect($this, self::CMD_INDEX);
208 $this->main_tpl->setContent(
209 $this->ui_renderer->render([$form])
217 $to_str = $this->
refinery->to()->string();
218 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
222 $this->
ctrl->saveParameter(
226 $icon = $this->icon_repo->getIconByRid($rid);
228 $form = $ui->getIconForm();
230 if ($this->http_request->getMethod() ===
"POST") {
231 $form = $form->withRequest($this->http_request);
232 $result = $form->getData();
234 if ($result !== null) {
239 $this->icon_repo->updateIcon($rid, $active,
false, $suffixes);
240 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_updated'),
true);
241 $this->
ctrl->redirect($this, self::CMD_INDEX);
243 $this->main_tpl->setContent(
244 $this->ui_renderer->render([$form])
250 public function delete():
void 252 $to_str = $this->
refinery->to()->string();
253 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
259 $is_deleted_from_irss =
false;
260 $id = $this->storage->manage()->find($rid);
263 $is_deleted_from_irss =
true;
266 $is_deleted_from_db = $this->icon_repo->deleteIconByRid($rid);
268 if ($is_deleted_from_irss && $is_deleted_from_db) {
269 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_deletion'),
true);
270 } elseif ($is_deleted_from_irss) {
271 $this->main_tpl->setOnScreenMessage(
273 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->
lng->txt(
'msg_icon_missing_from_db'),
276 } elseif ($is_deleted_from_db) {
277 $this->main_tpl->setOnScreenMessage(
279 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->
lng->txt(
'msg_icon_missing_from_irss'),
283 $this->main_tpl->setOnScreenMessage(
285 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->
lng->txt(
286 'msg_icon_missing_from_db' 287 ) .
" " . $this->
lng->txt(
'msg_icon_missing_from_irss'),
291 $this->
ctrl->redirect($this, self::CMD_INDEX);
const CMD_OPEN_CREATION_FORM
IconRepositoryInterface $icon_repo
ILIAS UI Renderer $ui_renderer
Class ChatMainBarProvider .
ILIAS ResourceStorage Services $storage
const CMD_OPEN_UPDATING_FORM
const CMD_CHANGE_ACTIVATION
ILIAS HTTP Wrapper WrapperFactory $wrapper
ILIAS UI Factory $ui_factory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
Psr Http Message RequestInterface $http_request
ILIAS Refinery Factory $refinery
ilGlobalTemplateInterface $main_tpl
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilFileServicesSettings $file_service_settings