ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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')
 
- 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

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

Member Function Documentation

◆ addFilterInputFieldToTable()

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

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

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().

118  {
119  $input = $table->addFilterItemByMetaType(
120  "filter_" . $this->getField()->getId(),
122  false,
123  $this->getField()->getId()
124  );
125  $ref_field_id = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
126  $ref_field = ilDclCache::getFieldCache((int) $ref_field_id);
127  $ref_table = ilDclCache::getTableCache($ref_field->getTableId());
128  $options = [];
129  foreach ($ref_table->getRecords() as $record) {
130  $options[$record->getId()] = $record->getRecordFieldPlainText($ref_field_id);
131  }
132  // Sort by values ASC
133  asort($options);
134  $options = ['' => $this->lng->txt('dcl_all_entries')]
135  + $options
136  + ['none' => $this->lng->txt('dcl_no_entry')];
137  $input->setOptions($options);
138 
139  $this->setupFilterInputField($input);
140 
141  return $this->getFilterInputFieldValue($input);
142  }
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.
static getTableCache(?int $table_id=null)
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
+ Here is the call graph for this function:

◆ buildFieldCreationInput()

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

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

References ilDclBaseFieldRepresentation\$field, ilSubEnabledFormPropertyGUI\addSubItem(), ilDclBaseFieldModel\getDatatypeId(), ilDclBaseFieldModel\getId(), ilObjDataCollection\getTables(), ilDclBaseFieldModel\getTitle(), ilDclDatatype\INPUTFORMAT_REFERENCE, ILIAS\Repository\lng(), ilDclBaseFieldModel\PROP_N_REFERENCE, ilDclBaseFieldModel\PROP_REFERENCE, ilDclBaseFieldModel\PROP_REFERENCE_LINK, ilFormPropertyGUI\setInfo(), and ilSelectInputGUI\setOptions().

165  : ilRadioOption
166  {
167  $opt = parent::buildFieldCreationInput($dcl, $mode);
168 
169  $options = [];
170  // Get Tables
171  $tables = $dcl->getTables();
172  foreach ($tables as $table) {
173  foreach ($table->getRecordFields() as $field) {
174  //referencing references may lead to endless loops.
176  $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
177  }
178  }
179  }
180  $prop_table_selection = new ilSelectInputGUI(
181  $this->lng->txt('dcl_reference_title'),
183  );
184  $prop_table_selection->setOptions($options);
185  $prop_table_selection->setInfo($this->lng->txt('dcl_reference_title_desc'));
186 
187  $opt->addSubItem($prop_table_selection);
188 
189  $prop_ref_link = new ilDclCheckboxInputGUI(
190  $this->lng->txt('dcl_reference_link'),
192  );
193  $prop_ref_link->setInfo($this->lng->txt('dcl_reference_link_info'));
194  $opt->addSubItem($prop_ref_link);
195 
196  $prop_multi_select = new ilDclCheckboxInputGUI(
197  $this->lng->txt('dcl_multiple_selection'),
199  );
200  $opt->addSubItem($prop_multi_select);
201 
202  return $opt;
203  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
setOptions(array $a_options)
getDatatypeId()
Get datatype_id.
+ 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

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

References $ref_id, ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ILIAS\Survey\Mode\getId(), ilDclCache\getTableCache(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), ilObject\getTitle(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ILIAS\FileDelivery\http(), ilDclDatatype\INPUTFORMAT_DATETIME, ilDclDatatype\INPUTFORMAT_FILEUPLOAD, 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().

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

◆ passThroughFilter()

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

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

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

147  : bool
148  {
149  $value = $record->getRecordFieldValue($this->getField()->getId());
150 
151  $pass = false;
152  if ($filter && $this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE) && is_array($value) && in_array(
153  $filter,
154  $value
155  )) {
156  $pass = true;
157  }
158  if (!$filter || $filter == $value) {
159  $pass = true;
160  }
161 
162  return $pass;
163  }
getRecordFieldValue(?string $field_id)
Get Field Value.
+ 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: