19declare(strict_types=1);
22use ILIAS\GlobalScreen\GUI\I18n\Translator;
25use Psr\Http\Message\ServerRequestInterface;
32use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
116 $this->translator = $pons->
i18n();
118 $this->ui_factory = $this->dic->ui()->factory();
121 $this->dic->database(),
126 $this->dic->database(),
129 $this->group_token = $this->pons->in()->buildToken(
'group',
'id');
130 $this->entry_token = $this->pons->in()->buildToken(
'entry',
'id');
131 $this->group = $this->groups_repository->get(
132 $this->pons->in()->getFirstFromRequest($this->group_token)
134 $this->pons->in()->keep($this->group_token);
140 $this->group_token->token(),
141 $this->entry_token->token(),
148 $this->pons->in()->getFirstFromRequest($this->entry_token->token())
157 if ($this->pons->access()->hasUserPermissionTo(
'write')) {
162 $this->dic->globalScreen()->collector()->footer()
172 $this->pons->out()->out(
179 private function add(): void
187 $target = $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
188 $this->pons->out()->outAsyncAsModal(
189 $this->translator->translate(
'add',
'entries'),
191 $form->get((
string) $target)
197 $modal = $this->ui_factory->modal()->roundtrip(
198 $this->translator->translate(
'add',
'entries'),
200 )->withAsyncRenderUrl(
201 (
string) $this->pons->flow()->getHereAsURI(self::CMD_ADD)
204 $this->dic->toolbar()->addComponent(
208 $this->translator->translate(
'add',
'entries'),
211 ->withOnClick($modal->getShowSignal())
219 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
220 $this->pons->in()->keep($this->entry_token);
233 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
235 $this->pons->in()->request(),
238 $this->pons->flow()->redirect(self::CMD_DEFAULT);
240 $this->pons->out()->out(
260 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_UPDATE);
261 $this->pons->out()->outAsyncAsModal(
262 $this->translator->translate(
'edit',
'entries'),
271 $id = $this->pons->in()->getFirstFromRequest($this->entry_token);
280 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
282 $this->pons->in()->request(),
285 $this->pons->flow()->redirect(self::CMD_DEFAULT);
287 $this->pons->out()->out(
295 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
297 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
298 $from_request = array_map(
304 foreach ($from_request as
$id) {
306 if ($entry ===
null) {
309 $this->
repository->store($entry->withActive(!$entry->isActive()));
312 $this->pons->out()->success($this->translator->translate(
'group_activation_toggled'),
true);
313 $this->pons->flow()->redirect(self::CMD_DEFAULT);
321 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
323 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
324 $from_request = array_map(
330 foreach ($from_request as
$id) {
332 if ($entry ===
null) {
335 if ($entry->isCore()) {
336 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
339 $this->translator->translate(
'info_not_deletable_core') .
340 $this->pons->out()->render($this->pons->out()->nok())
344 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
345 $this->hash($entry->getId()),
347 $this->pons->out()->render($this->pons->out()->ok())
351 $this->pons->out()->outAsyncAsModal(
352 $this->translator->translate(
'entry_delete'),
353 $this->pons->flow()->getHereAsURI(self::CMD_DELETE),
359 private function delete():
void
361 $from_request = $this->pons->in()->getAllFromRequest($this->entry_token);
363 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
364 $from_request = array_map(
370 $successful_deletions = 0;
371 foreach ($from_request as
$id) {
373 if ($item ===
null) {
376 if ($item->isCore()) {
380 $successful_deletions++;
383 if ($successful_deletions === 0) {
384 $this->pons->out()->error($this->translator->translate(
'entry_deleted_failed'),
true);
385 $this->pons->flow()->redirect(self::CMD_DEFAULT);
388 $this->pons->out()->success($this->translator->translate(
'entry_deleted'),
true);
389 $this->pons->flow()->redirect(self::CMD_DEFAULT);
395 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
396 $item = $this->
repository->get($this->unhash($hashed_id));
397 $item = $item->withPosition((
int) $position);
400 $this->pons->out()->success($this->pons->i18n()->translate(
'order_saved'));
401 $this->pons->flow()->redirect(self::CMD_DEFAULT);
407 $all_groups = $this->groups_repository->all();
410 foreach ($all_groups as
$group) {
411 if ($this->group !==
null &&
$group->
getId() === $this->group->getId()) {
417 return $this->pons->out()->ui()->factory()->input()->container()->form()->standard(
420 $this->pons->out()->ui()->factory()->input()->field()->select(
421 $this->pons->i18n()->t(
'target_group',
'entries'),
423 )->withRequired(
true)
431 $this->pons->in()->keepTokens($this);
433 $post_url = $this->pons->flow()->getHereAsURI(self::CMD_MOVE);
434 $this->pons->out()->outAsyncAsModal(
435 $this->pons->i18n()->t(self::CMD_MOVE),
437 $this->buildTargetSelectorForm($post_url)
442 private function move(): void
445 $this->pons->in()->request()
448 if ((
$data = $form->getData()) ===
null) {
449 $this->pons->out()->error($this->pons->i18n()->t(
'no_parent_selected'),
true);
450 $this->pons->flow()->redirect(self::CMD_DEFAULT);
455 $parent_group = $this->unhash(
$data[0] ??
'');
456 }
catch (Throwable
$e) {
457 $this->pons->out()->error($this->pons->i18n()->t(
'no_parent_selected'),
true);
458 $this->pons->flow()->redirect(self::CMD_DEFAULT);
466 $this->
repository->store($selected_item->withParent($parent_group));
467 $this->pons->out()->success($this->pons->i18n()->t(
'item_moved'),
true);
468 $this->pons->flow()->redirect(self::CMD_DEFAULT);
476 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
477 self::CMD_DEFAULT => $this->
index(),
478 self::CMD_ADD => $this->
add(),
479 self::CMD_CREATE => $this->
create(),
480 self::CMD_EDIT => $this->
edit(),
481 self::CMD_UPDATE => $this->
update(),
483 self::CMD_DELETE => $this->
delete(),
485 self::CMD_SAVE_ORDER => $this->
saveOrder(),
487 self::CMD_MOVE => $this->move(),
488 default => $this->pons->out()->outString(
489 '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.
The scope of this class is split ilias-conform URI's into components.
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)