19declare(strict_types=1);
26use Psr\Http\Message\RequestInterface;
63 $this->
ctrl = $DIC->ctrl();
64 $this->
access = $DIC->access();
65 $this->
lng = $DIC->language();
66 $this->
lng->loadLanguageModule(
'file');
67 $this->
toolbar = $DIC->toolbar();
68 $this->main_tpl =
$DIC->ui()->mainTemplate();
69 $this->ui_factory =
$DIC->ui()->factory();
70 $this->ui_renderer =
$DIC->ui()->renderer();
71 $this->http_request =
$DIC->http()->request();
72 $this->wrapper =
$DIC->http()->wrapper();
74 $this->storage =
$DIC->resourceStorage();
76 $this->file_service_settings =
$DIC->fileServiceSettings();
77 $this->write_access = $this->
access->checkAccess(
80 (
int) ($this->http_request->getQueryParams()[
'ref_id'] ?? 0)
86 $next_class = $this->
ctrl->getNextClass(self::class);
87 if ($next_class === strtolower(ilIconUploadHandlerGUI::class)) {
89 $this->
ctrl->forwardCommand($upload_handler);
92 match ($cmd = $this->
ctrl->getCmd(self::CMD_INDEX)) {
96 self::CMD_CREATE => $this->
create(),
97 self::CMD_UPDATE => $this->
update(),
98 self::CMD_DELETE => $this->
delete(),
99 default => $this->
index(),
106 if ($this->write_access) {
107 $btn_new_icon = $this->ui_factory->button()->standard(
108 $this->
lng->txt(
'add_icon'),
109 $this->ctrl->getLinkTargetByClass(self::class, self::CMD_OPEN_CREATION_FORM)
111 $this->
toolbar->addComponent($btn_new_icon);
122 $content[] = $listing->getFilter();
123 $content[] = $listing->getIconList();
124 $content[] = $listing->getDeletionModals();
126 $this->main_tpl->setContent(
127 $this->ui_renderer->render($content)
134 $icon_form = $icon_form_ui->getIconForm();
135 $this->main_tpl->setContent(
136 $this->ui_renderer->render($icon_form)
142 $to_str = $this->
refinery->to()->string();
143 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
147 $this->
ctrl->setParameter($this, self::P_RID, $rid);
148 $icon = $this->icon_repo->getIconByRid($rid);
150 $icon_form = $icon_form_ui->getIconForm();
151 $this->main_tpl->setContent(
152 $this->ui_renderer->render($icon_form)
158 $to_str = $this->
refinery->to()->string();
159 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
163 $icon = $this->icon_repo->getIconByRid($rid);
164 $suffixes = $icon->getSuffixes();
166 $is_default_icon = $icon->isDefaultIcon();
168 if (!$icon->isActive()) {
170 if ($this->icon_repo->causesNoActiveSuffixesConflict($suffixes,
true, $icon)) {
171 $this->icon_repo->updateIcon($rid,
true, $is_default_icon, $suffixes);
173 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_activated'),
true);
175 $this->main_tpl->setOnScreenMessage(
177 $this->
lng->txt(
'msg_error_active_suffixes_conflict'),
182 $this->icon_repo->updateIcon($rid,
false, $is_default_icon, $suffixes);
183 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_deactivated'),
true);
186 $this->
ctrl->redirect($this, self::CMD_INDEX);
192 $form = $ui->getIconForm();
194 if ($this->http_request->getMethod() ===
"POST") {
195 $form = $form->withRequest($this->http_request);
196 $result = $form->getData();
198 if ($result !==
null) {
203 $this->icon_repo->createIcon($rid, $active,
false, $suffixes);
206 if (array_diff($suffixes, $this->file_service_settings->getWhiteListedSuffixes()) !== []) {
207 $this->main_tpl->setOnScreenMessage(
209 $this->
lng->txt(
'msg_error_active_suffixes_not_whitelisted'),
215 if (array_intersect($suffixes, $this->file_service_settings->getBlackListedSuffixes()) !== []) {
216 $this->main_tpl->setOnScreenMessage(
218 $this->
lng->txt(
'msg_error_active_suffixes_blacklisted'),
223 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_created'),
true);
224 $this->
ctrl->redirect($this, self::CMD_INDEX);
226 $this->main_tpl->setContent(
227 $this->ui_renderer->render([$form])
235 $to_str = $this->
refinery->to()->string();
236 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
240 $this->
ctrl->saveParameter(
244 $icon = $this->icon_repo->getIconByRid($rid);
246 $form = $ui->getIconForm();
248 if ($this->http_request->getMethod() ===
"POST") {
249 $form = $form->withRequest($this->http_request);
250 $result = $form->getData();
252 if ($result !==
null) {
257 $this->icon_repo->updateIcon($rid, $active,
false, $suffixes);
258 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_updated'),
true);
259 $this->
ctrl->redirect($this, self::CMD_INDEX);
261 $this->main_tpl->setContent(
262 $this->ui_renderer->render([$form])
268 public function delete():
void
270 $to_str = $this->
refinery->to()->string();
271 $rid = $this->wrapper->query()->has(self::P_RID) ? $rid = $this->wrapper->query()->retrieve(
277 $is_deleted_from_irss =
false;
278 $id = $this->storage->manage()->find($rid);
281 $is_deleted_from_irss =
true;
284 $is_deleted_from_db = $this->icon_repo->deleteIconByRid($rid);
286 if ($is_deleted_from_irss && $is_deleted_from_db) {
287 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_success_icon_deletion'),
true);
288 } elseif ($is_deleted_from_irss) {
289 $this->main_tpl->setOnScreenMessage(
291 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->lng->txt(
'msg_icon_missing_from_db'),
294 } elseif ($is_deleted_from_db) {
295 $this->main_tpl->setOnScreenMessage(
297 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->lng->txt(
'msg_icon_missing_from_irss'),
301 $this->main_tpl->setOnScreenMessage(
303 $this->
lng->txt(
'msg_error_icon_deletion') .
" " . $this->lng->txt(
304 'msg_icon_missing_from_db'
305 ) .
" " . $this->lng->txt(
'msg_icon_missing_from_irss'),
309 $this->
ctrl->redirect($this, self::CMD_INDEX);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
RequestInterface $http_request
const CMD_OPEN_CREATION_FORM
ilGlobalTemplateInterface $main_tpl
const CMD_OPEN_UPDATING_FORM
IconRepositoryInterface $icon_repo
const CMD_CHANGE_ACTIVATION
ilFileServicesSettings $file_service_settings
ILIAS Refinery Factory $refinery
Class ResourceIdentification.
An entity that renders components to a string output.