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 Settings $settings)
35 {
36 global $DIC;
37 $this->language = $DIC->language();
38 $this->field_factory = $DIC->ui()->factory()->input()->field();
39 $this->refinery = $DIC->refinery();
40 }
41
42 public function asFormSection(): Section
43 {
44 return $this->field_factory->section(
45 [$this->asFormGroup()],
46 $this->language->txt('preview')
47 );
48 }
49
50 public function asFormGroup(): Group
51 {
52 $possible = $this->settings->isPreviewPossible();
53
54 $activated = $this->field_factory
55 ->checkbox(
56 $this->language->txt('enable_preview'),
57 $this->language->txt('enable_preview_info')
58 )
59 ->withDisabled(!$possible)
60 ->withValue($this->settings->isPreviewEnabled())
61 ->withAdditionalTransformation(
62 $this->refinery->custom()->transformation(function ($v): void {
63 $this->settings->setPreviewEnabled($v);
64 })
65 );
66
67 $image_size = $this->field_factory
68 ->numeric(
69 $this->language->txt('preview_image_size'),
70 $this->language->txt('preview_image_size_info')
71 )
72 ->withDisabled(!$possible)
73 ->withRequired(true)
74 ->withValue($this->settings->getImageSize())
75 ->withAdditionalTransformation(
76 $this->refinery->custom()->transformation(function ($v): void {
77 $this->settings->setImageSize($v);
78 })
79 );
80
81 $persisting = $this->field_factory
82 ->checkbox(
83 $this->language->txt('preview_persisting'),
84 $this->language->txt('preview_persisting_info')
85 )
86 ->withDisabled(!$possible)
87 ->withValue($this->settings->isPersisting())
88 ->withAdditionalTransformation(
89 $this->refinery->custom()->transformation(function ($v): void {
90 $this->settings->setPersisting($v);
91 })
92 );
93
94 $max_previews = $this->field_factory
95 ->numeric(
96 $this->language->txt('max_previews_per_object'),
97 $this->language->txt('max_previews_per_object_info')
98 )
99 ->withDisabled(!$possible)
100 ->withValue($this->settings->getMaximumPreviews())
101 ->withAdditionalTransformation(
102 $this->refinery->custom()->transformation(function ($v): void {
103 $this->settings->setMaximumPreviews($v);
104 })
105 );
106
107 $tile_previews = $this->field_factory
108 ->checkbox(
109 $this->language->txt('previews_for_tiles'),
110 $this->language->txt('previews_for_tiles_info')
111 )
112 ->withDisabled(!$possible)
113 ->withValue($this->settings->hasTilePreviews())
114 ->withAdditionalTransformation(
115 $this->refinery->custom()->transformation(function ($v): void {
116 $this->settings->setTilePreviews($v);
117 })
118 );
119
120 return $this->field_factory->group(
121 [
122 $activated,
123 $image_size,
124 $max_previews,
125 $persisting,
126 $tile_previews
127 ]
128 );
129 }
130}
__construct(private Settings $settings)
Definition: Form.php:34
ILIAS Refinery Factory $refinery
Definition: Form.php:32
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
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