77 $this->item_facade = $item;
78 if (!$this->item_facade->isEmpty()) {
87 $txt =
function ($key) {
88 return $this->lng->txt($key);
91 return $this->ui_fa->input();
95 $title =
$f()->field()->text(
$txt(
'topitem_title_default'),
$txt(
'topitem_title_default_byline'))
97 if (!$this->item_facade->isEmpty()) {
98 $title = $title->withValue($this->item_facade->getDefaultTitle());
101 $items[self::F_TITLE] = $title;
103 if ($this->item_facade->supportsCustomIcon()) {
106 ->withByline(
$txt(
'topitem_icon_byline'))
110 if ($this->item_facade->getIconID() !== null) {
111 $icon = $icon->withValue([$this->item_facade->getIconID()]);
114 $items[self::F_ICON] = $icon;
118 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
119 $type_groups = $this->
getTypeGroups(
$f, $this->item_facade->isEmpty());
120 $type =
$f()->field()->switchableGroup(
122 $txt(
'topitem_type'),
123 $txt(
'topitem_type_byline')
124 )->withRequired(
true);
125 if (!$this->item_facade->isEmpty()) {
126 $string = $this->item_facade->getType() ===
'' ? TopParentItem::class : $this->item_facade->getType();
127 $type = $type->withValue($this->
hash($string));
129 $type = $type->withValue($this->
hash(TopParentItem::class));
131 $items[self::F_TYPE] =
$type;
135 $active =
$f()->field()->checkbox(
$txt(
'topitem_active'),
$txt(
'topitem_active_byline'));
136 $active = $active->withValue($this->item_facade->isActivated());
137 $items[self::F_ACTIVE] = $active;
140 if ($this->item_facade->supportsRoleBasedVisibility()) {
142 $value_role_based_visibility = NULL;
143 $global_roles = $access->getGlobalRoles();
144 $global_role_ids = $this->item_facade->getGlobalRoleIDs();
145 if($this->item_facade->hasRoleBasedVisibility() && !empty($global_role_ids)) {
147 $value_role_based_visibility[0] = array_intersect(
149 array_keys($global_roles)
152 $role_based_visibility =
$f()->field()->optionalGroup(
154 $f()->field()->multiSelect(
155 $txt(
'sub_global_roles'),
157 )->withRequired(
true)
159 $txt(
'sub_role_based_visibility'),
160 $txt(
'sub_role_based_visibility_byline')
161 )->withValue($value_role_based_visibility);
162 $items[self::F_ROLE_BASED_VISIBILITY] = $role_based_visibility;
166 if ($this->item_facade->isEmpty()) {
168 $this->form =
$f()->container()->form()->standard($this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class,
172 $this->form =
$f()->container()->form()->standard($this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class,
179 $this->form = $this->form->withRequest($this->
http->request());
180 $data = $this->form->getData();
181 if (is_null(
$data)) {
185 $this->item_facade->setAction((
string)
$data[0][
'action']);
186 $this->item_facade->setDefaultTitle((
string) $data[0][self::F_TITLE]);
187 $this->item_facade->setActiveStatus((
bool) $data[0][self::F_ACTIVE]);
188 if ($this->item_facade->supportsRoleBasedVisibility()) {
189 $this->item_facade->setRoleBasedVisibility((
bool) $data[0][self::F_ROLE_BASED_VISIBILITY]);
190 if ((
bool) $data[0][self::F_ROLE_BASED_VISIBILITY] and (
bool) !empty($data[0][self::F_ROLE_BASED_VISIBILITY])) {
191 $this->item_facade->setGlobalRoleIDs((array) $data[0][self::F_ROLE_BASED_VISIBILITY][0]);
195 $this->item_facade->setIsTopItm(
true);
197 if ($this->item_facade->isEmpty()) {
198 $type = $this->unhash((
string) ($data[0][self::F_TYPE][0]));
199 $this->item_facade->setType(
$type);
200 $this->
repository->createItem($this->item_facade);
203 if ($this->item_facade->supportsCustomIcon()) {
204 $icon = (string) $data[0][self::F_ICON][0];
205 $this->item_facade->setIconID($icon);
208 if ($this->item_facade->isCustom()) {
209 $type = $this->item_facade->getType();
210 $type_specific_data = (array) $data[0][self::F_TYPE][1];
212 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
215 $this->
repository->updateItem($this->item_facade);
225 return $this->ui_re->render([$this->form]);
235 $type_informations = $this->
repository->getPossibleTopItemTypesWithInformation($new);
236 foreach ($type_informations as $classname => $information) {
237 if ($this->item_facade->isEmpty()
238 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
240 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
241 $type_groups[$this->
hash($classname)] =
$f()->field()->group($inputs,
242 $information->getTypeNameForPresentation());
An entity that renders components to a string output.
This class provides processing control methods.
Class ChatMainBarProvider .
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
static http()
Fetches the global http state from ILIAS.
This is how the factory for UI elements looks.
Interface ilMMItemFacadeInterface.