19declare(strict_types=1);
21use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
79 $this->item_facade = $item;
81 if (!$this->item_facade->isEmpty()) {
92 return $this->
lng->txt(
$id);
94 $f =
function (): InputFactory {
95 return $this->ui_fa->input();
98 $title =
$f()->field()->text(
$txt(
'sub_title_default'),
$txt(
'sub_title_default_byline'));
99 if (!$this->item_facade->isEmpty()) {
100 $title = $title->withValue($this->item_facade->getDefaultTitle());
105 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
107 $type =
$f()->field()->switchableGroup($type_groups,
$txt(
'sub_type'),
$txt(
'sub_type_byline'))->withRequired(
true);
108 if (!$this->item_facade->isEmpty()) {
109 $string = $this->item_facade->getType() ===
'' ? Link::class : $this->item_facade->getType();
110 $type =
$type->withValue($this->hash($string));
112 $type =
$type->withValue($this->hash(Link::class));
118 if ($this->item_facade->supportsCustomIcon()) {
121 ->withByline(
$txt(
'sub_icon_byline'))
122 ->withAcceptedMimeTypes([MimeType::IMAGE__SVG_XML]);
123 if ($this->item_facade->getIconID() !==
null) {
124 $icon = $icon->withValue([$this->item_facade->getIconID()]);
131 $parent =
$f()->field()->select(
$txt(
'sub_parent'), $this->
repository->getPossibleParentsForFormAndTable())
132 ->withRequired(
true);
134 $possible_parents = array_keys($this->
repository->getPossibleParentsForFormAndTable());
136 if (!$this->item_facade->isEmpty() && !$this->item_facade->isInLostItem() && in_array($this->item_facade->getParentIdentificationString(), $possible_parents)) {
137 $parent = $parent->withValue($this->item_facade->getParentIdentificationString());
139 $parent = $parent->withValue(reset($possible_parents));
144 $active =
$f()->field()->checkbox(
$txt(
'sub_active'),
$txt(
'sub_active_byline'));
145 $active = $active->withValue($this->item_facade->isActivated());
149 if ($this->item_facade->supportsRoleBasedVisibility()) {
151 $value_role_based_visibility =
null;
152 if ($this->item_facade->hasRoleBasedVisibility() && !empty($this->item_facade->getGlobalRoleIDs())) {
154 $value_role_based_visibility[0] = array_intersect(
155 $this->item_facade->getGlobalRoleIDs(),
156 array_keys($access->getGlobalRoles())
159 $role_based_visibility =
$f()->field()->optionalGroup(
161 $f()->field()->multiSelect(
162 $txt(
'sub_global_roles'),
163 $access->getGlobalRoles()
164 )->withRequired(
false)
166 $txt(
'sub_role_based_visibility'),
167 $txt(
'sub_role_based_visibility_byline')
168 )->withValue($value_role_based_visibility);
173 if ($this->item_facade->isEmpty()) {
175 $this->
form =
$f()->container()->form()
179 $this->
form =
$f()->container()->form()
188 $this->
form = $this->
form->withRequest($DIC->http()->request());
191 if (is_null(
$data)) {
196 $this->item_facade->setDefaultTitle((
string)
$data[0][self::F_TITLE]);
197 $this->item_facade->setActiveStatus((
bool)
$data[0][self::F_ACTIVE]);
198 $this->item_facade->setRoleBasedVisibility((
bool) $role_based_visibility);
200 if ($role_based_visibility) {
201 $this->item_facade->setGlobalRoleIDs((array) $role_based_visibility[0]);
203 if ((
string)
$data[0][self::F_PARENT]) {
204 $this->item_facade->setParent((
string)
$data[0][self::F_PARENT]);
206 $this->item_facade->setIsTopItm(
false);
208 if ($this->item_facade->isEmpty()) {
209 $type = $this->unhash((
string) (
$data[0][self::F_TYPE][0]));
210 $this->item_facade->setType(
$type);
211 $r->createItem($this->item_facade);
214 if ($this->item_facade->supportsCustomIcon()) {
215 $icon = (string) (
$data[0][self::F_ICON][0] ??
'');
216 $this->item_facade->setIconID($icon);
219 if ($this->item_facade->isCustom()) {
220 $type = $this->item_facade->getType();
221 $type_specific_data = (array)
$data[0][self::F_TYPE][1];
223 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
226 $r->updateItem($this->item_facade);
233 return $this->ui_re->render([$this->
form]);
243 $type_informations = $this->
repository->getPossibleSubItemTypesWithInformation();
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(
$inputs, $information->getTypeNameForPresentation());
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class Link Attention: This is not the same as the \ILIAS\UI\Component\Link\Link.
Class ilCtrl provides processing control methods.
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
Class ilObjMainMenuAccess.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface ilMMItemFacadeInterface.
form( $class_path, string $cmd)