19declare(strict_types=1);
22use ILIAS\GlobalScreen\GUI\I18n\Translator;
25use Psr\Http\Message\ServerRequestInterface;
35use ILIAS\GlobalScreen\GUI\Hasher;
118 $this->translator = $pons->
i18n();
119 $this->ui_factory = $this->dic->ui()->factory();
121 $this->dic->database(),
124 $this->group_token = $this->pons->in()->buildToken(
'group',
'id');
130 $this->group_token->token(),
137 $this->pons->in()->getFirstFromRequest($this->group_token)
143 $modal = $this->ui_factory
146 $this->translator->translate(
'group_add'),
149 ->withAsyncRenderUrl(
150 (
string) $this->pons->flow()->getHereAsURI(self::CMD_ADD)
153 $confirm_reset = $this->ui_factory
156 $this->pons->flow()->getHereAsURI(self::CMD_CONFIRM_RESET),
165 $this->translator->translate(
'group_add'),
168 ->withOnClick($modal->getShowSignal())
170 ...$this->ui_factory->helpTopics(
'gsfo_button_add')
179 $this->translator->translate(
'reset_footer'),
182 ->withOnClick($confirm_reset->getShowSignal())
184 ...$this->ui_factory->helpTopics(
'gsfo_button_reset')
188 return [$modal, $confirm_reset];
196 if ($this->pons->access()->hasUserPermissionTo(
'write')) {
201 $this->dic->globalScreen()->collector()->footer()
211 $this->pons->out()->out(
220 $this->pons->out()->outAsync(
221 $this->ui_factory->prompt()->state()->show(
222 $this->ui_factory->messageBox()->confirmation(
223 $this->translator->translate(
'confirm_reset')
226 $this->ui_factory->button()->standard(
227 $this->translator->translate(
'reset'),
228 (
string) $this->pons->flow()->getHereAsURI(self::CMD_RESET)
239 $from_request = $this->pons->in()->getAllFromRequest($this->group_token);
241 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
242 $from_request = array_map(
248 foreach ($from_request as
$id) {
250 if ($group ===
null) {
253 $this->
repository->store($group->withActive(!$group->isActive()));
256 $this->pons->out()->success($this->translator->translate(
'group_activation_toggled'));
257 $this->pons->flow()->redirect(self::CMD_DEFAULT);
265 $nok = $this->pons->out()->nok();
266 $ok = $this->pons->out()->ok();
268 $from_request = $this->pons->in()->getAllFromRequest($this->group_token);
270 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
271 $from_request = array_map(
277 foreach ($from_request as
$id) {
280 if ($group ===
null) {
283 if ($group->isCore()) {
284 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
287 $this->translator->translate(
'info_not_deletable_core') .
288 $this->pons->out()->ui()->renderer()->render(
294 if ($group->getItems() > 0) {
295 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
298 $this->translator->translate(
'info_not_deletable_not_empty') .
299 $this->pons->out()->ui()->renderer()->render($nok)
304 $items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
307 $this->pons->out()->ui()->renderer()->render($ok)
311 $this->pons->out()->outAsyncAsModal(
312 $this->pons->i18n()->translate(
'group_delete'),
313 (
string) $this->pons->flow()->getHereAsURI(self::CMD_DELETE),
319 private function delete():
void
321 $from_request = $this->pons->in()->getAllFromRequest($this->group_token);
323 if (($from_request[0] ??
null) === Input::ALL_OBJECTS) {
324 $from_request = array_map(
330 foreach ($from_request as
$id) {
332 if ($group ===
null) {
335 if ($group->isCore()) {
341 $this->pons->out()->success($this->translator->translate(
'group_deleted'));
342 $this->pons->flow()->redirect(self::CMD_DEFAULT);
346 private function add(): void
353 $action = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
355 $this->pons->out()->outAsyncAsModal(
356 $this->translator->translate(
'group_add'),
369 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
371 $this->pons->in()->request(),
374 $this->pons->flow()->redirect(self::CMD_DEFAULT);
376 $this->pons->out()->out(
386 $id = $this->pons->in()->getFirstFromRequest($this->group_token);
387 $this->pons->in()->keepTokens($this);
397 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_UPDATE);
398 $this->pons->out()->outAsyncAsModal(
399 $this->translator->translate(
'group_edit'),
408 $id = $this->pons->in()->getFirstFromRequest($this->group_token);
418 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_EDIT);
420 $this->pons->in()->request(),
423 $this->pons->flow()->redirect(self::CMD_DEFAULT);
425 $this->pons->out()->out(
436 $this->dic->globalScreen()->collector()->footer()
439 $entries_repo->reset($this->dic->globalScreen()->collector()->footer());
442 $translations->reset();
444 $this->pons->out()->success($this->translator->translate(
'reset_success'));
445 $this->pons->flow()->redirect(self::CMD_DEFAULT);
451 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
452 $item = $this->
repository->get($this->unhash($hashed_id));
453 $item = $item->withPosition((
int) $position);
456 $this->pons->out()->success($this->pons->i18n()->translate(
'order_saved'));
457 $this->pons->flow()->redirect(self::CMD_DEFAULT);
465 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
466 self::CMD_DEFAULT => $this->
index(),
467 self::CMD_ADD => $this->
add(),
468 self::CMD_CREATE => $this->
create(),
469 self::CMD_EDIT => $this->
edit(),
470 self::CMD_UPDATE => $this->
update(),
473 self::CMD_DELETE => $this->
delete(),
475 self::CMD_RESET => $this->
reset(),
476 self::CMD_SAVE_ORDER => $this->
saveOrder(),
477 default => $this->pons->out()->outString(
478 '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)