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

Class ilMMTopItemFormGUI. More...

+ Collaboration diagram for ilMMTopItemFormGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, Factory $ui_fa, Renderer $ui_re, ilLanguage $lng, \ILIAS\DI\HTTPServices $http, ilMMItemFacadeInterface $item, ilMMItemRepository $repository)
 
 save ()
 
 getHTML ()
 

Data Fields

const F_ACTIVE = 'active'
 ilMMTopItemFormGUI constructor. More...
 
const F_TITLE = 'title'
 
const F_TYPE = 'type'
 
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

const F_ICON = 'icon'
 
 $http
 
 $repository
 
 $form
 
 $item_facade
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMTopItemFormGUI::__construct ( ilCtrl  $ctrl,
Factory  $ui_fa,
Renderer  $ui_re,
ilLanguage  $lng,
\ILIAS\DI\HTTPServices  $http,
ilMMItemFacadeInterface  $item,
ilMMItemRepository  $repository 
)

Definition at line 62 of file class.ilMMTopItemFormGUI.php.

70 {
71 $this->repository = $repository;
72 $this->http = $http;
73 $this->ctrl = $ctrl;
74 $this->ui_fa = $ui_fa;
75 $this->ui_re = $ui_re;
76 $this->lng = $lng;
77 $this->item_facade = $item;
78 if (!$this->item_facade->isEmpty()) {
79 $this->ctrl->saveParameterByClass(ilMMTopItemGUI::class, ilMMTopItemGUI::IDENTIFIER);
80 }
81
82 $this->initForm();
83 }
static http()
Fetches the global http state from ILIAS.
repository()
Definition: repository.php:5

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilMMTopItemFormGUI::getHTML ( )
Returns
string

Definition at line 185 of file class.ilMMTopItemFormGUI.php.

185 : string
186 {
187 return $this->ui_re->render([$this->form]);
188 }

◆ getTypeGroups()

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

Definition at line 194 of file class.ilMMTopItemFormGUI.php.

194 : array
195 {
196 $type_groups = [];
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())
201 ) { // https://mantis.ilias.de/view.php?id=24152
202 $inputs = $this->repository->getTypeHandlerForType($classname)->getAdditionalFieldsForSubForm($this->item_facade->identification());
203 $type_groups[$this->hash($classname)] = $f()->field()->group($inputs,
204 $information->getTypeNameForPresentation());
205 }
206 }
207
208 return $type_groups;
209 }

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()

ilMMTopItemFormGUI::initForm ( )
private

Definition at line 85 of file class.ilMMTopItemFormGUI.php.

86 {
87 $txt = function ($key) {
88 return $this->lng->txt($key);
89 };
90 $f = function () : InputFactory {
91 return $this->ui_fa->input();
92 };
93
94 // TITLE
95 $title = $f()->field()->text($txt('topitem_title_default'), $txt('topitem_title_default_byline'))
96 ->withRequired(true);
97 if (!$this->item_facade->isEmpty()) {
98 $title = $title->withValue($this->item_facade->getDefaultTitle());
99 }
100
101 $items[self::F_TITLE] = $title;
102
103 if ($this->item_facade->supportsCustomIcon()) {
104 // ICON
105 $icon = $f()->field()->file(new ilMMUploadHandlerGUI(), $txt('topitem_icon'))
106 ->withByline($txt('topitem_icon_byline'))
107 ->withAcceptedMimeTypes([ilMimeTypeUtil::IMAGE__SVG_XML]);
108 if ($this->item_facade->getIconID() !== null) {
109 $icon = $icon->withValue([$this->item_facade->getIconID()]);
110 }
111
112 $items[self::F_ICON] = $icon;
113 }
114
115 // TYPE
116 if (($this->item_facade->isEmpty() || $this->item_facade->isCustom())) {
117 $type_groups = $this->getTypeGroups($f);
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));
123 } else {
124 $type = $type->withValue($this->hash(TopParentItem::class));
125 }
126 $items[self::F_TYPE] = $type;
127 }
128
129 // ACTIVE
130 $active = $f()->field()->checkbox($txt('topitem_active'), $txt('topitem_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(ilMMTopItemGUI::CMD_ADD), "");
137 $this->form = $f()->container()->form()->standard($this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class,
139 } else {
140 $section = $f()->field()->section($items, $txt(ilMMTopItemGUI::CMD_EDIT), "");
141 $this->form = $f()->container()->form()->standard($this->ctrl->getLinkTargetByClass(ilMMTopItemGUI::class,
143 }
144 }
$section
Definition: Utf8Test.php:83
const F_ACTIVE
ilMMTopItemFormGUI constructor.
Class ilMMUploadHandlerGUI.
$txt
Definition: error.php:13
$type

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

Referenced by __construct().

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

◆ save()

ilMMTopItemFormGUI::save ( )

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

147 {
148 $this->form = $this->form->withRequest($this->http->request());
149 $data = $this->form->getData();
150 if (is_null($data)) {
151 return false;
152 }
153
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);
158
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);
163 }
164
165 if ($this->item_facade->supportsCustomIcon()) {
166 $icon = (string) $data[0][self::F_ICON][0];
167 $this->item_facade->setIconID($icon);
168 }
169
170 if ($this->item_facade->isCustom()) {
171 $type = $this->item_facade->getType();
172 $type_specific_data = (array) $data[0][self::F_TYPE][1];
173 $type_handler = $this->repository->getTypeHandlerForType($type);
174 $type_handler->saveFormFields($this->item_facade->identification(), $type_specific_data);
175 }
176
177 $this->repository->updateItem($this->item_facade);
178
179 return true;
180 }
$data
Definition: storeScorm.php:23

References $data, $type, ILIAS\FileDelivery\http(), and repository().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMMTopItemFormGUI::$ctrl
protected

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

Referenced by __construct().

◆ $form

ilMMTopItemFormGUI::$form
private

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

◆ $http

ilMMTopItemFormGUI::$http
private

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

Referenced by __construct().

◆ $item_facade

ilMMTopItemFormGUI::$item_facade
private

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

◆ $lng

ilMMTopItemFormGUI::$lng
protected

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

Referenced by __construct().

◆ $repository

ilMMTopItemFormGUI::$repository
private

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

Referenced by __construct().

◆ $ui_fa

ilMMTopItemFormGUI::$ui_fa
protected

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

Referenced by __construct().

◆ $ui_re

ilMMTopItemFormGUI::$ui_re
protected

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

Referenced by __construct().

◆ F_ACTIVE

const ilMMTopItemFormGUI::F_ACTIVE = 'active'

ilMMTopItemFormGUI constructor.

Parameters
ilCtrl$ctrl
Factory$ui_fa
Renderer$ui_re

Definition at line 57 of file class.ilMMTopItemFormGUI.php.

Referenced by initForm().

◆ F_ICON

const ilMMTopItemFormGUI::F_ICON = 'icon'
private

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

Referenced by initForm().

◆ F_ROLE_BASED_VISIBILITY

const ilMMTopItemFormGUI::F_ROLE_BASED_VISIBILITY = "role_based_visibility"

Definition at line 60 of file class.ilMMTopItemFormGUI.php.

◆ F_TITLE

const ilMMTopItemFormGUI::F_TITLE = 'title'

Definition at line 58 of file class.ilMMTopItemFormGUI.php.

Referenced by initForm().

◆ F_TYPE

const ilMMTopItemFormGUI::F_TYPE = 'type'

Definition at line 59 of file class.ilMMTopItemFormGUI.php.

Referenced by initForm().


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