ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 private \ILIAS\HTTP\Services $http;
43
44 public function __construct(
45 private IconRepositoryInterface $icon_repo,
46 private object $gui
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->http = $DIC->http();
57 $this->filter_service = $DIC->uiService()->filter();
58
59 $this->initFilter();
60 $this->initListing();
61 }
62
63 private function initFilter(): void
64 {
65 // Filters
66 $this->filter = $this->filter_service->standard(
67 $this->gui::class . '_filter7',
68 $this->ctrl->getLinkTarget($this->gui),
69 [
70 'suffixes' => $this->ui_factory->input()->field()->text($this->lng->txt('suffixes')),
71 'active' => $this->ui_factory->input()->field()->select($this->lng->txt('status'), [
72 '1' => $this->lng->txt('active'),
73 '0' => $this->lng->txt('inactive'),
74 ])->withValue('1'),
75 'is_default_icon' => $this->ui_factory->input()->field()->select($this->lng->txt('default'), [
76 '1' => $this->lng->txt('yes'),
77 '0' => $this->lng->txt('no'),
78 ])
79 ],
80 [
81 'suffix' => true,
82 'status' => true,
83 'type' => true,
84 ],
85 true,
86 true
87 );
88 }
89
90 public function getFilter(): \ILIAS\UI\Component\Input\Container\Filter\Standard
91 {
92 return $this->filter;
93 }
94
95 protected function initListing(): void
96 {
97 $icon_items = [];
98 $this->icon_repo->getIcons();
99
100 // Filterting
101 $filter_data = $this->filter_service->getData($this->filter) ?? [];
102
103 foreach ($this->icon_repo->getIconsForFilter($filter_data) as $icon) {
104 $this->ctrl->setParameterByClass(
105 ilObjFileIconsOverviewGUI::class,
107 $icon->getRid()
108 );
109 $edit_target = $this->ctrl->getLinkTargetByClass(
110 ilObjFileIconsOverviewGUI::class,
112 );
113 $change_activation_target = $this->ctrl->getLinkTargetByClass(
114 ilObjFileIconsOverviewGUI::class,
116 );
117 $this->deletion_modals[] = $deletion_modal = $this->getDeletionConfirmationModal($icon);
118
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 $item_actions = $this->ui_factory->dropdown()->standard($item_action_entries);
132
133 $id = $this->storage->manage()->find($icon->getRid());
134 $icon_src = "";
135 if ($id !== null) {
136 $icon_src = $this->storage->consume()->src($id)->getSrc();
137 }
138
139 $suffixes_array_into_string = $this->icon_repo->turnSuffixesArrayIntoString(
140 $icon->getSuffixes()
141 );
142
143 $icon_image = $this->ui_factory->symbol()->icon()->custom(
144 $icon_src,
145 "Icon $suffixes_array_into_string"
146 )->withSize('large');
147
148 $icon_items[] = $this->ui_factory->item()
149 ->standard($this->lng->txt('icon') . " $suffixes_array_into_string")
150 ->withActions($item_actions)
151 ->withProperties(
152 [
153 $this->lng->txt('active') => $icon->isActive() ? $this->lng->txt(
154 'yes'
155 ) : $this->lng->txt('no'),
156 $this->lng->txt('default') => $icon->isDefaultIcon(
157 ) ? $this->lng->txt('yes') : $this->lng->txt('no'),
158 $this->lng->txt(
159 'suffixes'
160 ) => $suffixes_array_into_string
161 ]
162 )
163 ->withLeadIcon($icon_image);
164 }
165
166 $this->icon_list = $this->ui_factory->panel()->listing()->standard(
167 $this->lng->txt('suffix_specific_icons'),
168 [$this->ui_factory->item()->group("", $icon_items)]
169 );
170 }
171
172 public function getIconList(): Standard
173 {
174 return $this->icon_list;
175 }
176
180 public function getDeletionModals(): array
181 {
183 }
184
186 {
187 $target = $this->ctrl->getLinkTargetByClass(
188 ilObjFileIconsOverviewGUI::class,
190 );
191 $rid = $this->refinery->kindlyTo()->string()->transform($a_icon->getRid());
192
193 $id = $this->storage->manage()->find($rid);
194 $icon_src = "";
195 if ($id !== null) {
196 $icon_src = $this->storage->consume()->src($id)->getSrc();
197 }
198 $img_icon = $this->ui_factory->image()->standard(
199 $icon_src,
200 "Icon"
201 );
202 $txt_suffixes = $this->lng->txt('suffixes') . ": " . $this->icon_repo->turnSuffixesArrayIntoString(
203 $a_icon->getSuffixes()
204 );
205
206 return $this->ui_factory->modal()->interruptive(
207 $this->lng->txt("delete"),
208 $this->lng->txt('msg_confirm_entry_deletion'),
209 $target
210 )->withAffectedItems([
211 $this->ui_factory->modal()->interruptiveItem()->standard(
212 $rid,
213 $txt_suffixes,
214 $img_icon
215 )
216 ]);
217 }
218}
$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
ILIAS HTTP Services $http
getDeletionConfirmationModal(Icon $a_icon)
__construct(private IconRepositoryInterface $icon_repo, private object $gui)
ILIAS UI Component Input Container Filter Standard $filter
Definition: UI.php:24
This describes a Standard Dropdown.
Definition: Standard.php:27
static http()
Fetches the global http state from ILIAS.
filter(string $filter_id, $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