69 $this->item_facade = $item;
70 if (!$this->item_facade->isEmpty()) {
81 return $this->lng->txt(
$key);
83 $f =
function () : InputFactory {
84 return $this->ui_fa->input();
88 $title =
$f()->field()->text(
$txt(
'topitem_title_default'),
$txt(
'topitem_title_default_byline'))
90 if (!$this->item_facade->isEmpty()) {
91 $title =
$title->withValue($this->item_facade->getDefaultTitle());
94 $items[self::F_TITLE] =
$title;
97 $type =
$f()->field()->radio(
$txt(
'topitem_type'),
$txt(
'topitem_type_byline'))->withRequired(
true);
98 $type_informations = $this->
repository->getPossibleTopItemTypesWithInformation();
101 foreach ($type_informations as $classname => $information) {
102 if ($this->item_facade->isEmpty()
103 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
105 $inputs = $this->
repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
106 $type =
$type->withOption($this->
hash($classname), $information->getTypeNameForPresentation(), $information->getTypeBylineForPresentation(), $inputs);
111 if (!$this->item_facade->isEmpty() && $this->item_facade->isCustom()) {
112 $type =
$type->withValue($this->
hash($this->item_facade->getType()));
113 } elseif ($this->item_facade->isCustom()) {
114 $type =
$type->withValue($this->
hash(reset(array_keys($type_informations))));
117 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom()) && $type_i > 0) {
118 $items[self::F_TYPE] =
$type;
122 $active =
$f()->field()->checkbox(
$txt(
'topitem_active'),
$txt(
'topitem_active_byline'));
123 if (!$this->item_facade->isEmpty()) {
124 $active = $active->withValue($this->item_facade->isAvailable());
126 $items[self::F_ACTIVE] = $active;
129 if ($this->item_facade->isEmpty()) {
141 $this->form = $this->form->withRequest($this->
http->request());
142 $data = $this->form->getData();
143 if (is_null(
$data)) {
147 $this->item_facade->setAction((
string)
$data[0][
'action']);
148 $this->item_facade->setDefaultTitle((
string) $data[0][self::F_TITLE]);
149 $this->item_facade->setActiveStatus((
bool) $data[0][self::F_ACTIVE]);
150 $this->item_facade->setIsTopItm(
true);
152 if ($this->item_facade->isEmpty()) {
153 $type = $this->unhash((
string) ($data[0][self::F_TYPE][
'value']));
154 $this->item_facade->setType(
$type);
155 $this->
repository->createItem($this->item_facade);
158 if ($this->item_facade->isCustom()) {
159 $type = $this->item_facade->getType();
160 $type_specific_data = (array) $data[0][self::F_TYPE][
'group_values'];
162 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
165 $this->
repository->updateItem($this->item_facade);
176 return $this->ui_re->render([$this->form]);
An entity that renders components to a string output.
This class provides processing control methods.
Class ilMMItemRepository.
static http()
Fetches the global http state from ILIAS.
This is how the factory for UI elements looks.
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Interface ilMMItemFacadeInterface.