ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\ConsumerToolbox\Blocks Class Reference
+ Collaboration diagram for ILIAS\LegalDocuments\ConsumerToolbox\Blocks:

Public Member Functions

 __construct (private readonly string $id, private readonly Container $container, private readonly Provide $provide, ?Closure $format_date=null, ?Closure $mail_contact=null)
 
 slot ()
 
 defaultMappings ()
 
 marshal ()
 
 selectSettingsFrom (KeyValueStore $store)
 
 readOnlyStore (KeyValueStore $store)
 
 globalStore ()
 
 userStore (ilObjUser $user)
 
 sessionStore ()
 
 ui ()
 
 user (Settings $global_settings, UserSettings $user_settings, ilObjUser $user)
 
 routing ()
 
 retrieveQueryParameter (string $key, Closure $select)
 
 userManagementAgreeDateField (callable $build_user, string $lang_key, ?string $module=null)
 
 withRequest (Form $form, Closure $then)
 
 notAvailable ()
 

Private Member Functions

 formatDate (?DateTimeImmutable $date)
 

Private Attributes

readonly Closure $format_date
 
readonly Closure $mail_contact
 

Detailed Description

Definition at line 48 of file Blocks.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::__construct ( private readonly string  $id,
private readonly Container  $container,
private readonly Provide  $provide,
?Closure  $format_date = null,
?Closure  $mail_contact = null 
)
Parameters
null|Closure(DateTimeImmutable)string $format_date
null|Closure()string $mail_contact

Definition at line 59 of file Blocks.php.

65 {
66 $this->format_date = $format_date ?? fn(DateTimeImmutable $date): string => ilDatePresentation::formatDate(
67 new ilDateTime($date->getTimestamp(), IL_CAL_UNIX)
68 );
70 }
formatDate(?DateTimeImmutable $date)
Definition: Blocks.php:202
const IL_CAL_UNIX
Class for date presentation.
@classDescription Date and time handling
static getMailsToAddress()
Get mailto: emails.

References ILIAS\LegalDocuments\ConsumerToolbox\Blocks\$format_date, ILIAS\LegalDocuments\ConsumerToolbox\Blocks\$mail_contact, ilDatePresentation\formatDate(), ilSystemSupportContacts\getMailsToAddress(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

Member Function Documentation

◆ defaultMappings()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::defaultMappings ( )

Definition at line 82 of file Blocks.php.

82 : DefaultMappings
83 {
84 return new DefaultMappings($this->id, $this->container);
85 }

◆ formatDate()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::formatDate ( ?DateTimeImmutable  $date)
private

Definition at line 202 of file Blocks.php.

202 : string
203 {
204 return $date ? ($this->format_date)($date) : '';
205 }

References ILIAS\LegalDocuments\ConsumerToolbox\Blocks\$format_date.

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\Blocks\userManagementAgreeDateField().

+ Here is the caller graph for this function:

◆ globalStore()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::globalStore ( )

Definition at line 102 of file Blocks.php.

103 {
104 return new ILIASSettingStore($this->container->settings());
105 }

◆ marshal()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::marshal ( )

Definition at line 87 of file Blocks.php.

87 : Marshal
88 {
89 return new Marshal($this->container->refinery());
90 }

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\Blocks\selectSettingsFrom().

+ Here is the caller graph for this function:

◆ notAvailable()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::notAvailable ( )

Definition at line 192 of file Blocks.php.

192 : PageFragment
193 {
194 return new PageContent($this->ui()->txt('accept_usr_agreement_anonymous'), [
195 $this->container->ui()->factory()->legacy()->content(sprintf(
196 $this->ui()->txt('no_agreement_description'),
197 'mailto:' . htmlspecialchars(($this->mail_contact)(), ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8')
198 )),
199 ]);
200 }

References ILIAS\LegalDocuments\ConsumerToolbox\Blocks\ui().

Referenced by ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest\testNotAvailable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readOnlyStore()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::readOnlyStore ( KeyValueStore  $store)

Definition at line 97 of file Blocks.php.

98 {
99 return new ReadOnlyStore($store);
100 }

◆ retrieveQueryParameter()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::retrieveQueryParameter ( string  $key,
Closure  $select 
)
Parameters
Closure(Refinery)Transformation $select

Definition at line 140 of file Blocks.php.

141 {
142 return $this->container->http()->wrapper()->query()->retrieve($key, $select($this->container->refinery()));
143 }

◆ routing()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::routing ( )

Definition at line 127 of file Blocks.php.

127 : Routing
128 {
129 return new Routing(
130 $this->container->ctrl(),
131 $this->selectSettingsFrom($this->sessionStore()),
134 );
135 }
static redirectToStartingPage(string $target='')
static logoutUrl(array $parameters=[])
Return the logout URL with a valid CSRF token.

References ilStartUpGUI\logoutUrl(), and ilInitialisation\redirectToStartingPage().

+ Here is the call graph for this function:

◆ selectSettingsFrom()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::selectSettingsFrom ( KeyValueStore  $store)

Definition at line 92 of file Blocks.php.

92 : SelectSetting
93 {
94 return new SelectSetting($store, $this->marshal());
95 }

References ILIAS\LegalDocuments\ConsumerToolbox\Blocks\marshal().

+ Here is the call graph for this function:

◆ sessionStore()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::sessionStore ( )

Definition at line 112 of file Blocks.php.

113 {
114 return new SessionStore();
115 }

◆ slot()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::slot ( )

Definition at line 72 of file Blocks.php.

72 : Slot
73 {
74 return new Slot(
75 $this->id,
76 $this,
77 $this->provide,
78 $this->container
79 );
80 }

◆ ui()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::ui ( )

Definition at line 117 of file Blocks.php.

117 : UI
118 {
119 return new UI($this->id, $this->container->ui(), $this->container->language());
120 }

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\Blocks\notAvailable(), and ILIAS\LegalDocuments\ConsumerToolbox\Blocks\userManagementAgreeDateField().

+ Here is the caller graph for this function:

◆ user()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::user ( Settings  $global_settings,
UserSettings  $user_settings,
ilObjUser  $user 
)

Definition at line 122 of file Blocks.php.

122 : User
123 {
124 return new User($user, $global_settings, $user_settings, $this->provide, (new DataFactory())->clock()->system());
125 }

◆ userManagementAgreeDateField()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::userManagementAgreeDateField ( callable  $build_user,
string  $lang_key,
?string  $module = null 
)

Definition at line 145 of file Blocks.php.

145 : Closure
146 {
147 return function (ilObjUser $user) use ($build_user, $lang_key, $module) {
148 if ($module) {
149 $this->container->language()->loadLanguageModule($module);
150 }
151 $this->container->language()->loadLanguageModule('ldoc');
152 $user = $build_user($user);
153
154 $value = $user->acceptedVersion()->map(function (DocumentContent $content) use ($lang_key, $user): array {
155 $input = new ilNonEditableValueGUI($this->ui()->txt($lang_key), $lang_key);
156 $input->setValue($this->formatDate($user->agreeDate()->value()));
157 $modal = $this->ui()->create()->modal()->lightbox([
158 $this->ui()->create()->modal()->lightboxTextPage($content->value(), $content->title())
159 ]);
160
161 $titleLink = $this->ui()->create()->button()->shy($content->title(), '#')->withOnClick($modal->getShowSignal());
162 $sub = new ilNonEditableValueGUI($this->ui()->txt('agreement_document'), '', true);
163 $sub->setValue($this->container->ui()->renderer()->render($titleLink));
164 $input->addSubItem($sub);
165
166 return [$input, $modal];
167 })->except(fn() => new Ok($this->ui()->txt('never')))->value();
168
169 return [$lang_key => $value];
170 };
171 }
This class represents a non editable value in a property form.
User class.
modal(string $title="", string $cancel_label="")

References ILIAS\LegalDocuments\ConsumerToolbox\Blocks\formatDate(), ILIAS\Repository\modal(), ILIAS\LegalDocuments\Value\DocumentContent\title(), ILIAS\LegalDocuments\ConsumerToolbox\Blocks\ui(), and ILIAS\LegalDocuments\Value\DocumentContent\value().

Referenced by ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest\testUserManagementAgreeDateField().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userStore()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::userStore ( ilObjUser  $user)

Definition at line 107 of file Blocks.php.

108 {
109 return new UserPreferenceStore($user);
110 }

◆ withRequest()

ILIAS\LegalDocuments\ConsumerToolbox\Blocks::withRequest ( Form  $form,
Closure  $then 
)
Parameters
Closure(array)void $then

Definition at line 176 of file Blocks.php.

176 : Form
177 {
178 if ($this->container->http()->request()->getMethod() !== 'POST') {
179 return $form;
180 }
181
182 $form = $form->withRequest($this->container->http()->request());
183 $data = $form->getData();
184
185 if ($data) {
186 $then($data);
187 }
188
189 return $form;
190 }
withRequest(ServerRequestInterface $request)
Get a form like this where data from the request is attached.
getData()
Get the data in the form if all inputs are ok, where the transformation is applied if one was added.
This describes commonalities between all forms.
Definition: Form.php:33

References $data, ILIAS\UI\Component\Input\Container\Container\getData(), and ILIAS\UI\Component\Input\Container\Container\withRequest().

+ Here is the call graph for this function:

Field Documentation

◆ $format_date

readonly Closure ILIAS\LegalDocuments\ConsumerToolbox\Blocks::$format_date
private

◆ $mail_contact

readonly Closure ILIAS\LegalDocuments\ConsumerToolbox\Blocks::$mail_contact
private

Definition at line 53 of file Blocks.php.

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\Blocks\__construct().


The documentation for this class was generated from the following file: