19 declare(strict_types=1);
61 $this->
ctrl = $DIC->ctrl();
62 $this->
lng = $DIC->language();
63 $this->
lng->loadLanguageModule(
'file');
64 $this->
toolbar = $DIC->toolbar();
65 $this->main_tpl = $DIC->ui()->mainTemplate();
66 $this->ui_factory = $DIC->ui()->factory();
67 $this->ui_renderer = $DIC->ui()->renderer();
68 $this->http_request = $DIC->http()->request();
69 $this->wrapper = $DIC->http()->wrapper();
71 $this->storage = $DIC->resourceStorage();
73 $this->file_service_settings = $DIC->fileServiceSettings();
78 $next_class = $this->
ctrl->getNextClass(self::class);
79 if ($next_class === strtolower(ilIconUploadHandlerGUI::class)) {
81 $this->
ctrl->forwardCommand($upload_handler);
84 match ($cmd = $this->
ctrl->getCmd(self::CMD_INDEX)) {
88 self::CMD_CREATE => $this->
create(),
89 self::CMD_UPDATE => $this->
update(),
90 self::CMD_DELETE => $this->
delete(),
91 default => $this->
index(),
98 $btn_new_icon = $this->ui_factory->button()->standard(
99 $this->
lng->txt(
'add_icon'),
100 $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_OPEN_CREATION_FORM)
102 $this->
toolbar->addComponent($btn_new_icon);
111 $content[] = $listing->getFilter();
112 $content[] = $listing->getIconList();
113 $content[] = $listing->getDeletionModals();
115 $this->main_tpl->setContent(
116 $this->ui_renderer->render($content)
123 $icon_form = $icon_form_ui->getIconForm();
124 $this->main_tpl->setContent(
125 $this->ui_renderer->render($icon_form)
131 $to_str = $this->
refinery->to()->string();
132 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
136 $this->
ctrl->setParameter($this, self::P_RID, $rid);
137 $icon = $this->icon_repo->getIconByRid($rid);
139 $icon_form = $icon_form_ui->getIconForm();
140 $this->main_tpl->setContent(
141 $this->ui_renderer->render($icon_form)
147 $to_str = $this->
refinery->to()->string();
148 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
152 $icon = $this->icon_repo->getIconByRid($rid);
153 $suffixes = $icon->getSuffixes();
155 $is_default_icon = $icon->isDefaultIcon();
157 if (!$icon->isActive()) {
159 if ($this->icon_repo->causesNoActiveSuffixesConflict($suffixes,
true, $icon)) {
160 $this->icon_repo->updateIcon($rid,
true, $is_default_icon, $suffixes);
162 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_activated'),
true);
164 $this->main_tpl->setOnScreenMessage(
166 $this->
lng->txt(
'msg_error_active_suffixes_conflict'),
171 $this->icon_repo->updateIcon($rid,
false, $is_default_icon, $suffixes);
172 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_deactivated'),
true);
175 $this->
ctrl->redirect($this, self::CMD_INDEX);
181 $form = $ui->getIconForm();
183 if ($this->http_request->getMethod() ===
"POST") {
184 $form = $form->withRequest($this->http_request);
185 $result = $form->getData();
187 if ($result !==
null) {
192 $this->icon_repo->createIcon($rid, $active,
false, $suffixes);
195 if (array_diff($suffixes, $this->file_service_settings->getWhiteListedSuffixes()) !== []) {
196 $this->main_tpl->setOnScreenMessage(
198 $this->
lng->txt(
'msg_error_active_suffixes_not_whitelisted'),
204 if (array_intersect($suffixes, $this->file_service_settings->getBlackListedSuffixes()) !== []) {
205 $this->main_tpl->setOnScreenMessage(
207 $this->
lng->txt(
'msg_error_active_suffixes_blacklisted'),
212 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_created'),
true);
213 $this->
ctrl->redirect($this, self::CMD_INDEX);
215 $this->main_tpl->setContent(
216 $this->ui_renderer->render([$form])
224 $to_str = $this->
refinery->to()->string();
225 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
229 $this->
ctrl->saveParameter(
233 $icon = $this->icon_repo->getIconByRid($rid);
235 $form = $ui->getIconForm();
237 if ($this->http_request->getMethod() ===
"POST") {
238 $form = $form->withRequest($this->http_request);
239 $result = $form->getData();
241 if ($result !==
null) {
246 $this->icon_repo->updateIcon($rid, $active,
false, $suffixes);
247 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_updated'),
true);
248 $this->
ctrl->redirect($this, self::CMD_INDEX);
250 $this->main_tpl->setContent(
251 $this->ui_renderer->render([$form])
257 public function delete():
void 259 $to_str = $this->
refinery->to()->string();
260 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
266 $is_deleted_from_irss =
false;
267 $id = $this->storage->manage()->find($rid);
270 $is_deleted_from_irss =
true;
273 $is_deleted_from_db = $this->icon_repo->deleteIconByRid($rid);
275 if ($is_deleted_from_irss && $is_deleted_from_db) {
276 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_deletion'),
true);
277 } elseif ($is_deleted_from_irss) {
278 $this->main_tpl->setOnScreenMessage(
280 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->
lng->txt(
'msg_icon_missing_from_db'),
283 } elseif ($is_deleted_from_db) {
284 $this->main_tpl->setOnScreenMessage(
286 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->
lng->txt(
'msg_icon_missing_from_irss'),
290 $this->main_tpl->setOnScreenMessage(
292 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->
lng->txt(
293 'msg_icon_missing_from_db' 294 ) .
" " . $this->
lng->txt(
'msg_icon_missing_from_irss'),
298 $this->
ctrl->redirect($this, self::CMD_INDEX);
const CMD_OPEN_CREATION_FORM
IconRepositoryInterface $icon_repo
const CMD_OPEN_UPDATING_FORM
const CMD_CHANGE_ACTIVATION
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ResourceIdentification.
ILIAS Refinery Factory $refinery
ilGlobalTemplateInterface $main_tpl
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilFileServicesSettings $file_service_settings
RequestInterface $http_request