19declare(strict_types=1);
21use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
28use ILIAS\GlobalScreen\GUI\I18n\Translator;
29use Psr\Http\Message\RequestInterface;
61 protected Translator
$lng,
62 private RequestInterface $request,
74 $f = (fn(): InputFactory => $this->ui_fa->input());
76 $title =
$f()->field()->text(
$txt(
'sub_title_default'),
$txt(
'sub_title_default_byline'));
77 if (!$this->item_facade->isEmpty()) {
78 $title = $title->withValue($this->item_facade->getDefaultTitle());
83 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
85 $type =
$f()->field()->switchableGroup(
88 $txt(
'sub_type_byline')
89 )->withRequired(
true);
90 if (!$this->item_facade->isEmpty()) {
91 $string = $this->item_facade->getType() ===
'' ? Link::class : $this->item_facade->getType();
92 $type = $type->withValue($this->hash($string));
94 $type = $type->withValue($this->hash(Link::class));
100 if ($this->item_facade->supportsCustomIcon()) {
103 ->withByline(
$txt(
'sub_icon_byline'))
104 ->withAcceptedMimeTypes([MimeType::IMAGE__SVG_XML]);
105 if ($this->item_facade->getIconID() !==
null) {
106 $icon = $icon->withValue([$this->item_facade->getIconID()]);
113 $possible_parents = array_keys($this->
repository->getPossibleParentsForFormAndTable());
114 if (!$this->item_facade->isEmpty()
115 && !$this->item_facade->isInLostItem()
116 && in_array($this->item_facade->getParentIdentificationString(), $possible_parents,
true)) {
118 $parent =
$f()->field()
121 $this->
repository->getPossibleParentsForFormAndTable()
124 ->withValue($this->item_facade->getParentIdentificationString());
126 $parent =
$f()->field()
130 $this->parent_item?->identification()->serialize() ?? reset($possible_parents)
136 $active =
$f()->field()->checkbox(
$txt(
'sub_active'),
$txt(
'sub_active_byline'));
137 $active = $active->withValue($this->item_facade->isActivated());
141 if ($this->item_facade->supportsRoleBasedVisibility()) {
143 $value_role_based_visibility =
null;
144 if ($this->item_facade->hasRoleBasedVisibility() && !empty($this->item_facade->getGlobalRoleIDs())) {
146 $value_role_based_visibility[0] = array_intersect(
147 $this->item_facade->getGlobalRoleIDs(),
148 array_keys($access->getGlobalRoles())
151 $role_based_visibility =
$f()->field()->optionalGroup(
153 $f()->field()->multiSelect(
154 $txt(
'sub_global_roles'),
155 $access->getGlobalRoles()
156 )->withRequired(
false)
158 $txt(
'sub_role_based_visibility'),
159 $txt(
'sub_role_based_visibility_byline')
160 )->withValue($value_role_based_visibility);
165 if ($this->item_facade->isEmpty()) {
166 $this->
form =
$f()->container()->form()->standard(
167 $this->
ctrl->getLinkTargetByClass(
168 ilMMSubItemGUI::class,
174 $this->
form =
$f()->container()->form()->standard(
175 $this->
ctrl->getLinkTargetByClass(
176 ilMMSubItemGUI::class,
187 $this->
form = $this->
form->withRequest($this->request);
190 if (is_null(
$data)) {
195 $this->item_facade->setDefaultTitle((
string)
$data[self::F_TITLE]);
196 $this->item_facade->setActiveStatus((
bool)
$data[self::F_ACTIVE]);
197 $this->item_facade->setRoleBasedVisibility((
bool) $role_based_visibility);
199 if ($role_based_visibility) {
200 $this->item_facade->setGlobalRoleIDs((array) $role_based_visibility[0]);
202 if ((
string)
$data[self::F_PARENT] !==
'' && (
string)
$data[self::F_PARENT] !==
'0') {
203 $this->item_facade->setParent((
string)
$data[self::F_PARENT]);
205 $this->item_facade->setIsTopItm(
false);
207 if ($this->item_facade->isEmpty()) {
208 $type = $this->unhash((
string) (
$data[self::F_TYPE][0]));
209 $this->item_facade->setType($type);
210 $r->createItem($this->item_facade);
213 if ($this->item_facade->supportsCustomIcon()) {
214 $icon = (string) (
$data[self::F_ICON][0] ??
'');
215 $this->item_facade->setIconID($icon);
218 if ($this->item_facade->isCustom()) {
219 $type = $this->item_facade->getType();
220 $type_specific_data = (array)
$data[self::F_TYPE][1];
221 $type_handler = $this->
repository->getTypeHandlerForType($type);
222 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
225 $r->updateItem($this->item_facade);
235 return $this->ui_re->render([$this->
form]);
250 $type_informations = $this->
repository->getPossibleSubItemTypesWithInformation();
251 foreach ($type_informations as $classname => $information) {
252 if ($this->item_facade->isEmpty()
253 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType(
254 ) && $this->item_facade->isCustom())
256 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm(
257 $this->item_facade->identification()
259 $type_groups[$this->hash($classname)] =
$f()->field()->group(
261 $information->getTypeNameForPresentation()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Class Link Attention: This is not the same as the \ILIAS\UI\Component\Link\Link.
Class ilCtrl provides processing control methods.
Class ilMMUploadHandlerGUI.
Class ilObjMainMenuAccess.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface ilMMItemFacadeInterface.
form( $class_path, string $cmd, string $submit_caption="")
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.