19declare(strict_types=1);
21use ILIAS\GlobalScreen\GUI\I18n\Translator;
24use Psr\Http\Message\ServerRequestInterface;
31use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
110 $this->translator = $pons->
i18n();
112 $this->ui_factory = $this->dic->ui()->factory();
115 $this->dic->database(),
120 $this->dic->database(),
123 $this->group_token = $this->pons->in()->buildToken(
'group',
'id');
124 $this->entry_token = $this->pons->in()->buildToken(
'entry',
'id');
125 $this->group = $group_repository->get(
126 $this->pons->in()->getFirstFromRequest($this->group_token)
128 $this->pons->in()->keep($this->group_token);
134 $this->group_token->token(),
135 $this->entry_token->token(),
142 $this->pons->in()->getFirstFromRequest($this->entry_token->token())
151 if ($this->pons->access()->hasUserPermissionTo(
'write')) {
156 $this->dic->globalScreen()->collector()->footer()
166 $this->pons->out()->out(
173 private function add(): void
181 $target = $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
182 $this->pons->out()->outAsyncAsModal(
183 $this->translator->translate(
'add',
'entries'),
185 $form->get((
string) $target)
191 $modal = $this->ui_factory->modal()->roundtrip(
192 $this->translator->translate(
'add',
'entries'),
194 )->withAsyncRenderUrl(
195 (
string) $this->pons->flow()->getHereAsURI(self::CMD_ADD)
198 $this->dic->toolbar()->addComponent(
202 $this->translator->translate(
'add',
'entries'),
205 ->withOnClick($modal->getShowSignal())
213 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
214 $this->pons->in()->keep($this->entry_token);
227 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
229 $this->pons->in()->request(),
232 $this->pons->flow()->redirect(self::CMD_DEFAULT);
234 $this->pons->out()->out(
254 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_UPDATE);
255 $this->pons->out()->outAsyncAsModal(
256 $this->translator->translate(
'edit',
'entries'),
265 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
274 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
276 $this->pons->in()->request(),
279 $this->pons->flow()->redirect(self::CMD_DEFAULT);
281 $this->pons->out()->out(
289 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
291 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
292 $from_request = array_map(
298 foreach ($from_request as
$id) {
300 if ($entry ===
null) {
303 $this->
repository->store($entry->withActive(!$entry->isActive()));
306 $this->pons->out()->success($this->translator->translate(
'group_activation_toggled'),
true);
307 $this->pons->flow()->redirect(self::CMD_DEFAULT);
315 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
317 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
318 $from_request = array_map(
324 foreach ($from_request as
$id) {
326 if ($entry ===
null) {
329 if ($entry->isCore()) {
330 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
333 $this->translator->translate(
'info_not_deletable_core') .
334 $this->pons->out()->render($this->pons->out()->nok())
338 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
339 $this->hash($entry->getId()),
341 $this->pons->out()->render($this->pons->out()->ok())
345 $this->pons->out()->outAsyncAsModal(
346 $this->translator->translate(
'entry_delete'),
347 $this->pons->flow()->getHereAsURI(self::CMD_DELETE),
353 private function delete():
void
355 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
357 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
358 $from_request = array_map(
364 foreach ($from_request as
$id) {
366 if ($item ===
null) {
369 if ($item->isCore()) {
375 $this->pons->out()->success($this->translator->translate(
'entry_deleted'),
true);
376 $this->pons->flow()->redirect(self::CMD_DEFAULT);
381 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
382 $item = $this->
repository->get($this->unhash($hashed_id));
383 $item = $item->withPosition((
int) $position);
386 $this->pons->out()->success($this->pons->i18n()->translate(
'order_saved'));
387 $this->pons->flow()->redirect(self::CMD_DEFAULT);
395 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
396 self::CMD_DEFAULT => $this->
index(),
397 self::CMD_ADD => $this->
add(),
398 self::CMD_CREATE => $this->
create(),
399 self::CMD_EDIT => $this->
edit(),
400 self::CMD_UPDATE => $this->
update(),
402 self::CMD_DELETE => $this->
delete(),
404 self::CMD_SAVE_ORDER => $this->
saveOrder(),
405 default => $this->pons->out()->outString(
406 'Unknown command: ' . $this->pons->flow()->getCommand(self::CMD_DEFAULT)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Customizing of pimple-DIC for ILIAS.
Builds a Color from either hex- or rgb values.
This is how the factory for UI elements looks.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
button(string $caption, string $cmd)