ILIAS  release_7 Revision v7.30-3-g800a261c036
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"
 
const F_ROLE_BASED_VISIBILITY = "role_based_visibility"
 

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 62 of file class.ilMMSubitemFormGUI.php.

63 {
64 $this->ctrl = $ctrl;
65 $this->ui_fa = $ui_fa;
66 $this->ui_re = $ui_re;
67 $this->lng = $lng;
68 $this->item_facade = $item;
69 $this->repository = $repository;
70 if (!$this->item_facade->isEmpty()) {
71 $this->ctrl->saveParameterByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::IDENTIFIER);
72 }
73
74 $this->initForm();
75 }
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 220 of file class.ilMMSubitemFormGUI.php.

221 {
222 return $this->ui_re->render([$this->form]);
223 }

◆ getTypeGroups()

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

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

229 : array
230 {
231 $type_groups = [];
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())
236 ) { // https://mantis.ilias.de/view.php?id=24152
237 $inputs = $this->repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
238 $type_groups[$this->hash($classname)] = $f()->field()->group($inputs, $information->getTypeNameForPresentation());
239 }
240 }
241
242 return $type_groups;
243 }

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 77 of file class.ilMMSubitemFormGUI.php.

77 : void
78 {
79 // TITLE
80 $txt = function ($id) : string {
81 return $this->lng->txt($id);
82 };
83 $f = function () : InputFactory {
84 return $this->ui_fa->input();
85 };
86
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());
90 }
91 $items[self::F_TITLE] = $title;
92
93 // TYPE
94 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
95 $type_groups = $this->getTypeGroups($f);
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));
100 } else {
101 $type = $type->withValue($this->hash(Link::class));
102 }
103 $items[self::F_TYPE] = $type;
104 }
105
106 // ICON
107 if ($this->item_facade->supportsCustomIcon()) {
108 // ICON
109 $icon = $f()->field()->file(new ilMMUploadHandlerGUI(), $txt('sub_icon'))
110 ->withByline($txt('sub_icon_byline'))
111 ->withAcceptedMimeTypes([ilMimeTypeUtil::IMAGE__SVG_XML])
112 ->withMaxFileSize(ilMMUploadHandlerGUI::MAX_FILE_SIZE);
113 if ($this->item_facade->getIconID() !== null) {
114 $icon = $icon->withValue([$this->item_facade->getIconID()]);
115 }
116
117 $items[self::F_ICON] = $icon;
118 }
119
120 // PARENT
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());
125 } else {
126 $array = array_keys($this->repository->getPossibleParentsForFormAndTable());
127 $parent = $parent->withValue(reset($array));
128 }
129 $items[self::F_PARENT] = $parent;
130
131 // ACTIVE
132 $active = $f()->field()->checkbox($txt('sub_active'), $txt('sub_active_byline'));
133 $active = $active->withValue($this->item_facade->isActivated());
134 $items[self::F_ACTIVE] = $active;
135
136 // ROLE BASED VISIBILITY
137 if($this->item_facade->supportsRoleBasedVisibility()) {
138 $access = new ilObjMainMenuAccess();
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)) {
143 // remove deleted roles, see https://mantis.ilias.de/view.php?id=34936
144 $value_role_based_visibility[0] = array_intersect(
145 $global_role_ids,
146 array_keys($global_roles)
147 );
148 }
149 $role_based_visibility = $f()->field()->optionalGroup(
150 [
151 $f()->field()->multiSelect(
152 $txt('sub_global_roles'),
153 $global_roles
154 )->withRequired(true)
155 ],
156 $txt('sub_role_based_visibility'),
157 $txt('sub_role_based_visibility_byline')
158 )->withValue($value_role_based_visibility);
159 $items[self::F_ROLE_BASED_VISIBILITY] = $role_based_visibility;
160 }
161
162 // RETURN FORM
163 if ($this->item_facade->isEmpty()) {
164 $section = $f()->field()->section($items, $txt(ilMMSubItemGUI::CMD_ADD), "");
165 $this->form = $f()->container()->form()
166 ->standard($this->ctrl->getLinkTargetByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_CREATE), [$section]);
167 } else {
168 $section = $f()->field()->section($items, $txt(ilMMSubItemGUI::CMD_EDIT), "");
169 $this->form = $f()->container()->form()
170 ->standard($this->ctrl->getLinkTargetByClass(ilMMSubItemGUI::class, ilMMSubItemGUI::CMD_UPDATE), [$section]);
171 }
172 }
$section
Definition: Utf8Test.php:83
Class ilMMUploadHandlerGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$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_ROLE_BASED_VISIBILITY, F_TITLE, F_TYPE, getTypeGroups(), ilMimeTypeUtil\IMAGE__SVG_XML, ilMMUploadHandlerGUI\MAX_FILE_SIZE, 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 174 of file class.ilMMSubitemFormGUI.php.

174 : bool
175 {
176 global $DIC;
177 $r = new ilMMItemRepository();
178 $this->form = $this->form->withRequest($DIC->http()->request());
179 $data = $this->form->getData();
180
181 if (is_null($data)) {
182 return false;
183 }
184
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]);
191 }
192 if ((string) $data[0][self::F_PARENT]) {
193 $this->item_facade->setParent((string) $data[0][self::F_PARENT]);
194 }
195 $this->item_facade->setIsTopItm(false);
196
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);
201 }
202
203 if ($this->item_facade->supportsCustomIcon()) {
204 $icon = (string) $data[0][self::F_ICON][0];
205 $this->item_facade->setIconID($icon);
206 }
207
208 if ($this->item_facade->isCustom()) {
209 $type = $this->item_facade->getType();
210 $type_specific_data = (array) $data[0][self::F_TYPE][1];
211 $type_handler = $this->repository->getTypeHandlerForType($type);
212 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
213 }
214
215 $r->updateItem($this->item_facade);
216
217 return true;
218 }
Class ilMMItemRepository.
global $DIC
Definition: goto.php:24
$data
Definition: storeScorm.php:23

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

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMMSubitemFormGUI::$ctrl
protected

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

Referenced by __construct().

◆ $form

ilMMSubitemFormGUI::$form
private

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

◆ $item_facade

ilMMSubitemFormGUI::$item_facade
private

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

◆ $lng

ilMMSubitemFormGUI::$lng
protected

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

Referenced by __construct().

◆ $repository

ilMMSubitemFormGUI::$repository
private

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

Referenced by __construct().

◆ $ui_fa

ilMMSubitemFormGUI::$ui_fa
protected

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

Referenced by __construct().

◆ $ui_re

ilMMSubitemFormGUI::$ui_re
protected

Definition at line 47 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_ROLE_BASED_VISIBILITY

const ilMMSubitemFormGUI::F_ROLE_BASED_VISIBILITY = "role_based_visibility"

Definition at line 23 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: