ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilDclReferenceFieldRepresentation Class Reference
+ Inheritance diagram for ilDclReferenceFieldRepresentation:
+ Collaboration diagram for ilDclReferenceFieldRepresentation:

Public Member Functions

 getInputField (ilPropertyFormGUI $form, ?int $record_id=null)
 Returns field-input. More...
 
 addFilterInputFieldToTable (ilTable2GUI $table)
 Add filter input to TableGUI. More...
 
 passThroughFilter (ilDclBaseRecordModel $record, $filter)
 
- Public Member Functions inherited from ilDclBaseFieldRepresentation
 __construct (ilDclBaseFieldModel $field)
 
 addFilterInputFieldToTable (ilTable2GUI $table)
 Add filter input to TableGUI. More...
 
 passThroughFilter (ilDclBaseRecordModel $record, $filter)
 Checks if a filter affects a record. More...
 
 parseSortingValue (string $value, bool $link=true)
 
 getInputField (ilPropertyFormGUI $form, ?int $record_id=null)
 Returns field-input. More...
 
 addFieldCreationForm (ilSubEnabledFormPropertyGUI $form, ilObjDataCollection $dcl, string $mode="create")
 Adds the options for the field-types to the field-creation form. More...
 
 getPropertyInputFieldId (string $property)
 Return post-var for property-fields. More...
 
 getField ()
 Return BaseFieldModel. More...
 

Data Fields

const REFERENCE_SEPARATOR = " -> "
 

Protected Member Functions

 getSortedRecords ()
 
 buildFieldCreationInput (ilObjDataCollection $dcl, string $mode='create')
 Build the creation-input-field. More...
 
- Protected Member Functions inherited from ilDclBaseFieldRepresentation
 setupFilterInputField (?ilTableFilterItem $input)
 Set basic settings for filter-input-gui. More...
 
 setupInputField (ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
 Sets basic settings on field-input. More...
 
 getFilterInputFieldValue (ilTableFilterItem $input)
 
 buildFieldCreationInput (ilObjDataCollection $dcl, string $mode='create')
 Build the creation-input-field. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilDclBaseFieldRepresentation
ilDclBaseFieldModel $field
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilObjUser $user
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ilComponentRepository $component_repository
 
ilComponentFactory $component_factory
 

Detailed Description

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

Member Function Documentation

◆ addFilterInputFieldToTable()

ilDclReferenceFieldRepresentation::addFilterInputFieldToTable ( ilTable2GUI  $table)

Add filter input to TableGUI.

Parameters
ilTable2GUI$table
Returns
null

Reimplemented from ilDclBaseFieldRepresentation.

Definition at line 60 of file class.ilDclReferenceFieldRepresentation.php.

60 : array|string|null
61 {
62 $input = $table->addFilterItemByMetaType(
63 "filter_" . $this->getField()->getId(),
65 false,
66 $this->getField()->getId()
67 );
68 $options = ['' => $this->lng->txt('dcl_all_entries')]
69 + $this->getSortedRecords()
70 + ['none' => $this->lng->txt('dcl_no_entry')];
71 $input->setOptions($options);
72
73 $this->setupFilterInputField($input);
74
75 return $this->getFilterInputFieldValue($input);
76 }
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.

References ILIAS\UI\Implementation\Component\Input\Field\$options, ilTable2GUI\addFilterItemByMetaType(), ilTable2GUI\FILTER_SELECT, ilDclBaseFieldRepresentation\getField(), ilDclBaseFieldRepresentation\getFilterInputFieldValue(), ILIAS\Survey\Mode\getId(), getSortedRecords(), ILIAS\Repository\lng(), and ilDclBaseFieldRepresentation\setupFilterInputField().

+ Here is the call graph for this function:

◆ buildFieldCreationInput()

ilDclReferenceFieldRepresentation::buildFieldCreationInput ( ilObjDataCollection  $dcl,
string  $mode = 'create' 
)
protected

Build the creation-input-field.

Reimplemented from ilDclBaseFieldRepresentation.

Definition at line 154 of file class.ilDclReferenceFieldRepresentation.php.

155 {
156 $opt = parent::buildFieldCreationInput($dcl, $mode);
157
158 $options = [];
159 // Get Tables
160 $tables = $dcl->getTables();
161 foreach ($tables as $table) {
162 foreach ($table->getRecordFields() as $field) {
163 //referencing references may lead to endless loops.
165 $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
166 }
167 }
168 }
169 $prop_table_selection = new ilSelectInputGUI(
170 $this->lng->txt('dcl_reference_title'),
172 );
173 $prop_table_selection->setOptions($options);
174 $prop_table_selection->setInfo($this->lng->txt('dcl_reference_title_desc'));
175
176 $opt->addSubItem($prop_table_selection);
177
178 $prop_ref_link = new ilDclCheckboxInputGUI(
179 $this->lng->txt('dcl_reference_link'),
181 );
182 $prop_ref_link->setInfo($this->lng->txt('dcl_reference_link_info'));
183 $opt->addSubItem($prop_ref_link);
184
185 $prop_multi_select = new ilDclCheckboxInputGUI(
186 $this->lng->txt('dcl_multiple_selection'),
188 );
189 $opt->addSubItem($prop_multi_select);
190
191 return $opt;
192 }
This class represents an option in a radio group.
This class represents a selection list property in a property form.

References ilDclBaseFieldRepresentation\$field, ILIAS\UI\Implementation\Component\Input\Field\$options, ilDclBaseFieldModel\getDatatypeId(), ilDclBaseFieldModel\getId(), ilObjDataCollection\getTables(), ilDclBaseFieldModel\getTitle(), ilDclDatatype\INPUTFORMAT_REFERENCE, ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_N_REFERENCE, ilDclBaseFieldModel\PROP_REFERENCE, and ilDclBaseFieldModel\PROP_REFERENCE_LINK.

+ Here is the call graph for this function:

◆ getInputField()

ilDclReferenceFieldRepresentation::getInputField ( ilPropertyFormGUI  $form,
?int  $record_id = null 
)

Returns field-input.

Reimplemented from ilDclBaseFieldRepresentation.

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

26 {
27 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
28 $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
29 $input->setWidth(100);
30 $input->setWidthUnit('%');
31 } else {
32 $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
33 }
34
35 $this->setupInputField($input, $this->getField());
36
37 $options = $this->getSortedRecords();
38 if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
39 $options = ['' => $this->lng->txt('dcl_please_select')] + $options;
40 }
41
42 $input->setOptions($options);
43 if ($input instanceof ilMultiSelectInputGUI) {
44 $input->setHeight(32 * min(5, max(1, count($options))));
45 }
46
47 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
48
49 $fieldref = (int) $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
50 $reffield = ilDclCache::getFieldCache($fieldref);
52 $input->addCustomAttribute('data-ref="1"');
53 $input->addCustomAttribute('data-ref-table-id="' . $reffield->getTableId() . '"');
54 $input->addCustomAttribute('data-ref-field-id="' . $reffield->getId() . '"');
55 }
56
57 return $input;
58 }
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
static getFieldCache(int $field_id=0)
This class represents a multi selection list property in a property form.
static hasPermissionToAddRecord(int $ref_id, int $table_id)
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.

References ILIAS\UI\Implementation\Component\Input\Field\$options, $ref_id, ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ILIAS\Survey\Mode\getId(), getSortedRecords(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_N_REFERENCE, ilDclBaseFieldModel\PROP_REFERENCE, ILIAS\Repository\refinery(), and ilDclBaseFieldRepresentation\setupInputField().

+ Here is the call graph for this function:

◆ getSortedRecords()

ilDclReferenceFieldRepresentation::getSortedRecords ( )
protected

Definition at line 78 of file class.ilDclReferenceFieldRepresentation.php.

78 : array
79 {
80 $options = [];
81 $fieldref = (int) $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
82 $reffield = ilDclCache::getFieldCache($fieldref);
83 $reftable = ilDclCache::getTableCache($reffield->getTableId());
84 foreach ($reftable->getRecords() as $record) {
85 $record_field = $record->getRecordField($fieldref);
86 switch ($reffield->getDatatypeId()) {
88 if ($record_field->getValue()) {
89 $file_obj = new ilObjFile($record_field->getValue(), false);
90 $options[$record->getId()] = $file_obj->getFileName();
91 }
92 break;
94 $media_obj = new ilObjMediaObject($record_field->getValue());
95 $options[$record->getId()] = $media_obj->getTitle();
96 break;
98 $options[$record->getId()] = strtotime($record->getRecordField($fieldref)->getPlainText());
99 $options2[$record->getId()] = $record->getRecordField($fieldref)->getPlainText();
100 break;
102 $value = $record_field->getValue();
103 if ($record->getRecordField((int) $fieldref)->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
104 if (!is_array($value)) {
105 $value = ['title' => '', 'link' => $value];
106 }
107 $value = $value['title'] ?: $value['link'];
108 }
109 $options[$record->getId()] = $value;
110 break;
112 $value = $record_field->getValue();
113 $options[$record->getId()] = ilObject::_lookupTitle(ilObject::_lookupObjectId($value)) . ' [' . $value . ']';
114 break;
115 default:
116 $options[$record->getId()] = $record_field->getExportValue();
117 break;
118 }
119 }
120 asort($options, SORT_NATURAL | SORT_FLAG_CASE);
121
122 if ($reffield->getDatatypeId() === ilDclDatatype::INPUTFORMAT_DATE) {
123 foreach ($options as $key => $opt) {
124 if ($key != "" && isset($options2) && is_array($options2)) {
125 $options[$key] = $options2[$key];
126 }
127 }
128 }
129
130 return $options;
131 }
static getTableCache(?int $table_id=null)
Class ilObjFile.
static _lookupObjectId(int $ref_id)
static _lookupTitle(int $obj_id)

References ILIAS\UI\Implementation\Component\Input\Field\$options, ilObject\_lookupObjectId(), ilObject\_lookupTitle(), ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ilDclCache\getTableCache(), ilDclDatatype\INPUTFORMAT_DATE, ilDclDatatype\INPUTFORMAT_FILEUPLOAD, ilDclDatatype\INPUTFORMAT_ILIAS_REF, ilDclDatatype\INPUTFORMAT_MOB, ilDclDatatype\INPUTFORMAT_TEXT, ILIAS\Repository\int(), ilDclBaseFieldModel\PROP_REFERENCE, and ilDclBaseFieldModel\PROP_URL.

Referenced by addFilterInputFieldToTable(), and getInputField().

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

◆ passThroughFilter()

ilDclReferenceFieldRepresentation::passThroughFilter ( ilDclBaseRecordModel  $record,
  $filter 
)
Parameters
int$filter

Reimplemented from ilDclBaseFieldRepresentation.

Definition at line 136 of file class.ilDclReferenceFieldRepresentation.php.

136 : bool
137 {
138 $value = $record->getRecordFieldValue($this->getField()->getId());
139
140 $pass = false;
141 if ($filter && $this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE) && is_array($value) && in_array(
142 $filter,
143 $value
144 )) {
145 $pass = true;
146 }
147 if (!$filter || $filter == $value) {
148 $pass = true;
149 }
150
151 return $pass;
152 }
getRecordFieldValue(?string $field_id)
Get Field Value.

References ilDclBaseFieldRepresentation\getField(), ILIAS\Survey\Mode\getId(), ilDclBaseRecordModel\getRecordFieldValue(), and ilDclBaseFieldModel\PROP_N_REFERENCE.

+ Here is the call graph for this function:

Field Documentation

◆ REFERENCE_SEPARATOR

const ilDclReferenceFieldRepresentation::REFERENCE_SEPARATOR = " -> "

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


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