ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Form.php
Go to the documentation of this file.
1<?php
2
20
24
28class Form
29{
30 private \ilLanguage $language;
32 private \ILIAS\Refinery\Factory $refinery;
33
34 public function __construct(private General $settings)
35 {
36 global $DIC;
37 $this->language = $DIC->language();
38 $this->language->loadLanguageModule("bgtask");
39 $this->field_factory = $DIC->ui()->factory()->input()->field();
40 $this->refinery = $DIC->refinery();
41 }
42
43 public function asFormSection(): Section
44 {
45 return $this->field_factory->section(
46 [$this->asFormGroup()],
47 $this->language->txt('obj_file')
48 );
49 }
50
51 public function asFormGroup(): Group
52 {
53 $download_limit = $this->field_factory
54 ->numeric(
55 $this->language->txt('bgtask_setting_limit'),
56 $this->language->txt('bgtask_setting_limit_info')
57 )
58 ->withValue($this->settings->getDownloadLimitinMB())
59 ->withRequired(true)
60 ->withAdditionalTransformation(
61 $this->refinery->custom()->transformation(function ($value): void {
62 $this->settings->setDownloadLimitInMB($value);
63 })
64 );
65
66 $inline_file_extensions = $this->field_factory
67 ->tag(
68 $this->language->txt('inline_file_extensions'),
69 [],
70 $this->language->txt('inline_file_extensions_info')
71 )
72 ->withValue($this->settings->getInlineFileExtensions())
73 ->withAdditionalTransformation(
74 $this->refinery->custom()->transformation(function ($value): void {
75 $this->settings->setInlineFileExtensions($value);
76 })
77 );
78
79 $show_amount_of_downloads = $this->field_factory
80 ->checkbox(
81 $this->language->txt('show_amount_of_downloads'),
82 $this->language->txt('show_amount_of_downloads_info')
83 )
84 ->withValue($this->settings->isShowAmountOfDownloads())
85 ->withAdditionalTransformation(
86 $this->refinery->custom()->transformation(
87 function ($value): void {
88 $this->settings->setShowAmountOfDownloads($value);
89 }
90 )
91 );
92
93 $ascii_filename = $this->field_factory
94 ->checkbox(
95 $this->language->txt('download_ascii_filename'),
96 $this->language->txt('download_ascii_filename_info')
97 )
98 ->withValue($this->settings->isDownloadWithAsciiFileName())
99 ->withAdditionalTransformation(
100 $this->refinery->custom()->transformation(function ($value): void {
101 $this->settings->setDownloadWithAsciiFileName($value);
102 })
103 );
104
105 return $this->field_factory->group(
106 [
107 $ascii_filename,
108 $download_limit,
109 $inline_file_extensions,
110 $show_amount_of_downloads,
111 ]
112 );
113 }
114}
ILIAS Refinery Factory $refinery
Definition: Form.php:32
__construct(private General $settings)
Definition: Form.php:34
This is what a factory for input fields looks like.
Definition: Factory.php:31
Describes the monoid operation of grouping form inputs.
Definition: Group.php:32
This describes section inputs.
Definition: Section.php:29
withValue($value)
Get an input like this with another value displayed on the client side.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Form.php:19
global $DIC
Definition: shib_login.php:26