3use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
68 $this->item_facade = $item;
70 if (!$this->item_facade->isEmpty()) {
80 $txt =
function ($id) :
string {
81 return $this->lng->txt($id);
83 $f =
function () : InputFactory {
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());
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();
99 $type =
$type->withValue($this->hash($string));
101 $type =
$type->withValue($this->hash(Link::class));
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()]);
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));
132 $active =
$f()->field()->checkbox(
$txt(
'sub_active'),
$txt(
'sub_active_byline'));
133 $active = $active->withValue($this->item_facade->isActivated());
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);
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 exception for terminatinating execution or to throw for unit testing.
Class Link Attention: This is not the same as the \ILIAS\UI\Component\Link\Link.
This class provides processing control methods.
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface ilMMItemFacadeInterface.