ILIAS  release_8 Revision v8.24
ilDclFieldEditGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilDclFieldEditGUI:

Public Member Functions

 __construct (ilDclTableListGUI $a_parent_obj)
 Constructor. More...
 
 executeCommand ()
 execute command More...
 
 create ()
 create field add form More...
 
 edit ()
 create field edit form More...
 
 permissionDenied ()
 
 confirmDelete ()
 confirmDelete More...
 
 cancelDelete ()
 cancelDelete More...
 
 delete ()
 
 cancel ()
 
 initForm (string $a_mode="create")
 initEditCustomForm More...
 
 save (string $a_mode="create")
 save Field More...
 
 getDataCollectionObject ()
 

Protected Member Functions

 checkInput (string $a_mode)
 Check input of form. More...
 
 checkAccess ()
 

Protected Attributes

int $obj_id
 
int $table_id
 
ilDclTableListGUI $parent_obj
 
ilDclTable $table
 
ilPropertyFormGUI $form
 
ilDclBaseFieldModel $field_obj
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
int $field_id
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Constructor & Destructor Documentation

◆ __construct()

ilDclFieldEditGUI::__construct ( ilDclTableListGUI  $a_parent_obj)

Constructor.

Definition at line 36 of file class.ilDclFieldEditGUI.php.

37 {
38 global $DIC;
39 $this->main_tpl = $DIC->ui()->mainTemplate();
40 $ilCtrl = $DIC['ilCtrl'];
41
42 $this->obj_id = $a_parent_obj->getObjId();
43 $this->parent_obj = $a_parent_obj;
44 $this->http = $DIC->http();
45 $this->refinery = $DIC->refinery();
46
47 $this->table_id = $this->http->wrapper()->query()->retrieve('table_id', $this->refinery->kindlyTo()->int());
48
49 $hasFieldId = $this->http->wrapper()->query()->has('field_id');
50 if ($hasFieldId) {
51 $this->field_id = $this->http->wrapper()->query()->retrieve('field_id', $this->refinery->kindlyTo()->int());
52 } else {
53 $this->field_id = 0;
54 }
55
56 if ($this->field_id) {
57 $this->field_obj = ilDclCache::getFieldCache($this->field_id);
58 } else {
59 $datatype = null;
60
61 $has_datatype = $this->http->wrapper()->post()->has('datatype');
62
63 if ($has_datatype) {
64 $datatype_value = $this->http->wrapper()->post()->retrieve(
65 'datatype',
66 $this->refinery->kindlyTo()->string()
67 );
68 if (in_array(
69 $datatype_value,
71 )) {
72 $datatype = $datatype_value;
73 }
74 }
75 $this->field_obj = ilDclFieldFactory::getFieldModelInstance($this->field_id, $datatype);
76 if (!$this->table_id) {
77 $ilCtrl->redirectByClass("ilDclTableListGUI", "listFields");
78 }
79 $this->field_obj->setTableId($this->table_id);
80 $ilCtrl->saveParameter($this, "table_id");
81 }
82
83 $this->table = ilDclCache::getTableCache($this->table_id);
84 }
static getFieldCache(int $field_id=0)
static getTableCache(int $table_id=null)
static getAllDatatype(bool $force=false)
Get all possible Datatypes.
static getFieldModelInstance(int $field_id, ?int $datatype=null)
Get FieldModel from field-id and datatype.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

References $DIC, ilDclDatatype\getAllDatatype(), ilDclCache\getFieldCache(), ilDclFieldFactory\getFieldModelInstance(), ilDclTableListGUI\getObjId(), ilDclCache\getTableCache(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancel()

ilDclFieldEditGUI::cancel ( )

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

197 : void
198 {
199 global $DIC;
200 $ilCtrl = $DIC['ilCtrl'];
201 $ilCtrl->redirectByClass("ildclfieldlistgui", "listFields");
202 }

References $DIC.

◆ cancelDelete()

ilDclFieldEditGUI::cancelDelete ( )

cancelDelete

Definition at line 174 of file class.ilDclFieldEditGUI.php.

174 : void
175 {
176 global $DIC;
177 $ilCtrl = $DIC['ilCtrl'];
178
179 $ilCtrl->redirectByClass("ildclfieldlistgui", "listFields");
180 }

References $DIC.

◆ checkAccess()

ilDclFieldEditGUI::checkAccess ( )
protected
Returns
bool

Definition at line 380 of file class.ilDclFieldEditGUI.php.

380 : bool
381 {
382 if ($field_id = $this->field_obj->getId()) {
384 $this->getDataCollectionObject()->getRefId(),
385 $this->table_id,
387 );
388 } else {
390 $this->getDataCollectionObject()->getRefId(),
391 $this->table_id
392 );
393 }
394 }
static hasAccessToFields(int $ref_id, int $table_id)
static hasAccessToField(int $ref_id, int $table_id, int $field_id)

References $field_id, getDataCollectionObject(), ilObjDataCollectionAccess\hasAccessToField(), and ilObjDataCollectionAccess\hasAccessToFields().

Referenced by executeCommand().

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

◆ checkInput()

ilDclFieldEditGUI::checkInput ( string  $a_mode)
protected

Check input of form.

Parameters
$a_mode'create' | 'update'
Returns
bool

Definition at line 341 of file class.ilDclFieldEditGUI.php.

341 : bool
342 {
343 global $DIC;
344 $lng = $DIC['lng'];
345 $return = $this->form->checkInput();
346
347 // load specific model for input checking
348 $datatype_id = $this->form->getInput('datatype');
349 if ($datatype_id != null && is_numeric($datatype_id)) {
350 $base_model = new ilDclBaseFieldModel();
351 $base_model->setDatatypeId($datatype_id);
352 $field_validation_class = ilDclFieldFactory::getFieldModelInstanceByClass($base_model);
353
354 if (!$field_validation_class->checkFieldCreationInput($this->form)) {
355 $return = false;
356 }
357 }
358
359 // Don't allow multiple fields with the same title in this table
360 if ($a_mode == 'create') {
361 if ($title = $this->form->getInput('title')) {
362 if (ilDclTable::_hasFieldByTitle($title, $this->table_id)) {
363 $inputObj = $this->form->getItemByPostVar('title');
364 $inputObj->setAlert($lng->txt("dcl_field_title_unique"));
365 $return = false;
366 }
367 }
368 }
369
370 if (!$return) {
371 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
372 }
373
374 return $return;
375 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getFieldModelInstanceByClass(ilDclBaseFieldModel $field, ?int $field_id=null)
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldMod...
static _hasFieldByTitle(string $title, int $obj_id)
Checks if a table has a field with the given title.
form( $class_path, string $cmd)
$lng

References $DIC, $lng, ilDclTable\_hasFieldByTitle(), ILIAS\Repository\form(), and ilDclFieldFactory\getFieldModelInstanceByClass().

Referenced by save().

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

◆ confirmDelete()

ilDclFieldEditGUI::confirmDelete ( )

confirmDelete

Definition at line 152 of file class.ilDclFieldEditGUI.php.

152 : void
153 {
154 global $DIC;
155 $ilCtrl = $DIC['ilCtrl'];
156 $lng = $DIC['lng'];
157 $tpl = $DIC['tpl'];
158
159 $conf = new ilConfirmationGUI();
160 $conf->setFormAction($ilCtrl->getFormAction($this));
161 $conf->setHeaderText($lng->txt('dcl_confirm_delete_field'));
162
163 $conf->addItem('field_id', (int) $this->field_obj->getId(), $this->field_obj->getTitle());
164
165 $conf->setConfirm($lng->txt('delete'), 'delete');
166 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
167
168 $tpl->setContent($conf->getHTML());
169 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $DIC, $lng, and $tpl.

◆ create()

ilDclFieldEditGUI::create ( )

create field add form

Definition at line 115 of file class.ilDclFieldEditGUI.php.

115 : void
116 {
117 global $DIC;
118 $tpl = $DIC['tpl'];
119
120 $this->initForm();
121 $tpl->setContent($this->form->getHTML());
122 }
initForm(string $a_mode="create")
initEditCustomForm

References $DIC, $tpl, ILIAS\Repository\form(), and initForm().

+ Here is the call graph for this function:

◆ delete()

ilDclFieldEditGUI::delete ( )

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

185 : void
186 {
187 global $DIC;
188 $ilCtrl = $DIC['ilCtrl'];
189
190 $this->table->deleteField($this->field_obj->getId());
191 $ilCtrl->redirectByClass("ildclfieldlistgui", "listFields");
192 }

References $DIC.

◆ edit()

ilDclFieldEditGUI::edit ( )

create field edit form

Definition at line 127 of file class.ilDclFieldEditGUI.php.

127 : void
128 {
129 global $DIC;
130 $tpl = $DIC['tpl'];
131
132 $this->initForm("edit");
133
134 $this->field_obj->fillPropertiesForm($this->form);
135
136 $tpl->setContent($this->form->getHTML());
137 }

References $DIC, $tpl, ILIAS\Repository\form(), and initForm().

+ Here is the call graph for this function:

◆ executeCommand()

ilDclFieldEditGUI::executeCommand ( )

execute command

Definition at line 89 of file class.ilDclFieldEditGUI.php.

89 : void
90 {
91 global $DIC;
92 $ilCtrl = $DIC['ilCtrl'];
93 $ilCtrl->saveParameter($this, 'field_id');
94
95 $cmd = $ilCtrl->getCmd();
96
97 if (!$this->checkAccess()) {
98 $this->permissionDenied();
99 return;
100 }
101
102 switch ($cmd) {
103 case "update":
104 $this->save("update");
105 break;
106 default:
107 $this->$cmd();
108 break;
109 }
110 }
save(string $a_mode="create")
save Field

References $DIC, checkAccess(), permissionDenied(), and save().

+ Here is the call graph for this function:

◆ getDataCollectionObject()

ilDclFieldEditGUI::getDataCollectionObject ( )
Returns
ilObjDataCollection

Definition at line 399 of file class.ilDclFieldEditGUI.php.

400 {
401 return $this->parent_obj->getDataCollectionObject();
402 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by checkAccess(), and initForm().

+ Here is the caller graph for this function:

◆ initForm()

ilDclFieldEditGUI::initForm ( string  $a_mode = "create")

initEditCustomForm

Parameters
string$a_modevalues: create | edit

Definition at line 208 of file class.ilDclFieldEditGUI.php.

208 : void
209 {
210 global $DIC;
211 $ilCtrl = $DIC['ilCtrl'];
212 $lng = $DIC['lng'];
213
214 $this->form = new ilPropertyFormGUI();
215
216 if ($a_mode == "edit") {
217 $this->form->setTitle($lng->txt('dcl_edit_field'));
218 $hidden_prop = new ilHiddenInputGUI("field_id");
219 $this->form->addItem($hidden_prop);
220
221 $this->form->setFormAction($ilCtrl->getFormAction($this));
222
223 $this->form->addCommandButton('update', $lng->txt('dcl_update_field'));
224 } else {
225 $this->form->setTitle($lng->txt('dcl_new_field'));
226 $hidden_prop = new ilHiddenInputGUI("table_id");
227 $hidden_prop->setValue($this->field_obj->getTableId());
228 $this->form->addItem($hidden_prop);
229
230 $this->form->setFormAction($ilCtrl->getFormAction($this));
231
232 $this->form->addCommandButton('save', $lng->txt('dcl_create_field'));
233 }
234 $this->form->addCommandButton('cancel', $lng->txt('cancel'));
235
236 $text_prop = new ilTextInputGUI($lng->txt("title"), "title");
237 $text_prop->setRequired(true);
238 $text_prop->setInfo(sprintf(
239 $lng->txt('fieldtitle_allow_chars'),
241 ));
242 $text_prop->setValidationRegexp(ilDclBaseFieldModel::_getTitleInvalidChars(true));
243 $this->form->addItem($text_prop);
244
245 // Description
246 $text_prop = new ilTextAreaInputGUI($lng->txt("dcl_field_description"), "description");
247 $this->form->addItem($text_prop);
248
249 $edit_datatype = new ilRadioGroupInputGUI($lng->txt('dcl_datatype'), 'datatype');
250
251 foreach (ilDclDatatype::getAllDatatype() as $datatype) {
252 $model = new ilDclBaseFieldModel();
253 $model->setDatatypeId($datatype->getId());
255
256 if ($a_mode == 'edit' && $datatype->getId() === $this->field_obj->getDatatypeId()) {
257 $model = $this->field_obj;
258 }
259
260 $field_representation = ilDclFieldFactory::getFieldRepresentationInstance($model);
261 $field_representation->addFieldCreationForm($edit_datatype, $this->getDataCollectionObject(), $a_mode);
262 }
263 $edit_datatype->setRequired(true);
264
265 //you can't change type but we still need it in POST
266 if ($a_mode == "edit") {
267 $edit_datatype->setDisabled(true);
268 }
269 $this->form->addItem($edit_datatype);
270
271 //Unique
272 $cb = new ilCheckboxInputGUI($lng->txt("dcl_unique"), "unique");
273 $cb->setInfo($lng->txt('dcl_unique_desc'));
274 $this->form->addItem($cb);
275 }
This class represents a checkbox property in a property form.
static _getTitleInvalidChars(bool $a_as_regex=true)
All valid chars for filed titles.
ilDclBaseFieldModel $field_obj
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This class represents a property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References $DIC, $field_obj, $lng, ilDclBaseFieldModel\_getTitleInvalidChars(), ILIAS\Repository\form(), ilDclDatatype\getAllDatatype(), getDataCollectionObject(), ilDclFieldFactory\getFieldModelInstanceByClass(), and ilDclFieldFactory\getFieldRepresentationInstance().

Referenced by create(), edit(), and save().

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

◆ permissionDenied()

ilDclFieldEditGUI::permissionDenied ( )

Definition at line 142 of file class.ilDclFieldEditGUI.php.

142 : void
143 {
144 global $DIC;
145 $tpl = $DIC['tpl'];
146 $tpl->setContent("Permission denied");
147 }

References $DIC, and $tpl.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ save()

ilDclFieldEditGUI::save ( string  $a_mode = "create")

save Field

Parameters
string$a_modevalues: create | update

Definition at line 281 of file class.ilDclFieldEditGUI.php.

281 : void
282 {
283 global $DIC;
284 $ilCtrl = $DIC['ilCtrl'];
285 $lng = $DIC['lng'];
286 $tpl = $DIC['tpl'];
287
288 $this->initForm($a_mode == "update" ? "edit" : "create");
289
290 if ($this->checkInput($a_mode)) {
291
292 // check if confirmation is needed and if so, fetch and render confirmationGUI
293 if (($a_mode == "update") && !($this->form->getInput('confirmed')) && $this->field_obj->isConfirmationRequired($this->form)) {
294 $ilConfirmationGUI = $this->field_obj->getConfirmationGUI($this->form);
295 $tpl->setContent($ilConfirmationGUI->getHTML());
296
297 return;
298 }
299
300 $title = $this->form->getInput("title");
301 if ($a_mode != "create" && $title != $this->field_obj->getTitle()) {
302 $this->main_tpl->setOnScreenMessage('info', $lng->txt("dcl_field_title_change_warning"), true);
303 }
304
305 $this->field_obj->setTitle($title);
306 $this->field_obj->setDescription($this->form->getInput("description"));
307 $this->field_obj->setDatatypeId($this->form->getInput("datatype"));
308 $this->field_obj->setUnique($this->form->getInput("unique"));
309
310 if ($a_mode == "update") {
311 $this->field_obj->doUpdate();
312 } else {
313 $this->field_obj->setOrder($this->table->getNewFieldOrder());
314 $this->field_obj->doCreate();
315 }
316
317 // Get possible properties and save them
318 $this->field_obj->storePropertiesFromForm($this->form);
319
320 $ilCtrl->setParameter($this, "field_id", $this->field_obj->getId());
321
322 if ($a_mode == "update") {
323 $this->main_tpl->setOnScreenMessage('success', $lng->txt("dcl_msg_field_modified"), true);
324 } else {
325 $this->table->addField($this->field_obj);
326 $this->table->buildOrderFields();
327 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_field_created"), false);
328 }
329 $ilCtrl->redirectByClass(strtolower("ilDclFieldListGUI"), "listFields");
330 } else {
331 $this->form->setValuesByPost();
332 $tpl->setContent($this->form->getHTML());
333 }
334 }
checkInput(string $a_mode)
Check input of form.

References $DIC, $lng, $tpl, checkInput(), ILIAS\Repository\form(), and initForm().

Referenced by executeCommand().

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

Field Documentation

◆ $field_id

int ilDclFieldEditGUI::$field_id
protected

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

Referenced by checkAccess().

◆ $field_obj

ilDclBaseFieldModel ilDclFieldEditGUI::$field_obj
protected

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

Referenced by initForm().

◆ $form

ilPropertyFormGUI ilDclFieldEditGUI::$form
protected

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

◆ $http

ILIAS HTTP Services ilDclFieldEditGUI::$http
protected

Definition at line 29 of file class.ilDclFieldEditGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilDclFieldEditGUI::$main_tpl
private

Definition at line 28 of file class.ilDclFieldEditGUI.php.

◆ $obj_id

int ilDclFieldEditGUI::$obj_id
protected

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

◆ $parent_obj

ilDclTableListGUI ilDclFieldEditGUI::$parent_obj
protected

Definition at line 24 of file class.ilDclFieldEditGUI.php.

◆ $refinery

ILIAS Refinery Factory ilDclFieldEditGUI::$refinery
protected

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

◆ $table

ilDclTable ilDclFieldEditGUI::$table
protected

Definition at line 25 of file class.ilDclFieldEditGUI.php.

◆ $table_id

int ilDclFieldEditGUI::$table_id
protected

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


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