3 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionField.php");
4 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionDatatype.php");
5 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
6 require_once
"class.ilDataCollectionCache.php";
7 require_once(
'./Services/Form/classes/class.ilNonEditableValueGUI.php');
62 $this->obj_id = $a_parent_obj->obj_id;
63 $this->parent_obj = $a_parent_obj;
69 if (!isset($field_id)) {
70 $this->field_id =
$_GET[
'field_id'];
73 if (isset($field_id)) {
78 $ilCtrl->redirectByClass(
"ilDataCollectionGUI",
"listFields");
81 $ilCtrl->saveParameter($this,
"table_id");
94 $cmd = $ilCtrl->getCmd();
96 if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
104 $this->
save(
"update");
122 $tpl->setContent($this->form->getHTML());
135 $tpl->setContent($this->form->getHTML());
144 $tpl->setContent(
"Permission denied");
154 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
156 $conf->setFormAction($ilCtrl->getFormAction($this));
157 $conf->setHeaderText($lng->txt(
'dcl_confirm_delete_field'));
159 $conf->addItem(
'field_id', (
int)$this->field_obj->getId(), $this->field_obj->getTitle());
161 $conf->setConfirm($lng->txt(
'delete'),
'delete');
162 $conf->setCancel($lng->txt(
'cancel'),
'cancelDelete');
164 $tpl->setContent($conf->getHTML());
174 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
181 public function delete() {
184 $this->table->deleteField($this->field_obj->getId());
185 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
194 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
206 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
209 if ($a_mode ==
"edit") {
210 $this->form->setTitle($lng->txt(
'dcl_edit_field'));
212 $this->form->addItem($hidden_prop);
214 $this->form->setFormAction($ilCtrl->getFormAction($this),
"update");
216 $this->form->addCommandButton(
'update', $lng->txt(
'dcl_update_field'));
218 $this->form->setTitle($lng->txt(
'dcl_new_field'));
220 $hidden_prop->setValue($this->field_obj->getTableId());
221 $this->form->addItem($hidden_prop);
223 $this->form->setFormAction($ilCtrl->getFormAction($this),
"save");
225 $this->form->addCommandButton(
'save', $lng->txt(
'dcl_create_field'));
227 $this->form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
233 $this->form->addItem($text_prop);
237 $opt =
new ilRadioOption($lng->txt(
'dcl_' . $datatype[
'title']), $datatype[
'id']);
246 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
247 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
248 foreach ($tables as
$table) {
249 foreach ($table->getRecordFields() as $field) {
252 $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
257 $table_selection->setOptions(
$options);
259 $opt->addSubItem($table_selection);
265 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
266 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
267 foreach ($tables as
$table) {
268 foreach ($table->getRecordFields() as $field) {
271 $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
276 $table_selection->setOptions(
$options);
277 $opt->addSubItem($table_selection);
281 foreach (
$table->getFieldsForFormula() as $f) {
282 $placeholder = ($f->isStandardField()) ? $f->getId() : $f->getTitle();
283 $fields[] =
'<a class="dclPropExpressionField" data-placeholder="' . $placeholder .
'">' . $f->getTitle() .
'</a>';
285 $subitem =
new ilTextAreaInputGUI($lng->txt(
'dcl_prop_expression'),
'prop_' . $property[
'id']);
288 $subitem->setInfo(sprintf($lng->txt(
'dcl_prop_expression_info'), $operators, $functions, implode(
'<br>', $fields)));
289 $opt->addSubItem($subitem);
290 } elseif ($property[
'datatype_id'] == $datatype[
'id']) {
293 $subitem =
new ilCheckboxInputGUI($lng->txt(
'dcl_' . $property[
'title']),
'prop_' . $property[
'id']);
296 $subitem =
new ilNumberInputGUI($lng->txt(
'dcl_' . $property[
'title']),
'prop_' . $property[
'id']);
303 if ($property[
'title'] ==
'length') {
304 $subitem->setMaxValue(4000);
305 $subitem->setInfo($lng->txt(
'dcl_'.$property[
'title'].
'_info'));
307 $opt->addSubItem($subitem);
311 $opt->addSubItem($subitem);
313 $subitem =
new ilTextInputGUI($lng->txt(
'dcl_' . $property[
'title']),
'prop_' . $property[
'id']);
318 if($property[
'title'] ==
'regex') {
319 $subitem->
setInfo($lng->txt(
'dcl_'.$property[
'title'].
'_info'));
321 $opt->addSubItem($subitem);
326 $edit_datatype->addOption($opt);
328 $edit_datatype->setRequired(
true);
331 if ($a_mode ==
"edit") {
332 $edit_datatype->setDisabled(
true);
334 $this->form->addItem($edit_datatype);
337 $text_prop =
new ilTextAreaInputGUI($lng->txt(
"dcl_field_description"),
"description");
338 $this->form->addItem($text_prop);
342 $this->form->addItem($cb);
346 $this->form->addItem($cb);
356 'table_id' => $this->field_obj->getTableId(),
357 'field_id' => $this->field_obj->getId(),
358 'title' => $this->field_obj->getTitle(),
359 'datatype' => $this->field_obj->getDatatypeId(),
360 'description' => $this->field_obj->getDescription(),
361 'required' => $this->field_obj->getRequired(),
362 'unique' => $this->field_obj->isUnique(),
365 $propertyvalues = $this->field_obj->getPropertyvalues();
370 $values[
'prop_' . $property[
'id']] = $propertyvalues[$property[
'id']];
374 $this->form->setValuesByArray($values);
385 public function save($a_mode =
"create") {
389 if (!$this->table->hasPermissionToFields($this->parent_obj->ref_id)) {
395 $this->
initForm($a_mode ==
"update" ?
"edit" :
"create");
397 $title = $this->form->getInput(
"title");
398 if ($a_mode !=
"create" && $title != $this->field_obj->getTitle()) {
402 $this->field_obj->setTitle($title);
403 $this->field_obj->setDescription($this->form->getInput(
"description"));
404 $this->field_obj->setDatatypeId($this->form->getInput(
"datatype"));
405 $this->field_obj->setRequired($this->form->getInput(
"required"));
406 $this->field_obj->setUnique($this->form->getInput(
"unique"));
408 if ($a_mode ==
"update") {
409 $this->field_obj->doUpdate();
411 $this->field_obj->setVisible(
true);
412 $this->field_obj->setOrder($this->table->getNewOrder());
413 $this->field_obj->doCreate();
417 include_once(
"./Modules/DataCollection/classes/class.ilDataCollectionFieldProp.php");
420 $fieldprop_obj->setDatatypePropertyId($property[
'id']);
421 $fieldprop_obj->setFieldId($this->field_obj->getId());
422 $fieldprop_obj->setValue($this->form->getInput(
"prop_" . $property[
'id']));
424 if ($a_mode ==
"update") {
425 $fieldprop_obj->doUpdate();
427 $fieldprop_obj->doCreate();
431 $ilCtrl->setParameter($this,
"field_id", $this->field_obj->getId());
433 if ($a_mode ==
"update") {
436 $this->table->addField($this->field_obj);
437 $this->table->buildOrderFields();
440 $ilCtrl->redirectByClass(strtolower(
"ilDataCollectionFieldListGUI"),
"listFields");
442 $this->form->setValuesByPost();
443 $tpl->setContent($this->form->getHTML());
457 $return = $this->form->checkInput();
465 $inputObj->setAlert($lng->txt(
"form_msg_value_too_high"));
470 if ($a_mode ==
'create') {
471 if ($title = $this->form->getInput(
'title')) {
473 $inputObj = $this->form->getItemByPostVar(
'title');
474 $inputObj->setAlert($lng->txt(
"dcl_field_title_unique"));
493 $tpl->setContent(
"Access Denied");