ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
PersonalSettingsTableShowAction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
31use ILIAS\UI\Factory as UIFactory;
34use Psr\Http\Message\ServerRequestInterface;
35
37{
38 public const string ACTION_ID = 'show_template';
39
40 public function __construct(
41 private readonly Language $lng,
42 private readonly UIFactory $ui_factory,
43 private readonly \ilObjUser $user,
44 private readonly PersonalSettingsRepository $repository,
45 private readonly MainSettingsRepository $main_settings_repository,
46 private readonly ScoreSettingsRepository $score_settings_repository,
47 private readonly MarksRepository $marks_repository,
48 private readonly AdditionalInformationGenerator $information_generator,
49 ) {
50 }
51
52 public function getActionId(): string
53 {
54 return self::ACTION_ID;
55 }
56
57 public function buildTableAction(
58 URLBuilder $url_builder,
59 URLBuilderToken $row_id_token,
60 URLBuilderToken $action_token,
61 URLBuilderToken $action_type_token
62 ): Action {
63 return $this->ui_factory->table()->action()->single(
64 $this->lng->txt('personal_settings_show'),
65 $url_builder
66 ->withParameter($action_token, self::ACTION_ID)
67 ->withParameter($action_type_token, ParticipantTableActions::SHOW_ACTION),
68 $row_id_token
69 )->withAsync();
70 }
71
72 public function buildModal(URLBuilder $url_builder, array $selected_templates): ?Modal
73 {
74 if (count($selected_templates) !== 1) {
75 throw new \InvalidArgumentException('Expected exactly one template to show');
76 }
77 $template = reset($selected_templates);
78 $modal_content = [];
79
80 $environment = [
81 'timezone' => new \DateTimeZone($this->user->getTimeZone()),
82 'date_format' => $this->user->getDateFormat()->toString()
83 ];
84
85 $settings_id = $template->getSettingsId();
86 $settings_info = array_merge(
87 $this->main_settings_repository->getById($settings_id)->getArrayForLog($this->information_generator),
88 $this->score_settings_repository->getById($settings_id)->getArrayForLog($this->information_generator),
89 );
90
91 $modal_content[] = $this->information_generator->parseForTable(
92 array_map(static fn(mixed $v): mixed => $v ?? '', $settings_info),
93 $environment
94 );
95
96 $mark_steps = $this->repository->lookupMarkSteps($template->getId());
97 $mark_schema = $this->marks_repository->getMarkSchemaBySteps($mark_steps);
98
99 $modal_content[] = $this->ui_factory->legacy()->content("<h4>{$this->lng->txt('mark_schema')}</h4>");
100
101 // le, 2025-10-27: This is not the right way to go, as a logging facility is used directly for presentation.
102 $modal_content[] = $this->information_generator->parseForTable(
103 $mark_schema->toLog($this->information_generator),
104 $environment
105 );
106
107 return $this->ui_factory->modal()->roundtrip(
108 $this->lng->txt('additional_info'),
109 $modal_content,
110 )->withCancelButtonLabel($this->lng->txt('ok'));
111 }
112
113 public function onSubmit(
114 URLBuilder $url_builder,
115 ServerRequestInterface $request,
116 array $selected_templates,
117 ): ?Modal {
118 return null;
119 }
120}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
onSubmit(URLBuilder $url_builder, ServerRequestInterface $request, array $selected_templates,)
__construct(private readonly Language $lng, private readonly UIFactory $ui_factory, private readonly \ilObjUser $user, private readonly PersonalSettingsRepository $repository, private readonly MainSettingsRepository $main_settings_repository, private readonly ScoreSettingsRepository $score_settings_repository, private readonly MarksRepository $marks_repository, private readonly AdditionalInformationGenerator $information_generator,)
buildTableAction(URLBuilder $url_builder, URLBuilderToken $row_id_token, URLBuilderToken $action_token, URLBuilderToken $action_type_token)
buildModal(URLBuilder $url_builder, array $selected_templates)
User class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between the different modals.
Definition: Modal.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31