ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
IconListingUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\File\Icon;
22
27
32{
33 private \ilCtrl $ctrl;
34 private \ilLanguage $lng;
36 private \ILIAS\Refinery\Factory $refinery;
38 private array $deletion_modals = [];
40 private \ilUIFilterService $filter_service;
41 private \ILIAS\UI\Component\Input\Container\Filter\Standard $filter;
42
43 public function __construct(
44 private IconRepositoryInterface $icon_repo,
45 private ilObjFileIconsOverviewGUI $gui,
46 private bool $write_access
47 ) {
48 global $DIC;
49
50 $this->ctrl = $DIC->ctrl();
51 $this->lng = $DIC->language();
52 $this->lng->loadLanguageModule('file');
53 $this->ui_factory = $DIC->ui()->factory();
54 $this->refinery = $DIC->refinery();
55 $this->storage = $DIC->resourceStorage();
56 $this->filter_service = $DIC->uiService()->filter();
57
58 $this->initFilter();
59 $this->initListing();
60 }
61
62 private function initFilter(): void
63 {
64 // Filters
65 $this->filter = $this->filter_service->standard(
66 $this->gui::class . '_filter7',
67 $this->ctrl->getLinkTarget($this->gui),
68 [
69 'suffixes' => $this->ui_factory->input()->field()->text($this->lng->txt('suffixes')),
70 'active' => $this->ui_factory->input()->field()->select($this->lng->txt('status'), [
71 '1' => $this->lng->txt('active'),
72 '0' => $this->lng->txt('inactive'),
73 ])->withValue('1'),
74 'is_default_icon' => $this->ui_factory->input()->field()->select($this->lng->txt('default'), [
75 '1' => $this->lng->txt('yes'),
76 '0' => $this->lng->txt('no'),
77 ])
78 ],
79 [
80 'suffix' => true,
81 'status' => true,
82 'type' => true,
83 ],
84 true,
85 true
86 );
87 }
88
89 public function getFilter(): \ILIAS\UI\Component\Input\Container\Filter\Standard
90 {
91 return $this->filter;
92 }
93
94 protected function initListing(): void
95 {
96 $icon_items = [];
97 $this->icon_repo->getIcons();
98
99 // Filterting
100 $filter_data = $this->filter_service->getData($this->filter) ?? [];
101
102 foreach ($this->icon_repo->getIconsForFilter($filter_data) as $icon) {
103 $this->ctrl->setParameterByClass(
104 ilObjFileIconsOverviewGUI::class,
106 $icon->getRid()
107 );
108 $edit_target = $this->ctrl->getLinkTargetByClass(
109 ilObjFileIconsOverviewGUI::class,
111 );
112 $change_activation_target = $this->ctrl->getLinkTargetByClass(
113 ilObjFileIconsOverviewGUI::class,
115 );
116 $this->deletion_modals[] = $deletion_modal = $this->getDeletionConfirmationModal($icon);
117
118 if ($this->write_access) {
119 $item_action_entries = [
120 $this->ui_factory->button()->shy(
121 $this->lng->txt('de_activate_icon'),
122 $change_activation_target
123 )
124 ];
125 if (!$icon->isDefaultIcon()) {
126 $item_action_entries[] = $this->ui_factory->button()->shy($this->lng->txt('edit'), $edit_target);
127 $item_action_entries[] = $this->ui_factory->button()->shy($this->lng->txt('delete'), '#')->withOnClick(
128 $deletion_modal->getShowSignal()
129 );
130 }
131 } else {
132 $item_action_entries = [];
133 }
134
135 $item_actions = $this->ui_factory->dropdown()->standard($item_action_entries);
136
137 $id = $this->storage->manage()->find($icon->getRid());
138 $icon_src = "";
139 if ($id !== null) {
140 $icon_src = $this->storage->consume()->src($id)->getSrc();
141 }
142
143 $suffixes_array_into_string = $this->icon_repo->turnSuffixesArrayIntoString(
144 $icon->getSuffixes()
145 );
146
147 $icon_image = $this->ui_factory->symbol()->icon()->custom(
148 $icon_src,
149 "Icon $suffixes_array_into_string"
150 )->withSize('large');
151
152 $icon_items[] = $this->ui_factory->item()
153 ->standard($this->lng->txt('icon') . " $suffixes_array_into_string")
154 ->withActions($item_actions)
155 ->withProperties(
156 [
157 $this->lng->txt('active') => $icon->isActive() ? $this->lng->txt(
158 'yes'
159 ) : $this->lng->txt('no'),
160 $this->lng->txt('default') => $icon->isDefaultIcon(
161 ) ? $this->lng->txt('yes') : $this->lng->txt('no'),
162 $this->lng->txt(
163 'suffixes'
164 ) => $suffixes_array_into_string
165 ]
166 )
167 ->withLeadIcon($icon_image);
168 }
169
170 $this->icon_list = $this->ui_factory->panel()->listing()->standard(
171 $this->lng->txt('suffix_specific_icons'),
172 [$this->ui_factory->item()->group("", $icon_items)]
173 );
174 }
175
176 public function getIconList(): Standard
177 {
178 return $this->icon_list;
179 }
180
184 public function getDeletionModals(): array
185 {
187 }
188
190 {
191 $target = $this->ctrl->getLinkTargetByClass(
192 ilObjFileIconsOverviewGUI::class,
194 );
195 $rid = $this->refinery->kindlyTo()->string()->transform($a_icon->getRid());
196
197 $id = $this->storage->manage()->find($rid);
198 $icon_src = "";
199 if ($id !== null) {
200 $icon_src = $this->storage->consume()->src($id)->getSrc();
201 }
202 $img_icon = $this->ui_factory->image()->standard(
203 $icon_src,
204 "Icon"
205 );
206 $txt_suffixes = $this->lng->txt('suffixes') . ": " . $this->icon_repo->turnSuffixesArrayIntoString(
207 $a_icon->getSuffixes()
208 );
209
210 return $this->ui_factory->modal()->interruptive(
211 $this->lng->txt("delete"),
212 $this->lng->txt('msg_confirm_entry_deletion'),
213 $target
214 )->withAffectedItems([
215 $this->ui_factory->modal()->interruptiveItem()->standard(
216 $rid,
217 $txt_suffixes,
218 $img_icon
219 )
220 ]);
221 }
222}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
ILIAS Refinery Factory $refinery
ilUIFilterService $filter_service
getDeletionConfirmationModal(Icon $a_icon)
__construct(private IconRepositoryInterface $icon_repo, private ilObjFileIconsOverviewGUI $gui, private bool $write_access)
ILIAS UI Component Input Container Filter Standard $filter
Definition: UI.php:24
This describes a Standard Dropdown.
Definition: Standard.php:27
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26