3declare(strict_types=1);
32 protected \ilLanguage
$lng;
38 protected \ILIAS\HTTP\Services
$http;
39 protected \ilCtrlInterface
$ctrl;
40 protected \ILIAS\DI\UIServices
$ui;
42 protected array
$sections = [self::DEFAULT_SECTION => [
"title" =>
"",
"description" =>
""]];
47 protected ?Form\Standard
$form =
null;
60 $this->
ui = $DIC->ui();
61 $this->
ctrl = $DIC->ctrl();
62 $this->
http = $DIC->http();
63 $this->
lng = $DIC->language();
74 string $description =
""
76 if ($this->title ==
"") {
80 $this->sections[
$key] = [
82 "description" => $description
84 $this->current_section =
$key;
91 string $description =
"",
94 $field = $this->
ui->factory()->input()->field()->text($title, $description);
95 if (!is_null($value)) {
96 $field = $field->withValue($value);
98 $this->addField(
$key, $field);
105 string $description =
"",
106 ?
string $value =
null
108 $field = $this->
ui->factory()->input()->field()->textarea($title, $description);
109 if (!is_null($value)) {
110 $field = $field->withValue($value);
112 $this->addField(
$key, $field);
120 string $description =
"",
121 ?
string $value =
null
123 $field = $this->
ui->factory()->input()->field()->select($title, $options, $description);
124 if (!is_null($value)) {
125 $field = $field->withValue($value);
137 \Closure $result_handler,
138 string $id_parameter,
139 string $description =
"",
141 array $mime_types = [],
142 bool $required =
false
149 if (count($mime_types) > 0) {
150 $description.= $this->
lng->txt(
"rep_allowed_types") .
": " .
151 implode(
", ", $mime_types);
154 $field = $this->
ui->factory()->input()->field()->file(
155 $this->upload_handler[
$key],
160 ->withMaxFiles($max_files);
161 if (count($mime_types) > 0) {
162 $field = $field->withAcceptedMimeTypes($mime_types);
165 $field = $field->withRequired(
true);
177 if (!isset($this->upload_handler[
$key])) {
178 throw new \ilException(
"Unknown file upload field: " .
$key);
180 return $this->upload_handler[
$key];
186 if (isset($this->section_of_field[
$key])) {
187 throw new \ilException(
"Duplicate Input Key: " .
$key);
190 throw new \ilException(
"Missing Input Key: " .
$key);
192 $this->section_of_field[
$key] = $this->current_section;
193 $this->
fields[$this->current_section][
$key] = $field;
201 if (is_null($this->
form)) {
202 $action = $ctrl->getLinkTargetByClass($this->class_path, $this->cmd);
204 foreach ($this->sections as $sec_key => $section) {
205 if ($sec_key === self::DEFAULT_SECTION) {
206 if (isset($this->
fields[$sec_key])) {
207 foreach ($this->
fields[$sec_key] as $f_key => $field) {
212 if (isset($this->
fields[$sec_key]) && count($this->
fields[$sec_key]) > 0) {
213 $inputs[$sec_key] = $this->
ui->factory()->input()->field()->section(
216 $section[
"description"]
221 $this->
form = $this->
ui->factory()->input()->container()->form()->standard(
234 if (is_null($this->raw_data)) {
235 $request = $this->
http->request();
236 $this->raw_data = $this->getForm()->withRequest($request)->getData();
239 if (!isset($this->section_of_field[
$key])) {
240 throw new \ilException(
"Unknown Key: " .
$key);
243 $section_data = ($this->section_of_field[
$key] === self::DEFAULT_SECTION)
245 : $this->raw_data[$this->section_of_field[
$key]] ??
null;
247 if (!isset($section_data[
$key])) {
250 return $section_data[
$key];
255 return $this->
ui->renderer()->render($this->getForm());
260 if (is_null($this->raw_data)) {
261 $request = $this->
http->request();
262 $this->
form = $this->getForm()->withRequest($request);
263 $this->raw_data = $this->
form->getData();
270 return !(is_null($this->raw_data));
static getUploadSizeLimitBytes()
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
form( $class_path, string $cmd)