19 declare(strict_types=1);
67 if (!$this->item_facade->isEmpty()) {
76 $txt = (fn($key):
string => $this->
lng->txt($key));
80 $title =
$f()->field()->text(
$txt(
'topitem_title_default'),
$txt(
'topitem_title_default_byline'))
82 if (!$this->item_facade->isEmpty()) {
83 $title = $title->withValue($this->item_facade->getDefaultTitle());
86 $items[self::F_TITLE] = $title;
88 if ($this->item_facade->supportsCustomIcon()) {
91 ->withByline(
$txt(
'topitem_icon_byline'))
92 ->withAcceptedMimeTypes([MimeType::IMAGE__SVG_XML]);
93 if ($this->item_facade->getIconID() !==
null) {
94 $icon = $icon->withValue([$this->item_facade->getIconID()]);
97 $items[self::F_ICON] = $icon;
101 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
102 $type_groups = $this->
getTypeGroups(
$f, $this->item_facade->isEmpty());
103 $type =
$f()->field()->switchableGroup(
105 $txt(
'topitem_type'),
106 $txt(
'topitem_type_byline')
107 )->withRequired(
true);
108 if (!$this->item_facade->isEmpty()) {
109 $string = $this->item_facade->getType() ===
'' ? TopParentItem::class : $this->item_facade->getType();
110 $type = $type->withValue($this->
hash($string));
112 $type = $type->withValue($this->
hash(TopParentItem::class));
114 $items[self::F_TYPE] = $type;
118 $active =
$f()->field()->checkbox(
$txt(
'topitem_active'),
$txt(
'topitem_active_byline'));
119 $active = $active->withValue($this->item_facade->isActivated());
120 $items[self::F_ACTIVE] = $active;
123 if ($this->item_facade->supportsRoleBasedVisibility()) {
124 $value_role_based_visibility =
null;
125 $global_roles = $this->
access->getGlobalRoles();
126 $global_role_ids = $this->item_facade->getGlobalRoleIDs();
127 if ($this->item_facade->hasRoleBasedVisibility() && !empty($global_role_ids)) {
129 $value_role_based_visibility[0] = array_intersect(
131 array_keys($global_roles)
134 $role_based_visibility =
$f()->field()->optionalGroup(
136 $f()->field()->multiSelect(
137 $txt(
'sub_global_roles'),
139 )->withRequired(
false)
141 $txt(
'sub_role_based_visibility'),
142 $txt(
'sub_role_based_visibility_byline')
143 )->withValue($value_role_based_visibility);
144 $items[self::F_ROLE_BASED_VISIBILITY] = $role_based_visibility;
148 if ($this->item_facade->isEmpty()) {
150 $this->
form =
$f()->container()->form()->standard($this->
ctrl->getLinkTargetByClass(
151 ilMMTopItemGUI::class,
156 $this->
form =
$f()->container()->form()->standard($this->
ctrl->getLinkTargetByClass(
157 ilMMTopItemGUI::class,
165 $this->
form = $this->
form->withRequest($this->
http->request());
167 if (is_null(
$data)) {
171 $this->item_facade->setAction((
string) (
$data[0][
'action'] ??
''));
172 $this->item_facade->setDefaultTitle((
string)
$data[0][self::F_TITLE]);
173 $this->item_facade->setActiveStatus((
bool)
$data[0][self::F_ACTIVE]);
174 if ($this->item_facade->supportsRoleBasedVisibility()) {
175 $this->item_facade->setRoleBasedVisibility((
bool)
$data[0][self::F_ROLE_BASED_VISIBILITY]);
176 if (
$data[0][self::F_ROLE_BASED_VISIBILITY] && !empty(
$data[0][self::F_ROLE_BASED_VISIBILITY])) {
177 $this->item_facade->setGlobalRoleIDs((array)
$data[0][self::F_ROLE_BASED_VISIBILITY][0]);
181 $this->item_facade->setIsTopItm(
true);
183 if ($this->item_facade->isEmpty()) {
184 $type = $this->unhash((
string) (
$data[0][self::F_TYPE][0]));
185 $this->item_facade->setType($type);
186 $this->
repository->createItem($this->item_facade);
189 if ($this->item_facade->supportsCustomIcon()) {
190 $icon = (string) (
$data[0][self::F_ICON][0] ??
'');
191 $this->item_facade->setIconID($icon);
194 if ($this->item_facade->isCustom()) {
195 $type = $this->item_facade->getType();
196 $type_specific_data = (array)
$data[0][self::F_TYPE][1];
197 $type_handler = $this->
repository->getTypeHandlerForType($type);
198 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
201 $this->
repository->updateItem($this->item_facade);
211 return $this->ui_re->render([$this->
form]);
221 $type_informations = $this->
repository->getPossibleTopItemTypesWithInformation($new);
222 foreach ($type_informations as $classname => $information) {
223 if ($this->item_facade->isEmpty()
224 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
226 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
227 $type_groups[$this->
hash($classname)] =
$f()->field()->group(
229 $information->getTypeNameForPresentation()
Interface Observer Contains several chained tasks and infos about them.
repository()
description: > Example for rendering a repository card
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
This is how the factory for UI elements looks.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
form( $class_path, string $cmd, string $submit_caption="")
Interface ilMMItemFacadeInterface.