ILIAS  release_8 Revision v8.24
class.ilDclCopyFieldRepresentation.php
Go to the documentation of this file.
1<?php
2
20{
21 private const VALID_TYPES = [
26 ];
27
31 public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFormPropertyGUI
32 {
33 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
34 $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
35 } else {
36 $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
37 }
38
39 $this->setupInputField($input, $this->getField());
40
41 $options = [];
42 if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
43 $options[''] = $this->lng->txt('dcl_please_select');
44 }
45
46 $value = null;
47 $copy_id = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
48 $copy_field = ilDclCache::getFieldCache($copy_id);
49 if ($copy_field->getTableId() !== 0) {
50 $copy_table = ilDclCache::getTableCache($copy_field->getTableId());
51 foreach ($copy_table->getRecords() as $record) {
52 $option = $record->getRecordField($copy_field->getId())->getPlainText();
53 if (!in_array($option, $options)) {
54 $options[$option] = $option;
55 }
56 }
57 } else {
58 $input->setAlert($this->lng->txt('dcl_origin_not_found'));
59 }
60
61 if ($record_id !== null) {
62 $value = ilDclCache::getRecordCache($record_id)->getRecordFieldValue($this->getField()->getId());
63 if ($value !== '' && !array_key_exists($value, $options)) {
64 $options[$value] = $value . ' ' . $this->lng->txt('dcl_deprecated_copy');
65 }
66 }
67
68 $input->setOptions($options);
69
70 return $input;
71 }
72
74 {
75 $input = $table->addFilterItemByMetaType(
76 "filter_" . $this->getField()->getId(),
78 false,
79 $this->getField()->getId()
80 );
81 $input->setSubmitFormOnEnter(true);
82
83 $this->setupFilterInputField($input);
84
85 return $this->getFilterInputFieldValue($input);
86 }
87
88 public function passThroughFilter(ilDclBaseRecordModel $record, $filter): bool
89 {
90 $pass = parent::passThroughFilter($record, $filter);
91
92 $value = $record->getRecordFieldValue($this->getField()->getId());
93 if (!$filter || strpos(strtolower($value), strtolower($filter)) !== false) {
94 $pass = true;
95 }
96
97 return $pass;
98 }
99
100 protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption
101 {
102 $datetype_title = $this->getField()->getPresentationTitle();
103 $opt = new ilRadioOption($this->getField()->getPresentationTitle(), $this->getField()->getDatatypeId());
104 $opt->setInfo($this->getField()->getPresentationDescription());
105
106 $options = [];
107 $tables = $dcl->getTables();
108 foreach ($tables as $table) {
109 foreach ($table->getRecordFields() as $field) {
110 if (in_array($field->getDatatypeId(), self::VALID_TYPES)) {
111 $options[$field->getId()] = $table->getTitle() . ' -> ' . $field->getTitle();
112 }
113 }
114 }
115
116 $prop_table_selection = new ilSelectInputGUI(
117 $this->lng->txt('dcl_copy_title'),
119 );
120 $prop_table_selection->setOptions($options);
121 $opt->addSubItem($prop_table_selection);
122
123 $prop_multi_select = new ilDclCheckboxInputGUI(
124 $this->lng->txt('dcl_multiple_selection'),
126 );
127 $opt->addSubItem($prop_multi_select);
128
129 return $opt;
130 }
131}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
getRecordFieldValue(?int $field_id)
Get Field Value.
static getRecordCache(?int $record_id)
static getFieldCache(int $field_id=0)
static getTableCache(int $table_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getInputField(ilPropertyFormGUI $form, ?int $record_id=null)
addFilterInputFieldToTable(ilTable2GUI $table)
Add filter input to TableGUI.
buildFieldCreationInput(ilObjDataCollection $dcl, string $mode='create')
Build the creation-input-field.
passThroughFilter(ilDclBaseRecordModel $record, $filter)
Checks if a filter affects a record.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.