ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDclFieldEditGUI Class Reference

Class ilDclFieldEditGUI. 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 ($a_mode="create")
 initEditCustomForm More...
 
 save ($a_mode="create")
 save Field More...
 
 getDataCollectionObject ()
 

Protected Member Functions

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

Protected Attributes

 $obj_id
 
 $table_id
 
 $parent_obj
 
 $table
 
 $form
 
 $field_obj
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclFieldEditGUI::__construct ( ilDclTableListGUI  $a_parent_obj)

Constructor.

Parameters
ilDclTableListGUI$a_parent_obj
int$table_idWe need a table_id if no field_id is set (creation mode). We ignore the table_id by edit mode
int$field_idThe field_id of a existing fiel (edit mode)

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

54 {
55 global $DIC;
56 $ilCtrl = $DIC['ilCtrl'];
57
58 $this->obj_id = $a_parent_obj->obj_id;
59 $this->parent_obj = $a_parent_obj;
60
61 $this->table_id = $_GET["table_id"];
62 $this->field_id = $_GET['field_id'];
63
64 if ($this->field_id) {
65 $this->field_obj = ilDclCache::getFieldCache($this->field_id);
66 } else {
67 $datatype = null;
68 if (isset($_POST['datatype']) && in_array($_POST['datatype'], array_keys(ilDclDatatype::getAllDatatype()))) {
69 $datatype = $_POST['datatype'];
70 }
71 $this->field_obj = ilDclFieldFactory::getFieldModelInstance($this->field_id, $datatype);
72 if (!$this->table_id) {
73 $ilCtrl->redirectByClass("ilDclTableListGUI", "listFields");
74 }
75 $this->field_obj->setTableId($this->table_id);
76 $ilCtrl->saveParameter($this, "table_id");
77 }
78
79 $this->table = ilDclCache::getTableCache($this->table_id);
80 }
$_GET["client_id"]
$_POST["username"]
static getTableCache($table_id=0)
static getFieldCache($field_id=0)
static getAllDatatype()
Get all possible Datatypes.
static getFieldModelInstance($field_id, $datatype=null)
Get FieldModel from field-id and datatype.
global $DIC
Definition: goto.php:24

References $_GET, $_POST, $DIC, ilDclDatatype\getAllDatatype(), ilDclCache\getFieldCache(), ilDclFieldFactory\getFieldModelInstance(), and ilDclCache\getTableCache().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancel()

ilDclFieldEditGUI::cancel ( )

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

205 {
206 global $DIC;
207 $ilCtrl = $DIC['ilCtrl'];
208 $ilCtrl->redirectByClass("ildclfieldlistgui", "listFields");
209 }

References $DIC.

◆ cancelDelete()

ilDclFieldEditGUI::cancelDelete ( )

cancelDelete

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

180 {
181 global $DIC;
182 $ilCtrl = $DIC['ilCtrl'];
183
184 $ilCtrl->redirectByClass("ildclfieldlistgui", "listFields");
185 }

References $DIC.

◆ checkAccess()

ilDclFieldEditGUI::checkAccess ( )
protected
Returns
bool

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

392 {
393 if ($field_id = $this->field_obj->getId()) {
394 return ilObjDataCollectionAccess::hasAccessToField($this->getDataCollectionObject()->ref_id, $this->table_id, $field_id);
395 } else {
396 return ilObjDataCollectionAccess::hasAccessToFields($this->getDataCollectionObject()->ref_id, $this->table_id);
397 }
398 }
static hasAccessToFields($ref_id, $table_id)
static hasAccessToField($ref_id, $table_id, $field_id)

References 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 (   $a_mode)
protected

Check input of form.

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

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

352 {
353 global $DIC;
354 $lng = $DIC['lng'];
355 $return = $this->form->checkInput();
356
357 // load specific model for input checking
358 $datatype_id = $this->form->getInput('datatype');
359 if ($datatype_id != null && is_numeric($datatype_id)) {
360 $base_model = new ilDclBaseFieldModel();
361 $base_model->setDatatypeId($datatype_id);
362 $field_validation_class = ilDclFieldFactory::getFieldModelInstanceByClass($base_model);
363
364 if (!$field_validation_class->checkFieldCreationInput($this->form)) {
365 $return = false;
366 }
367 }
368
369 // Don't allow multiple fields with the same title in this table
370 if ($a_mode == 'create') {
371 if ($title = $this->form->getInput('title')) {
372 if (ilDclTable::_hasFieldByTitle($title, $this->table_id)) {
373 $inputObj = $this->form->getItemByPostVar('title');
374 $inputObj->setAlert($lng->txt("dcl_field_title_unique"));
375 $return = false;
376 }
377 }
378 }
379
380 if (!$return) {
381 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
382 }
383
384 return $return;
385 }
Class ilDclBaseFieldModel.
static getFieldModelInstanceByClass(ilDclBaseFieldModel $field, $field_id=null)
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldMod...
static _hasFieldByTitle($title, $obj_id)
Checks if a table has a field with the given title.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$lng

References $DIC, $lng, ilDclTable\_hasFieldByTitle(), ilDclFieldFactory\getFieldModelInstanceByClass(), and ilUtil\sendFailure().

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 156 of file class.ilDclFieldEditGUI.php.

157 {
158 global $DIC;
159 $ilCtrl = $DIC['ilCtrl'];
160 $lng = $DIC['lng'];
161 $tpl = $DIC['tpl'];
162
163 $conf = new ilConfirmationGUI();
164 $conf->setFormAction($ilCtrl->getFormAction($this));
165 $conf->setHeaderText($lng->txt('dcl_confirm_delete_field'));
166
167 $conf->addItem('field_id', (int) $this->field_obj->getId(), $this->field_obj->getTitle());
168
169 $conf->setConfirm($lng->txt('delete'), 'delete');
170 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
171
172 $tpl->setContent($conf->getHTML());
173 }
Confirmation screen class.
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 116 of file class.ilDclFieldEditGUI.php.

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

References $DIC, $tpl, and initForm().

+ Here is the call graph for this function:

◆ delete()

ilDclFieldEditGUI::delete ( )

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

192 {
193 global $DIC;
194 $ilCtrl = $DIC['ilCtrl'];
195
196 $this->table->deleteField($this->field_obj->getId());
197 $ilCtrl->redirectByClass("ildclfieldlistgui", "listFields");
198 }

References $DIC.

◆ edit()

ilDclFieldEditGUI::edit ( )

create field edit form

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

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

References $DIC, $tpl, and initForm().

+ Here is the call graph for this function:

◆ executeCommand()

ilDclFieldEditGUI::executeCommand ( )

execute command

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

87 {
88 global $DIC;
89 $ilCtrl = $DIC['ilCtrl'];
90 $ilCtrl->saveParameter($this, 'field_id');
91
92 $cmd = $ilCtrl->getCmd();
93
94 if (!$this->checkAccess()) {
95 $this->permissionDenied();
96
97 return;
98 }
99
100 switch ($cmd) {
101 case "update":
102 $this->save("update");
103 break;
104 default:
105 $this->$cmd();
106 break;
107 }
108
109 return true;
110 }
save($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 404 of file class.ilDclFieldEditGUI.php.

405 {
406 return $this->parent_obj->getDataCollectionObject();
407 }

Referenced by checkAccess(), and initForm().

+ Here is the caller graph for this function:

◆ initForm()

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

initEditCustomForm

Parameters
string$a_modevalues: create | edit

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

218 {
219 global $DIC;
220 $ilCtrl = $DIC['ilCtrl'];
221 $lng = $DIC['lng'];
222
223 $this->form = new ilPropertyFormGUI();
224
225 if ($a_mode == "edit") {
226 $this->form->setTitle($lng->txt('dcl_edit_field'));
227 $hidden_prop = new ilHiddenInputGUI("field_id");
228 $this->form->addItem($hidden_prop);
229
230 $this->form->setFormAction($ilCtrl->getFormAction($this), "update");
231
232 $this->form->addCommandButton('update', $lng->txt('dcl_update_field'));
233 } else {
234 $this->form->setTitle($lng->txt('dcl_new_field'));
235 $hidden_prop = new ilHiddenInputGUI("table_id");
236 $hidden_prop->setValue($this->field_obj->getTableId());
237 $this->form->addItem($hidden_prop);
238
239 $this->form->setFormAction($ilCtrl->getFormAction($this), "save");
240
241 $this->form->addCommandButton('save', $lng->txt('dcl_create_field'));
242 }
243 $this->form->addCommandButton('cancel', $lng->txt('cancel'));
244
245 $text_prop = new ilTextInputGUI($lng->txt("title"), "title");
246 $text_prop->setRequired(true);
247 $text_prop->setInfo(sprintf($lng->txt('fieldtitle_allow_chars'), ilDclBaseFieldModel::_getTitleInvalidChars(false)));
248 $text_prop->setValidationRegexp(ilDclBaseFieldModel::_getTitleInvalidChars(true));
249 $this->form->addItem($text_prop);
250
251 // Description
252 $text_prop = new ilTextAreaInputGUI($lng->txt("dcl_field_description"), "description");
253 $this->form->addItem($text_prop);
254
255 $edit_datatype = new ilRadioGroupInputGUI($lng->txt('dcl_datatype'), 'datatype');
256
257 foreach (ilDclDatatype::getAllDatatype() as $datatype) {
258 $model = new ilDclBaseFieldModel();
259 $model->setDatatypeId($datatype->getId());
260
261 if ($a_mode == 'edit' && $datatype->getId() == $this->field_obj->getDatatypeId()) {
262 $model = $this->field_obj;
263 }
264
265 $field_representation = ilDclFieldFactory::getFieldRepresentationInstance($model);
266 $field_representation->addFieldCreationForm($edit_datatype, $this->getDataCollectionObject(), $a_mode);
267 }
268 $edit_datatype->setRequired(true);
269
270 //you can't change type but we still need it in POST
271 if ($a_mode == "edit") {
272 $edit_datatype->setDisabled(true);
273 }
274 $this->form->addItem($edit_datatype);
275
276 //Unique
277 $cb = new ilCheckboxInputGUI($lng->txt("dcl_unique"), "unique");
278 $cb->setInfo($lng->txt('dcl_unique_desc'));
279 $this->form->addItem($cb);
280 }
This class represents a checkbox property in a property form.
static _getTitleInvalidChars($a_as_regex=true)
All valid chars for filed titles.
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
Returns FieldRepresentation from BaseFieldModel.
This class represents a hidden form property in a property form.
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(), ilDclDatatype\getAllDatatype(), getDataCollectionObject(), 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 145 of file class.ilDclFieldEditGUI.php.

146 {
147 global $DIC;
148 $tpl = $DIC['tpl'];
149 $tpl->setContent("Permission denied");
150 }

References $DIC, and $tpl.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ save()

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

save Field

Parameters
string$a_modevalues: create | update

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

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

References $DIC, $lng, $tpl, checkInput(), initForm(), and ilUtil\sendInfo().

Referenced by executeCommand().

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

Field Documentation

◆ $field_obj

ilDclFieldEditGUI::$field_obj
protected

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

Referenced by initForm().

◆ $form

ilDclFieldEditGUI::$form
protected

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

◆ $obj_id

ilDclFieldEditGUI::$obj_id
protected

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

◆ $parent_obj

ilDclFieldEditGUI::$parent_obj
protected

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

◆ $table

ilDclFieldEditGUI::$table
protected

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

◆ $table_id

ilDclFieldEditGUI::$table_id
protected

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


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