ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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) {
62 $this->settings->setDownloadLimitInMB($value);
63 return $value;
64 })
65 );
66
67 $inline_file_extensions = $this->field_factory
68 ->tag(
69 $this->language->txt('inline_file_extensions'),
70 [],
71 $this->language->txt('inline_file_extensions_info')
72 )
73 ->withValue($this->settings->getInlineFileExtensions())
74 ->withAdditionalTransformation(
75 $this->refinery->custom()->transformation(function ($value) {
76 $this->settings->setInlineFileExtensions($value);
77 return $value;
78 })
79 );
80
81 $show_amount_of_downloads = $this->field_factory
82 ->checkbox(
83 $this->language->txt('show_amount_of_downloads'),
84 $this->language->txt('show_amount_of_downloads_info')
85 )
86 ->withValue($this->settings->isShowAmountOfDownloads())
87 ->withAdditionalTransformation(
88 $this->refinery->custom()->transformation(
89 function ($value) {
90 $this->settings->setShowAmountOfDownloads($value);
91 return $value;
92 }
93 )
94 );
95
96 $ascii_filename = $this->field_factory
97 ->checkbox(
98 $this->language->txt('download_ascii_filename'),
99 $this->language->txt('download_ascii_filename_info')
100 )
101 ->withValue($this->settings->isDownloadWithAsciiFileName())
102 ->withAdditionalTransformation(
103 $this->refinery->custom()->transformation(function ($value) {
104 $this->settings->setDownloadWithAsciiFileName($value);
105 return $value;
106 })
107 );
108
109 return $this->field_factory->group(
110 [
111 $ascii_filename,
112 $download_limit,
113 $inline_file_extensions,
114 $show_amount_of_downloads,
115 ]
116 );
117 }
118}
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