ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilMMSubitemFormGUI Class Reference

Class ilMMSubitemFormGUI. More...

+ Collaboration diagram for ilMMSubitemFormGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, Factory $ui_fa, Renderer $ui_re, ilLanguage $lng, ilMMItemFacadeInterface $item, ilMMItemRepository $repository)
 ilMMSubitemFormGUI constructor. More...
 
 save ()
 
 getHTML ()
 

Data Fields

const F_TITLE = "title"
 
const F_TYPE = "type"
 
const F_PARENT = "parent"
 
const F_ACTIVE = "active"
 
const F_ICON = "icon"
 

Protected Attributes

 $lng
 
 $ctrl
 
 $ui_fa
 
 $ui_re
 

Private Member Functions

 initForm ()
 
 getTypeGroups (Closure $f)
 

Private Attributes

 $repository
 
 $form
 
 $item_facade
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMSubitemFormGUI::__construct ( ilCtrl  $ctrl,
Factory  $ui_fa,
Renderer  $ui_re,
ilLanguage  $lng,
ilMMItemFacadeInterface  $item,
ilMMItemRepository  $repository 
)

ilMMSubitemFormGUI constructor.

Parameters
ilCtrl$ctrl
Factory$ui_fa
Renderer$ui_re
ilLanguage$lng
ilMMItemFacadeInterface$item
ilMMItemRepository$repository

Definition at line 61 of file class.ilMMSubitemFormGUI.php.

62 {
63 $this->ctrl = $ctrl;
64 $this->ui_fa = $ui_fa;
65 $this->ui_re = $ui_re;
66 $this->lng = $lng;
67 $this->item_facade = $item;
68 $this->repository = $repository;
69 if (!$this->item_facade->isEmpty()) {
70 $this->ctrl->saveParameterByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::IDENTIFIER);
71 }
72
73 $this->initForm();
74 }
repository()
Definition: repository.php:5

References $ctrl, $lng, $repository, $ui_fa, $ui_re, ilMMAbstractItemGUI\IDENTIFIER, initForm(), and repository().

+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilMMSubitemFormGUI::getHTML ( )

Definition at line 188 of file class.ilMMSubitemFormGUI.php.

189 {
190 return $this->ui_re->render([$this->form]);
191 }

◆ getTypeGroups()

ilMMSubitemFormGUI::getTypeGroups ( Closure  $f)
private
Parameters
Closure$f
Returns
array

Definition at line 197 of file class.ilMMSubitemFormGUI.php.

197 : array
198 {
199 $type_groups = [];
200 $type_informations = $this->repository->getPossibleSubItemTypesWithInformation();
201 foreach ($type_informations as $classname => $information) {
202 if ($this->item_facade->isEmpty()
203 || (!$this->item_facade->isEmpty() && $classname === $this->item_facade->getType() && $this->item_facade->isCustom())
204 ) { // https://mantis.ilias.de/view.php?id=24152
205 $inputs = $this->repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
206 $type_groups[$this->hash($classname)] = $f()->field()->group($inputs, $information->getTypeNameForPresentation());
207 }
208 }
209
210 return $type_groups;
211 }

References Vendor\Package\$f, and repository().

Referenced by initForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilMMSubitemFormGUI::initForm ( )
private

Definition at line 76 of file class.ilMMSubitemFormGUI.php.

76 : void
77 {
78 // TITLE
79 $txt = function ($id) : string {
80 return $this->lng->txt($id);
81 };
82 $f = function () : InputFactory {
83 return $this->ui_fa->input();
84 };
85
86 $title = $f()->field()->text($txt('sub_title_default'), $txt('sub_title_default_byline'));
87 if (!$this->item_facade->isEmpty()) {
88 $title = $title->withValue($this->item_facade->getDefaultTitle());
89 }
90 $items[self::F_TITLE] = $title;
91
92 // TYPE
93 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
94 $type_groups = $this->getTypeGroups($f);
95 $type = $f()->field()->switchableGroup($type_groups, $txt('sub_type'), $txt('sub_type_byline'))->withRequired(true);
96 if (!$this->item_facade->isEmpty()) {
97 $string = $this->item_facade->getType() === '' ? Link::class : $this->item_facade->getType();
98 $type = $type->withValue($this->hash($string));
99 } else {
100 $type = $type->withValue($this->hash(Link::class));
101 }
102 $items[self::F_TYPE] = $type;
103 }
104
105 // ICON
106 if ($this->item_facade->supportsCustomIcon()) {
107 // ICON
108 $icon = $f()->field()->file(new ilMMUploadHandlerGUI(), $txt('sub_icon'))
109 ->withByline($txt('sub_icon_byline'))
110 ->withAcceptedMimeTypes([ilMimeTypeUtil::IMAGE__SVG_XML]);
111 if ($this->item_facade->getIconID() !== null) {
112 $icon = $icon->withValue([$this->item_facade->getIconID()]);
113 }
114
115 $items[self::F_ICON] = $icon;
116 }
117
118 // PARENT
119 $parent = $f()->field()->select($txt('sub_parent'), $this->repository->getPossibleParentsForFormAndTable())
120 ->withRequired(true);
121 if (!$this->item_facade->isEmpty() && !$this->item_facade->isInLostItem()) {
122 $parent = $parent->withValue($this->item_facade->getParentIdentificationString());
123 } else {
124 $array = array_keys($this->repository->getPossibleParentsForFormAndTable());
125 $parent = $parent->withValue(reset($array));
126 }
127 $items[self::F_PARENT] = $parent;
128
129 // ACTIVE
130 $active = $f()->field()->checkbox($txt('sub_active'), $txt('sub_active_byline'));
131 $active = $active->withValue($this->item_facade->isActivated());
132 $items[self::F_ACTIVE] = $active;
133
134 // RETURN FORM
135 if ($this->item_facade->isEmpty()) {
136 $section = $f()->field()->section($items, $txt(ilMMSubItemGUI::CMD_ADD), "");
137 $this->form = $f()->container()->form()
138 ->standard($this->ctrl->getLinkTargetByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_CREATE), [$section]);
139 } else {
140 $section = $f()->field()->section($items, $txt(ilMMSubItemGUI::CMD_EDIT), "");
141 $this->form = $f()->container()->form()
142 ->standard($this->ctrl->getLinkTargetByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_UPDATE), [$section]);
143 }
144 }
$section
Definition: Utf8Test.php:83
Class ilMMUploadHandlerGUI.
$txt
Definition: error.php:13
$type

References Vendor\Package\$f, $section, $txt, $type, ilMMSubItemGUI\CMD_ADD, ilMMSubItemGUI\CMD_CREATE, ilMMSubItemGUI\CMD_EDIT, ilMMSubItemGUI\CMD_UPDATE, F_ACTIVE, F_ICON, F_PARENT, F_TITLE, F_TYPE, getTypeGroups(), ilMimeTypeUtil\IMAGE__SVG_XML, and repository().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilMMSubitemFormGUI::save ( )

Definition at line 146 of file class.ilMMSubitemFormGUI.php.

146 : bool
147 {
148 global $DIC;
149 $r = new ilMMItemRepository();
150 $this->form = $this->form->withRequest($DIC->http()->request());
151 $data = $this->form->getData();
152
153 if (is_null($data)) {
154 return false;
155 }
156
157 $this->item_facade->setAction((string) $data[0]['action']);
158 $this->item_facade->setDefaultTitle((string) $data[0][self::F_TITLE]);
159 $this->item_facade->setActiveStatus((bool) $data[0][self::F_ACTIVE]);
160 if ((string) $data[0][self::F_PARENT]) {
161 $this->item_facade->setParent((string) $data[0][self::F_PARENT]);
162 }
163 $this->item_facade->setIsTopItm(false);
164
165 if ($this->item_facade->isEmpty()) {
166 $type = $this->unhash((string) ($data[0][self::F_TYPE][0]));
167 $this->item_facade->setType($type);
168 $r->createItem($this->item_facade);
169 }
170
171 if ($this->item_facade->supportsCustomIcon()) {
172 $icon = (string) $data[0][self::F_ICON][0];
173 $this->item_facade->setIconID($icon);
174 }
175
176 if ($this->item_facade->isCustom()) {
177 $type = $this->item_facade->getType();
178 $type_specific_data = (array) $data[0][self::F_TYPE][1];
179 $type_handler = $this->repository->getTypeHandlerForType($type);
180 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
181 }
182
183 $r->updateItem($this->item_facade);
184
185 return true;
186 }
Class ilMMItemRepository.
$data
Definition: storeScorm.php:23
$DIC
Definition: xapitoken.php:46

References $data, $DIC, $type, and repository().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMMSubitemFormGUI::$ctrl
protected

Definition at line 38 of file class.ilMMSubitemFormGUI.php.

Referenced by __construct().

◆ $form

ilMMSubitemFormGUI::$form
private

Definition at line 30 of file class.ilMMSubitemFormGUI.php.

◆ $item_facade

ilMMSubitemFormGUI::$item_facade
private

Definition at line 50 of file class.ilMMSubitemFormGUI.php.

◆ $lng

ilMMSubitemFormGUI::$lng
protected

Definition at line 34 of file class.ilMMSubitemFormGUI.php.

Referenced by __construct().

◆ $repository

ilMMSubitemFormGUI::$repository
private

Definition at line 26 of file class.ilMMSubitemFormGUI.php.

Referenced by __construct().

◆ $ui_fa

ilMMSubitemFormGUI::$ui_fa
protected

Definition at line 42 of file class.ilMMSubitemFormGUI.php.

Referenced by __construct().

◆ $ui_re

ilMMSubitemFormGUI::$ui_re
protected

Definition at line 46 of file class.ilMMSubitemFormGUI.php.

Referenced by __construct().

◆ F_ACTIVE

const ilMMSubitemFormGUI::F_ACTIVE = "active"

Definition at line 21 of file class.ilMMSubitemFormGUI.php.

Referenced by initForm().

◆ F_ICON

const ilMMSubitemFormGUI::F_ICON = "icon"

Definition at line 22 of file class.ilMMSubitemFormGUI.php.

Referenced by initForm().

◆ F_PARENT

const ilMMSubitemFormGUI::F_PARENT = "parent"

Definition at line 20 of file class.ilMMSubitemFormGUI.php.

Referenced by initForm().

◆ F_TITLE

const ilMMSubitemFormGUI::F_TITLE = "title"

Definition at line 18 of file class.ilMMSubitemFormGUI.php.

Referenced by initForm().

◆ F_TYPE

const ilMMSubitemFormGUI::F_TYPE = "type"

Definition at line 19 of file class.ilMMSubitemFormGUI.php.

Referenced by initForm().


The documentation for this class was generated from the following file: