19 declare(strict_types=1);
83 $this->item_facade = $item;
85 if (!$this->item_facade->isEmpty()) {
97 $f =
function (): InputFactory {
98 return $this->ui_fa->input();
102 $title =
$f()->field()->text(
$txt(
'topitem_title_default'),
$txt(
'topitem_title_default_byline'))
103 ->withRequired(
true);
104 if (!$this->item_facade->isEmpty()) {
105 $title = $title->withValue($this->item_facade->getDefaultTitle());
108 $items[self::F_TITLE] = $title;
110 if ($this->item_facade->supportsCustomIcon()) {
113 ->withByline(
$txt(
'topitem_icon_byline'))
114 ->withAcceptedMimeTypes([MimeType::IMAGE__SVG_XML]);
115 if ($this->item_facade->getIconID() !== null) {
116 $icon = $icon->withValue([$this->item_facade->getIconID()]);
119 $items[self::F_ICON] = $icon;
123 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
124 $type_groups = $this->
getTypeGroups(
$f, $this->item_facade->isEmpty());
125 $type =
$f()->field()->switchableGroup(
127 $txt(
'topitem_type'),
128 $txt(
'topitem_type_byline')
129 )->withRequired(
true);
130 if (!$this->item_facade->isEmpty()) {
131 $string = $this->item_facade->getType() ===
'' ? TopParentItem::class : $this->item_facade->getType();
132 $type = $type->withValue($this->
hash($string));
134 $type = $type->withValue($this->
hash(TopParentItem::class));
136 $items[self::F_TYPE] =
$type;
140 $active =
$f()->field()->checkbox(
$txt(
'topitem_active'),
$txt(
'topitem_active_byline'));
141 $active = $active->withValue($this->item_facade->isActivated());
142 $items[self::F_ACTIVE] = $active;
145 if ($this->item_facade->supportsRoleBasedVisibility()) {
146 $value_role_based_visibility = null;
147 $global_roles = $this->
access->getGlobalRoles();
148 $global_role_ids = $this->item_facade->getGlobalRoleIDs();
149 if ($this->item_facade->hasRoleBasedVisibility() && !empty($global_role_ids)) {
151 $value_role_based_visibility[0] = array_intersect(
153 array_keys($global_roles)
156 $role_based_visibility =
$f()->field()->optionalGroup(
158 $f()->field()->multiSelect(
159 $txt(
'sub_global_roles'),
161 )->withRequired(
false)
163 $txt(
'sub_role_based_visibility'),
164 $txt(
'sub_role_based_visibility_byline')
165 )->withValue($value_role_based_visibility);
166 $items[self::F_ROLE_BASED_VISIBILITY] = $role_based_visibility;
170 if ($this->item_facade->isEmpty()) {
172 $this->
form =
$f()->container()->form()->standard($this->
ctrl->getLinkTargetByClass(
173 ilMMTopItemGUI::class,
178 $this->
form =
$f()->container()->form()->standard($this->
ctrl->getLinkTargetByClass(
179 ilMMTopItemGUI::class,
187 $this->
form = $this->
form->withRequest($this->
http->request());
189 if (is_null(
$data)) {
193 $this->item_facade->setAction((
string) (
$data[0][
'action'] ??
''));
194 $this->item_facade->setDefaultTitle((
string)
$data[0][self::F_TITLE]);
195 $this->item_facade->setActiveStatus((
bool)
$data[0][self::F_ACTIVE]);
196 if ($this->item_facade->supportsRoleBasedVisibility()) {
197 $this->item_facade->setRoleBasedVisibility((
bool)
$data[0][self::F_ROLE_BASED_VISIBILITY]);
198 if (
$data[0][self::F_ROLE_BASED_VISIBILITY] and !empty(
$data[0][self::F_ROLE_BASED_VISIBILITY])) {
199 $this->item_facade->setGlobalRoleIDs((array)
$data[0][self::F_ROLE_BASED_VISIBILITY][0]);
203 $this->item_facade->setIsTopItm(
true);
205 if ($this->item_facade->isEmpty()) {
206 $type = $this->unhash((
string) (
$data[0][self::F_TYPE][0]));
207 $this->item_facade->setType(
$type);
208 $this->
repository->createItem($this->item_facade);
211 if ($this->item_facade->supportsCustomIcon()) {
212 $icon = (string) (
$data[0][self::F_ICON][0] ??
'');
213 $this->item_facade->setIconID($icon);
216 if ($this->item_facade->isCustom()) {
217 $type = $this->item_facade->getType();
218 $type_specific_data = (array)
$data[0][self::F_TYPE][1];
220 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
223 $this->
repository->updateItem($this->item_facade);
233 return $this->ui_re->render([$this->
form]);
243 $type_informations = $this->
repository->getPossibleTopItemTypesWithInformation($new);
244 foreach ($type_informations as $classname => $information) {
245 if ($this->item_facade->isEmpty()
246 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
248 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
249 $type_groups[$this->
hash($classname)] =
$f()->field()->group(
251 $information->getTypeNameForPresentation()
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
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)
Interface ilMMItemFacadeInterface.