ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDclReferenceFieldRepresentation Class Reference
+ 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
 
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)
Returns
string|array|null

Reimplemented from ilDclBaseFieldRepresentation.

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

121 {
122 $input = $table->addFilterItemByMetaType(
123 "filter_" . $this->getField()->getId(),
125 false,
126 $this->getField()->getId()
127 );
128 $ref_field_id = (int) $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
129 $ref_field = ilDclCache::getFieldCache($ref_field_id);
130 $ref_table = ilDclCache::getTableCache($ref_field->getTableId());
131 $options = [];
132 foreach ($ref_table->getRecords() as $record) {
133 $options[$record->getId()] = $record->getRecordField($ref_field_id)->getPlainText();
134 }
135 // Sort by values ASC
136 asort($options);
137 $options = ['' => $this->lng->txt('dcl_all_entries')]
138 + $options
139 + ['none' => $this->lng->txt('dcl_no_entry')];
140 $input->setOptions($options);
141
142 $this->setupFilterInputField($input);
143
144 return $this->getFilterInputFieldValue($input);
145 }
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
static getTableCache(?int $table_id=null)
static getFieldCache(int $field_id=0)
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\int(), 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 168 of file class.ilDclReferenceFieldRepresentation.php.

169 {
170 $opt = parent::buildFieldCreationInput($dcl, $mode);
171
172 $options = [];
173 // Get Tables
174 $tables = $dcl->getTables();
175 foreach ($tables as $table) {
176 foreach ($table->getRecordFields() as $field) {
177 //referencing references may lead to endless loops.
179 $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
180 }
181 }
182 }
183 $prop_table_selection = new ilSelectInputGUI(
184 $this->lng->txt('dcl_reference_title'),
186 );
187 $prop_table_selection->setOptions($options);
188 $prop_table_selection->setInfo($this->lng->txt('dcl_reference_title_desc'));
189
190 $opt->addSubItem($prop_table_selection);
191
192 $prop_ref_link = new ilDclCheckboxInputGUI(
193 $this->lng->txt('dcl_reference_link'),
195 );
196 $prop_ref_link->setInfo($this->lng->txt('dcl_reference_link_info'));
197 $opt->addSubItem($prop_ref_link);
198
199 $prop_multi_select = new ilDclCheckboxInputGUI(
200 $this->lng->txt('dcl_multiple_selection'),
202 );
203 $opt->addSubItem($prop_multi_select);
204
205 return $opt;
206 }
This class represents an option in a radio group.
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 30 of file class.ilDclReferenceFieldRepresentation.php.

31 {
32 if ($this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
33 $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
34 $input->setWidth(100);
35 $input->setWidthUnit('%');
36 } else {
37 $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
38 }
39
40 $this->setupInputField($input, $this->getField());
41
42 $options = [];
43 if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
44 $options[''] = $this->lng->txt('dcl_please_select');
45 }
46
47 $fieldref = (int) $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
48 $reffield = ilDclCache::getFieldCache($fieldref);
49 $reftable = ilDclCache::getTableCache($reffield->getTableId());
50 foreach ($reftable->getRecords() as $record) {
51 $record_field = $record->getRecordField($fieldref);
52 switch ($reffield->getDatatypeId()) {
54 if ($record_field->getValue()) {
55 $file_obj = new ilObjFile($record_field->getValue(), false);
56 $options[$record->getId()] = $file_obj->getFileName();
57 }
58 break;
60 $media_obj = new ilObjMediaObject($record_field->getValue());
61 $options[$record->getId()] = $media_obj->getTitle();
62 break;
64 $options[$record->getId()] = strtotime($record->getRecordFieldSingleHTML($fieldref));
65 $options2[$record->getId()] = $record->getRecordFieldSingleHTML($fieldref);
66 break;
68 $value = $record_field->getValue();
69 if ($record->getRecordField((int) $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 $value = $record_field->getValue();
79 $options[$record->getId()] = ilObject::_lookupTitle(ilObject::_lookupObjectId($value)) . ' [' . $value . ']';
80 break;
81 default:
82 $options[$record->getId()] = $record_field->getExportValue();
83 break;
84 }
85 }
86 asort($options, SORT_NATURAL | SORT_FLAG_CASE);
87
88 // TT #0019091: restore the actual values after sorting with timestamp
89 if ($reffield->getDatatypeId() === ilDclDatatype::INPUTFORMAT_DATE) {
90 foreach ($options as $key => $opt) {
91 if ($key != "" && isset($options2) && is_array($options2)) {
92 $options[$key] = $options2[$key];
93 }
94 }
95 // the option 'please select' messes with the order, therefore we reset it
96 unset($options[""]);
97 $options = ["" => $this->lng->txt('dcl_please_select')] + $options;
98 }
99
100 $input->setOptions($options);
101 if ($input instanceof ilMultiSelectInputGUI) {
102 $input->setHeight(32 * min(5, max(1, count($options))));
103 }
104
105
106 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
107
109 $input->addCustomAttribute('data-ref="1"');
110 $input->addCustomAttribute('data-ref-table-id="' . $reftable->getId() . '"');
111 $input->addCustomAttribute('data-ref-field-id="' . $reffield->getId() . '"');
112 }
113
114 return $input;
115 }
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
This class represents a property in a property form.
This class represents a multi selection list property in a property form.
static hasPermissionToAddRecord(int $ref_id, int $table_id)
Class ilObjFile.
static _lookupObjectId(int $ref_id)
static _lookupTitle(int $obj_id)
$ref_id
Definition: ltiauth.php:66
static http()
Fetches the global http state from ILIAS.

References $ref_id, ilObject\_lookupObjectId(), ilObject\_lookupTitle(), ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ILIAS\Survey\Mode\getId(), ilDclCache\getTableCache(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ILIAS\FileDelivery\http(), ilDclDatatype\INPUTFORMAT_DATE, ilDclDatatype\INPUTFORMAT_FILEUPLOAD, ilDclDatatype\INPUTFORMAT_ILIAS_REF, ilDclDatatype\INPUTFORMAT_MOB, ilDclDatatype\INPUTFORMAT_TEXT, ILIAS\Repository\int(), 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 150 of file class.ilDclReferenceFieldRepresentation.php.

150 : bool
151 {
152 $value = $record->getRecordFieldValue($this->getField()->getId());
153
154 $pass = false;
155 if ($filter && $this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE) && is_array($value) && in_array(
156 $filter,
157 $value
158 )) {
159 $pass = true;
160 }
161 if (!$filter || $filter == $value) {
162 $pass = true;
163 }
164
165 return $pass;
166 }
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: