3 declare(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" =>
""]];
46 protected string $cmd = self::DEFAULT_SECTION;
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);
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);
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);
138 string $id_parameter,
139 string $description =
"",
141 array $mime_types = [],
142 bool $required =
false 144 $this->upload_handler[
$key] = new \ilRepoStandardUploadHandlerGUI(
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);
201 if (is_null($this->
form)) {
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()
form( $class_path, string $cmd)
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
Returns a link target for the given information.