3 require_once(
"./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseFieldModel.php");
4 require_once(
"./Modules/DataCollection/classes/Fields/Base/class.ilDclDatatype.php");
5 require_once(
"./Modules/DataCollection/classes/Table/class.ilDclTable.php");
6 require_once(
"./Modules/DataCollection/classes/Helpers/class.ilDclCache.php");
7 require_once(
'./Services/Form/classes/class.ilNonEditableValueGUI.php');
8 require_once(
"./Modules/DataCollection/classes/Fields/Base/class.ilDclFieldProperty.php");
9 require_once(
'./Modules/DataCollection/classes/Fields/Plugin/class.ilDclFieldTypePlugin.php');
66 $this->obj_id = $a_parent_obj->obj_id;
67 $this->parent_obj = $a_parent_obj;
69 $this->table_id =
$_GET[
"table_id"];
70 $this->field_id =
$_GET[
'field_id'];
72 if ($this->field_id) {
77 $datatype =
$_POST[
'datatype'];
80 if (!$this->table_id) {
81 $ilCtrl->redirectByClass(
"ilDclTableListGUI",
"listFields");
83 $this->field_obj->setTableId($this->table_id);
84 $ilCtrl->saveParameter($this,
"table_id");
97 $ilCtrl->saveParameter($this,
'field_id');
109 $this->
save(
"update");
128 $tpl->setContent($this->form->getHTML());
142 $tpl->setContent($this->form->getHTML());
152 $tpl->setContent(
"Permission denied");
165 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
167 $conf->setFormAction(
$ilCtrl->getFormAction($this));
168 $conf->setHeaderText(
$lng->txt(
'dcl_confirm_delete_field'));
170 $conf->addItem(
'field_id', (
int)$this->field_obj->getId(), $this->field_obj->getTitle());
172 $conf->setConfirm(
$lng->txt(
'delete'),
'delete');
173 $conf->setCancel(
$lng->txt(
'cancel'),
'cancelDelete');
175 $tpl->setContent($conf->getHTML());
186 $ilCtrl->redirectByClass(
"ildclfieldlistgui",
"listFields");
193 public function delete() {
197 $this->table->deleteField($this->field_obj->getId());
198 $ilCtrl->redirectByClass(
"ildclfieldlistgui",
"listFields");
208 $ilCtrl->redirectByClass(
"ildclfieldlistgui",
"listFields");
222 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
225 if ($a_mode ==
"edit") {
226 $this->form->setTitle(
$lng->txt(
'dcl_edit_field'));
228 $this->form->addItem($hidden_prop);
230 $this->form->setFormAction(
$ilCtrl->getFormAction($this),
"update");
232 $this->form->addCommandButton(
'update',
$lng->txt(
'dcl_update_field'));
234 $this->form->setTitle(
$lng->txt(
'dcl_new_field'));
236 $hidden_prop->setValue($this->field_obj->getTableId());
237 $this->form->addItem($hidden_prop);
239 $this->form->setFormAction(
$ilCtrl->getFormAction($this),
"save");
241 $this->form->addCommandButton(
'save',
$lng->txt(
'dcl_create_field'));
243 $this->form->addCommandButton(
'cancel',
$lng->txt(
'cancel'));
249 $this->form->addItem($text_prop);
253 $this->form->addItem($text_prop);
259 $model->setDatatypeId($datatype->getId());
261 if($a_mode ==
'edit' && $datatype->getId() == $this->field_obj->getDatatypeId()) {
268 $edit_datatype->setRequired(
true);
271 if ($a_mode ==
"edit") {
272 $edit_datatype->setDisabled(
true);
274 $this->form->addItem($edit_datatype);
278 $this->form->addItem($cb);
283 $this->form->addItem($cb);
293 'table_id' => $this->field_obj->getTableId(),
294 'field_id' => $this->field_obj->getId(),
295 'title' => $this->field_obj->getTitle(),
296 'datatype' => $this->field_obj->getDatatypeId(),
297 'description' => $this->field_obj->getDescription(),
298 'required' => $this->field_obj->getRequired(),
299 'unique' => $this->field_obj->isUnique(),
302 $properties = $this->field_obj->getValidFieldProperties();
303 foreach ($properties as $prop) {
304 $values[
'prop_' . $prop] = $this->field_obj->getProperty($prop);
307 $this->form->setValuesByArray($values);
318 public function save($a_mode =
"create") {
324 $this->
initForm($a_mode ==
"update" ?
"edit" :
"create");
327 $title = $this->form->getInput(
"title");
328 if ($a_mode !=
"create" &&
$title != $this->field_obj->getTitle()) {
332 $this->field_obj->setTitle(
$title);
333 $this->field_obj->setDescription($this->form->getInput(
"description"));
334 $this->field_obj->setDatatypeId($this->form->getInput(
"datatype"));
335 $this->field_obj->setRequired($this->form->getInput(
"required"));
336 $this->field_obj->setUnique($this->form->getInput(
"unique"));
338 if ($a_mode ==
"update") {
339 $this->field_obj->doUpdate();
341 $this->field_obj->setOrder($this->table->getNewFieldOrder());
342 $this->field_obj->doCreate();
346 $field_props = $this->field_obj->getValidFieldProperties();
347 foreach ($field_props as $property) {
349 $value = $this->form->getInput($representation->getPropertyInputFieldId($property));
353 $this->field_obj->setProperty($property, $value)->store();
357 $ilCtrl->setParameter($this,
"field_id", $this->field_obj->getId());
359 if ($a_mode ==
"update") {
362 $this->table->addField($this->field_obj);
363 $this->table->buildOrderFields();
366 $ilCtrl->redirectByClass(strtolower(
"ilDclFieldListGUI"),
"listFields");
368 $this->form->setValuesByPost();
369 $tpl->setContent($this->form->getHTML());
384 $return = $this->form->checkInput();
387 $datatype_id = $this->form->getInput(
'datatype');
388 if($datatype_id != null && is_numeric($datatype_id)) {
390 $base_model->setDatatypeId($datatype_id);
393 if(!$field_validation_class->checkFieldCreationInput($this->form)) {
399 if ($a_mode ==
'create') {
400 if (
$title = $this->form->getInput(
'title')) {
402 $inputObj = $this->form->getItemByPostVar(
'title');
403 $inputObj->setAlert(
$lng->txt(
"dcl_field_title_unique"));
421 if ($field_id = $this->field_obj->getId()) {
432 return $this->parent_obj->getDataCollectionObject();
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getDataCollectionObject()
Class ilDclBaseFieldModel.
confirmDelete()
confirmDelete
static _getTitleInvalidChars($a_as_regex=true)
All valid chars for filed titles.
static getAllDatatype()
Get all possible Datatypes.
static _hasFieldByTitle($title, $obj_id)
Checks if a table has a field with the given title.
static getFieldCache($field_id=0)
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
Returns FieldRepresentation from BaseFieldModel.
edit()
create field edit form
const PROP_PLUGIN_HOOK_NAME
create()
create field add form
getValues()
getFieldValues
static getTableCache($table_id=0)
save($a_mode="create")
save Field
initForm($a_mode="create")
initEditCustomForm
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct(ilDclTableListGUI $a_parent_obj)
Constructor.
executeCommand()
execute command
static getFieldModelInstance($field_id, $datatype=null)
Get FieldModel from field-id and datatype.
static hasAccessToFields($ref_id, $table_id)
This class represents a text property in a property form.
checkInput($a_mode)
Check input of form.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
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...
cancelDelete()
cancelDelete
This class represents a text area property in a property form.
static hasAccessToField($ref_id, $table_id, $field_id)
Confirmation screen class.