ILIAS  release_8 Revision v8.24
ilDclReferenceFieldRepresentation Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilDclReferenceFieldRepresentation:
+ Collaboration diagram for ilDclReferenceFieldRepresentation:

Public Member Functions

 getInputField (ilPropertyFormGUI $form, ?int $record_id=null)
 
 addFilterInputFieldToTable (ilTable2GUI $table)
 
 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

 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
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ilComponentRepository $component_repository
 
ilComponentFactory $component_factory
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Member Function Documentation

◆ addFilterInputFieldToTable()

ilDclReferenceFieldRepresentation::addFilterInputFieldToTable ( ilTable2GUI  $table)
Returns
string|array|null

Reimplemented from ilDclBaseFieldRepresentation.

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

116 {
117 $input = $table->addFilterItemByMetaType(
118 "filter_" . $this->getField()->getId(),
120 false,
121 $this->getField()->getId()
122 );
123 $ref_field_id = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
124 $ref_field = ilDclCache::getFieldCache($ref_field_id);
125 $ref_table = ilDclCache::getTableCache($ref_field->getTableId());
126 $options = [];
127 foreach ($ref_table->getRecords() as $record) {
128 $options[$record->getId()] = $record->getRecordFieldPlainText($ref_field_id);
129 }
130 // Sort by values ASC
131 asort($options);
132 $options = ['' => $this->lng->txt('dcl_all_entries')]
133 + $options
134 + ['none' => $this->lng->txt('dcl_no_entry')];
135 $input->setOptions($options);
136
137 $this->setupFilterInputField($input);
138
139 return $this->getFilterInputFieldValue($input);
140 }
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
static getFieldCache(int $field_id=0)
static getTableCache(int $table_id=null)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.

References ilTable2GUI\addFilterItemByMetaType(), ilTable2GUI\FILTER_SELECT, ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ilDclBaseFieldRepresentation\getFilterInputFieldValue(), ILIAS\Survey\Mode\getId(), ilDclCache\getTableCache(), ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_REFERENCE, 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 163 of file class.ilDclReferenceFieldRepresentation.php.

164 {
165 $opt = parent::buildFieldCreationInput($dcl, $mode);
166
167 $options = [];
168 // Get Tables
169 $tables = $dcl->getTables();
170 foreach ($tables as $table) {
171 foreach ($table->getRecordFields() as $field) {
172 //referencing references may lead to endless loops.
174 $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
175 }
176 }
177 }
178 $prop_table_selection = new ilSelectInputGUI(
179 $this->lng->txt('dcl_reference_title'),
181 );
182 $prop_table_selection->setOptions($options);
183
184 $opt->addSubItem($prop_table_selection);
185
186 $prop_ref_link = new ilDclCheckboxInputGUI(
187 $this->lng->txt('dcl_reference_link'),
189 );
190 $prop_ref_link->setInfo($this->lng->txt('dcl_reference_link_info'));
191 $opt->addSubItem($prop_ref_link);
192
193 $prop_multi_select = new ilDclCheckboxInputGUI(
194 $this->lng->txt('dcl_multiple_selection'),
196 );
197 $opt->addSubItem($prop_multi_select);
198
199 return $opt;
200 }
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 selection list property in a property form.

References ilDclBaseFieldRepresentation\$field, 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 
)
Parameters
ilPropertyFormGUI$form
int | null$record_id
Returns
ilSelectInputGUI|ilMultiSelectInputGUI

Reimplemented from ilDclBaseFieldRepresentation.

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

29 {
30 if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
31 $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
32 } else {
33 $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
34 $input->setWidth(100);
35 $input->setWidthUnit('%');
36 }
37
38 $this->setupInputField($input, $this->getField());
39
40 $fieldref = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
41
42 $reffield = ilDclCache::getFieldCache($fieldref);
43 $options = [];
44 if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
45 $options[""] = $this->lng->txt('dcl_please_select');
46 }
47 $reftable = ilDclCache::getTableCache($reffield->getTableId());
48 foreach ($reftable->getRecords() as $record) {
49 // If the referenced field is MOB or FILE, we display the filename in the dropdown
50 switch ($reffield->getDatatypeId()) {
52 $field_value = $record->getRecordFieldValue($fieldref);
53 if ($field_value) {
54 $file_obj = new ilObjFile($field_value, false);
55 $options[$record->getId()] = $file_obj->getFileName();
56 }
57 break;
59 $media_obj = new ilObjMediaObject($record->getRecordFieldValue($fieldref));
60 $options[$record->getId()] = $media_obj->getTitle();
61 break;
63 $options[$record->getId()] = strtotime($record->getRecordFieldSingleHTML($fieldref));
64 // TT #0019091: options2 are the actual values, options the timestamp for sorting
65 $options2[$record->getId()] = $record->getRecordFieldSingleHTML($fieldref);
66 break;
68 $value = $record->getRecordFieldValue($fieldref);
69 if ($record->getRecordField($fieldref)->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
70 if (!is_array($value)) {
71 $value = ['title' => '', 'link' => $value];
72 }
73 $value = $value['title'] ?: $value['link'];
74 }
75 $options[$record->getId()] = $value;
76 break;
78 $options[$record->getId()] = $record->getRecordFieldRepresentationValue($fieldref);
79 break;
80 default:
81 $options[$record->getId()] = $record->getRecordFieldExportValue($fieldref);
82 break;
83 }
84 }
85 asort($options, SORT_NATURAL | SORT_FLAG_CASE);
86
87 // TT #0019091: restore the actual values after sorting with timestamp
88 if ($reffield->getDatatypeId() == ilDclDatatype::INPUTFORMAT_DATETIME) {
89 foreach ($options as $key => $opt) {
90 if ($key != "") {
91 $options[$key] = $options2[$key];
92 }
93 }
94 // the option 'please select' messes with the order, therefore we reset it
95 unset($options[""]);
96 $options = ["" => $this->lng->txt('dcl_please_select')] + $options;
97 }
98
99 $input->setOptions($options);
100
101 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
102
104 $input->addCustomAttribute('data-ref="1"');
105 $input->addCustomAttribute('data-ref-table-id="' . $reftable->getId() . '"');
106 $input->addCustomAttribute('data-ref-field-id="' . $reffield->getId() . '"');
107 }
108
109 return $input;
110 }
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
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...
static hasPermissionToAddRecord(int $ref_id, int $table_id)
Class ilObjFile.
$ref_id
Definition: ltiauth.php:67
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, $ref_id, ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ILIAS\Survey\Mode\getId(), ilDclCache\getTableCache(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ILIAS\FileDelivery\http(), ilDclDatatype\INPUTFORMAT_DATETIME, ilDclDatatype\INPUTFORMAT_FILE, ilDclDatatype\INPUTFORMAT_ILIAS_REF, ilDclDatatype\INPUTFORMAT_MOB, ilDclDatatype\INPUTFORMAT_TEXT, ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_N_REFERENCE, ilDclBaseFieldModel\PROP_REFERENCE, ilDclBaseFieldModel\PROP_URL, ILIAS\Repository\refinery(), and ilDclBaseFieldRepresentation\setupInputField().

+ Here is the call graph for this function:

◆ passThroughFilter()

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

Reimplemented from ilDclBaseFieldRepresentation.

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

145 : bool
146 {
147 $value = $record->getRecordFieldValue($this->getField()->getId());
148
149 $pass = false;
150 if ($filter && $this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE) && is_array($value) && in_array(
151 $filter,
152 $value
153 )) {
154 $pass = true;
155 }
156 if (!$filter || $filter == $value) {
157 $pass = true;
158 }
159
160 return $pass;
161 }
getRecordFieldValue(?int $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 21 of file class.ilDclReferenceFieldRepresentation.php.


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