68 $this->item_facade = $item;
70 if (!$this->item_facade->isEmpty()) {
80 $txt =
function ($id) :
string {
81 return $this->lng->txt($id);
84 return $this->ui_fa->input();
87 $title =
$f()->field()->text(
$txt(
'sub_title_default'),
$txt(
'sub_title_default_byline'));
88 if (!$this->item_facade->isEmpty()) {
89 $title = $title->withValue($this->item_facade->getDefaultTitle());
91 $items[self::F_TITLE] = $title;
94 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
96 $type =
$f()->field()->switchableGroup($type_groups,
$txt(
'sub_type'),
$txt(
'sub_type_byline'))->withRequired(
true);
97 if (!$this->item_facade->isEmpty()) {
98 $string = $this->item_facade->getType() ===
'' ? Link::class : $this->item_facade->getType();
103 $items[self::F_TYPE] =
$type;
107 if ($this->item_facade->supportsCustomIcon()) {
110 ->withByline(
$txt(
'sub_icon_byline'))
113 if ($this->item_facade->getIconID() !== null) {
114 $icon = $icon->withValue([$this->item_facade->getIconID()]);
117 $items[self::F_ICON] = $icon;
121 $parent =
$f()->field()->select(
$txt(
'sub_parent'), $this->
repository->getPossibleParentsForFormAndTable())
122 ->withRequired(
true);
123 if (!$this->item_facade->isEmpty() && !$this->item_facade->isInLostItem()) {
124 $parent = $parent->withValue($this->item_facade->getParentIdentificationString());
126 $array = array_keys($this->
repository->getPossibleParentsForFormAndTable());
127 $parent = $parent->withValue(reset($array));
129 $items[self::F_PARENT] = $parent;
132 $active =
$f()->field()->checkbox(
$txt(
'sub_active'),
$txt(
'sub_active_byline'));
133 $active = $active->withValue($this->item_facade->isActivated());
134 $items[self::F_ACTIVE] = $active;
137 if($this->item_facade->supportsRoleBasedVisibility()) {
139 $value_role_based_visibility = NULL;
140 $global_roles = $access->getGlobalRoles();
141 $global_role_ids = $this->item_facade->getGlobalRoleIDs();
142 if($this->item_facade->hasRoleBasedVisibility() && !empty($global_role_ids)) {
144 $value_role_based_visibility[0] = array_intersect(
146 array_keys($global_roles)
149 $role_based_visibility =
$f()->field()->optionalGroup(
151 $f()->field()->multiSelect(
152 $txt(
'sub_global_roles'),
154 )->withRequired(
true)
156 $txt(
'sub_role_based_visibility'),
157 $txt(
'sub_role_based_visibility_byline')
158 )->withValue($value_role_based_visibility);
159 $items[self::F_ROLE_BASED_VISIBILITY] = $role_based_visibility;
163 if ($this->item_facade->isEmpty()) {
165 $this->form =
$f()->container()->form()
169 $this->form =
$f()->container()->form()
178 $this->form = $this->form->withRequest($DIC->http()->request());
179 $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 $this->item_facade->setRoleBasedVisibility((
bool) $data[0][self::F_ROLE_BASED_VISIBILITY]);
189 if((
bool) $data[0][self::F_ROLE_BASED_VISIBILITY] AND (
bool) !empty($data[0][self::F_ROLE_BASED_VISIBILITY])) {
190 $this->item_facade->setGlobalRoleIDs((array) $data[0][self::F_ROLE_BASED_VISIBILITY][0]);
192 if ((
string) $data[0][self::F_PARENT]) {
193 $this->item_facade->setParent((
string) $data[0][self::F_PARENT]);
195 $this->item_facade->setIsTopItm(
false);
197 if ($this->item_facade->isEmpty()) {
198 $type = $this->unhash((
string) ($data[0][self::F_TYPE][0]));
199 $this->item_facade->setType(
$type);
200 $r->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 $r->updateItem($this->item_facade);
222 return $this->ui_re->render([$this->form]);
232 $type_informations = $this->
repository->getPossibleSubItemTypesWithInformation();
233 foreach ($type_informations as $classname => $information) {
234 if ($this->item_facade->isEmpty()
235 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
237 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
238 $type_groups[$this->
hash($classname)] =
$f()->field()->group($inputs, $information->getTypeNameForPresentation());
An entity that renders components to a string output.
This class provides processing control methods.
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
This is how the factory for UI elements looks.
Interface ilMMItemFacadeInterface.