3use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
77 $this->item_facade = $item;
78 if (!$this->item_facade->isEmpty()) {
87 $txt =
function ($key) {
88 return $this->lng->txt($key);
90 $f =
function () : InputFactory {
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());
103 if ($this->item_facade->supportsCustomIcon()) {
106 ->withByline(
$txt(
'topitem_icon_byline'))
108 if ($this->item_facade->getIconID() !==
null) {
109 $icon = $icon->withValue([$this->item_facade->getIconID()]);
116 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
118 $type =
$f()->field()->switchableGroup($type_groups,
$txt(
'topitem_type'),
119 $txt(
'topitem_type_byline'))->withRequired(
true);
120 if (!$this->item_facade->isEmpty()) {
121 $string = $this->item_facade->getType() ===
'' ? TopParentItem::class : $this->item_facade->getType();
122 $type =
$type->withValue($this->hash($string));
124 $type =
$type->withValue($this->hash(TopParentItem::class));
130 $active =
$f()->field()->checkbox(
$txt(
'topitem_active'),
$txt(
'topitem_active_byline'));
131 $active = $active->withValue($this->item_facade->isActivated());
135 if ($this->item_facade->isEmpty()) {
137 $this->form =
$f()->container()->form()->standard($this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class,
141 $this->form =
$f()->container()->form()->standard($this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class,
148 $this->form = $this->form->withRequest($this->
http->request());
149 $data = $this->form->getData();
150 if (is_null(
$data)) {
154 $this->item_facade->setAction((
string)
$data[0][
'action']);
155 $this->item_facade->setDefaultTitle((
string)
$data[0][self::F_TITLE]);
156 $this->item_facade->setActiveStatus((
bool)
$data[0][self::F_ACTIVE]);
157 $this->item_facade->setIsTopItm(
true);
159 if ($this->item_facade->isEmpty()) {
160 $type = $this->unhash((
string) (
$data[0][self::F_TYPE][0]));
161 $this->item_facade->setType(
$type);
162 $this->
repository->createItem($this->item_facade);
165 if ($this->item_facade->supportsCustomIcon()) {
166 $icon = (string)
$data[0][self::F_ICON][0];
167 $this->item_facade->setIconID($icon);
170 if ($this->item_facade->isCustom()) {
171 $type = $this->item_facade->getType();
172 $type_specific_data = (array)
$data[0][self::F_TYPE][1];
174 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
177 $this->
repository->updateItem($this->item_facade);
187 return $this->ui_re->render([$this->form]);
197 $type_informations = $this->
repository->getPossibleTopItemTypesWithInformation();
198 foreach ($type_informations as $classname => $information) {
199 if ($this->item_facade->isEmpty()
200 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
202 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
203 $type_groups[$this->hash($classname)] =
$f()->field()->group($inputs,
204 $information->getTypeNameForPresentation());
An exception for terminatinating execution or to throw for unit testing.
This class provides processing control methods.
Class ilMMItemRepository.
Class ilMMUploadHandlerGUI.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface ilMMItemFacadeInterface.
static http()
Fetches the global http state from ILIAS.
Class ChatMainBarProvider \MainMenu\Provider.