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 $successful_deletions = 0;
331 foreach ($from_request as
$id) {
333 if ($item ===
null) {
336 if ($item->isCore()) {
340 $successful_deletions++;
343 if ($successful_deletions === 0) {
344 $this->pons->out()->error($this->translator->translate(
'entry_deleted_failed'),
true);
345 $this->pons->flow()->redirect(self::CMD_DEFAULT);
348 $this->pons->out()->success($this->translator->translate(
'entry_deleted'),
true);
349 $this->pons->flow()->redirect(self::CMD_DEFAULT);
353 private function add(): void
360 $action = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
362 $this->pons->out()->outAsyncAsModal(
363 $this->translator->translate(
'group_add'),
376 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_CREATE);
378 $this->pons->in()->request(),
381 $this->pons->flow()->redirect(self::CMD_DEFAULT);
383 $this->pons->out()->out(
393 $id = $this->pons->in()->getFirstFromRequest($this->group_token);
394 $this->pons->in()->keepTokens($this);
404 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_UPDATE);
405 $this->pons->out()->outAsyncAsModal(
406 $this->translator->translate(
'group_edit'),
415 $id = $this->pons->in()->getFirstFromRequest($this->group_token);
425 $target = (string) $this->pons->flow()->getHereAsURI(self::CMD_EDIT);
427 $this->pons->in()->request(),
430 $this->pons->flow()->redirect(self::CMD_DEFAULT);
432 $this->pons->out()->out(
443 $this->dic->globalScreen()->collector()->footer()
446 $entries_repo->reset($this->dic->globalScreen()->collector()->footer());
449 $translations->reset();
451 $this->pons->out()->success($this->translator->translate(
'reset_success'));
452 $this->pons->flow()->redirect(self::CMD_DEFAULT);
458 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
459 $item = $this->
repository->get($this->unhash($hashed_id));
460 $item = $item->withPosition((
int) $position);
463 $this->pons->out()->success($this->pons->i18n()->translate(
'order_saved'));
464 $this->pons->flow()->redirect(self::CMD_DEFAULT);
472 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
473 self::CMD_DEFAULT => $this->
index(),
474 self::CMD_ADD => $this->
add(),
475 self::CMD_CREATE => $this->
create(),
476 self::CMD_EDIT => $this->
edit(),
477 self::CMD_UPDATE => $this->
update(),
480 self::CMD_DELETE => $this->
delete(),
482 self::CMD_RESET => $this->
reset(),
483 self::CMD_SAVE_ORDER => $this->
saveOrder(),
484 default => $this->pons->out()->outString(
485 '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)