ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDclReferenceFieldRepresentation Class Reference

Class ilDclTextFieldRepresentation. More...

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

Public Member Functions

 getInputField (ilPropertyFormGUI $form, $record_id=0)
 
 addFilterInputFieldToTable (ilTable2GUI $table)
 
 passThroughFilter (ilDclBaseRecordModel $record, $filter)
 
 buildFieldCreationInput (ilObjDataCollection $dcl, $mode='create')
 
- 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 ($value, $link=true)
 
 getInputField (ilPropertyFormGUI $form, $record_id=0)
 Returns field-input. More...
 
 addFieldCreationForm ($form, ilObjDataCollection $dcl, $mode="create")
 Adds the options for the field-types to the field-creation form. More...
 
 getPropertyInputFieldId ($property)
 Return post-var for property-fields. More...
 
 getField ()
 Return BaseFieldModel. More...
 

Data Fields

const REFERENCE_SEPARATOR = " -> "
 

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ addFilterInputFieldToTable()

ilDclReferenceFieldRepresentation::addFilterInputFieldToTable ( ilTable2GUI  $table)

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

References $options, ilTable2GUI\addFilterItemByMetaType(), array, ilTable2GUI\FILTER_SELECT, ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ilDclBaseFieldRepresentation\getFilterInputFieldValue(), ilDclCache\getTableCache(), ilDclBaseFieldModel\PROP_REFERENCE, and ilDclBaseFieldRepresentation\setupFilterInputField().

89  {
90  $input = $table->addFilterItemByMetaType("filter_" . $this->getField()->getId(), ilTable2GUI::FILTER_SELECT, false, $this->getField()->getId());
91  $ref_field_id = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
92  $ref_field = ilDclCache::getFieldCache($ref_field_id);
93  $ref_table = ilDclCache::getTableCache($ref_field->getTableId());
94  $options = array();
95  foreach ($ref_table->getRecords() as $record) {
96  $options[$record->getId()] = $record->getRecordFieldPlainText($ref_field_id);
97  }
98  // Sort by values ASC
99  asort($options);
100  $options = array('' => $this->lng->txt('dcl_any')) + $options;
101  $input->setOptions($options);
102 
103  $this->setupFilterInputField($input);
104 
105  return $this->getFilterInputFieldValue($input);
106  }
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
static getFieldCache($field_id=0)
static getTableCache($table_id=0)
if(!is_array($argv)) $options
setupFilterInputField(ilFormPropertyGUI $input)
Set basic settings for filter-input-gui.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ buildFieldCreationInput()

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

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

References ilDclBaseFieldRepresentation\$field, $options, ilSubEnabledFormPropertyGUI\addSubItem(), array, ilObjDataCollection\getTables(), ilDclDatatype\INPUTFORMAT_REFERENCE, ilFormPropertyGUI\setInfo(), and ilSelectInputGUI\setOptions().

126  {
127  $opt = parent::buildFieldCreationInput($dcl, $mode);
128 
129  $options = array();
130  // Get Tables
131  $tables = $dcl->getTables();
132  foreach ($tables as $table) {
133  foreach ($table->getRecordFields() as $field) {
134  //referencing references may lead to endless loops.
135  if ($field->getDatatypeId() != ilDclDatatype::INPUTFORMAT_REFERENCE) {
136  $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
137  }
138  }
139  }
140  $prop_table_selection = new ilSelectInputGUI($this->lng->txt('dcl_reference_title'), 'prop_' .ilDclBaseFieldModel::PROP_REFERENCE);
141  $prop_table_selection->setOptions($options);
142 
143  $opt->addSubItem($prop_table_selection);
144 
145  $prop_ref_link = new ilDclCheckboxInputGUI($this->lng->txt('dcl_reference_link'), 'prop_'.ilDclBaseFieldModel::PROP_REFERENCE_LINK);
146  $prop_ref_link->setInfo($this->lng->txt('dcl_reference_link_info'));
147  $opt->addSubItem($prop_ref_link);
148 
149  $prop_multi_select = new ilDclCheckboxInputGUI($this->lng->txt('dcl_multiple_selection'), 'prop_'.ilDclBaseFieldModel::PROP_N_REFERENCE);
150  $opt->addSubItem($prop_multi_select);
151 
152  return $opt;
153  }
This class represents a selection list property in a property form.
setInfo($a_info)
Set Information Text.
if(!is_array($argv)) $options
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
Class ilDclCheckboxInputGUI.
+ Here is the call graph for this function:

◆ getInputField()

ilDclReferenceFieldRepresentation::getInputField ( ilPropertyFormGUI  $form,
  $record_id = 0 
)

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

References $_GET, $options, array, ilDclBaseFieldRepresentation\getField(), ilDclCache\getFieldCache(), ilDclCache\getTableCache(), ilObject2\getTitle(), ilObjDataCollectionAccess\hasPermissionToAddRecord(), ilDclDatatype\INPUTFORMAT_DATETIME, ilDclDatatype\INPUTFORMAT_FILE, ilDclDatatype\INPUTFORMAT_ILIAS_REF, ilDclDatatype\INPUTFORMAT_MOB, ilDclDatatype\INPUTFORMAT_TEXT, ilDclBaseFieldModel\PROP_N_REFERENCE, ilDclBaseFieldModel\PROP_REFERENCE, ilDclBaseFieldModel\PROP_URL, and ilDclBaseFieldRepresentation\setupInputField().

13  {
14  if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
15  $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
16  } else {
17  $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
18  $input->setWidth(100);
19  $input->setWidthUnit('%');
20  }
21 
22  $this->setupInputField($input, $this->getField());
23 
24  $fieldref = $this->getField()->getProperty(ilDclBaseFieldModel::PROP_REFERENCE);
25 
26  $reffield = ilDclCache::getFieldCache($fieldref);
27  $options = array();
28  if (!$this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE)) {
29  $options[""] = $this->lng->txt('dcl_please_select');
30  }
31  $reftable = ilDclCache::getTableCache($reffield->getTableId());
32  foreach ($reftable->getRecords() as $record) {
33  // If the referenced field is MOB or FILE, we display the filename in the dropdown
34  switch ($reffield->getDatatypeId()) {
36  $file_obj = new ilObjFile($record->getRecordFieldValue($fieldref), false);
37  $options[$record->getId()] = $file_obj->getFileName();
38  break;
40  $media_obj = new ilObjMediaObject($record->getRecordFieldValue($fieldref), false);
41  $options[$record->getId()] = $media_obj->getTitle();
42  break;
44  $options[$record->getId()] = strtotime($record->getRecordFieldSingleHTML($fieldref));
45  // TT #0019091: options2 are the actual values, options the timestamp for sorting
46  $options2[$record->getId()] = $record->getRecordFieldSingleHTML($fieldref);
47  break;
49  $value = $record->getRecordFieldValue($fieldref);
50  if ($record->getRecordField($fieldref)->getField()->hasProperty(ilDclBaseFieldModel::PROP_URL)) {
51  if (!is_array($value)) {
52  $value = array('title' => '', 'link' => $value);
53  }
54  $value = $value['title'] ? $value['title'] : $value['link'];
55  }
56  $options[$record->getId()] = $value;
57  break;
59  $options[$record->getId()] = $record->getRecordFieldRepresentationValue($fieldref);
60  break;
61  default:
62  $options[$record->getId()] = $record->getRecordFieldValue($fieldref);
63  break;
64  }
65  }
66  asort($options);
67 
68  // TT #0019091: restore the actual values after sorting with timestamp
69  if ($reffield->getDatatypeId() == ilDclDatatype::INPUTFORMAT_DATETIME) {
70  foreach ($options as $key => $opt) {
71  $options[$key] = $options2[$key];
72  }
73  // the option 'please select' messes with the order, therefore we reset it
74  unset($options[""]);
75  $options = array("" => $this->lng->txt('dcl_please_select')) + $options;
76  }
77 
78  $input->setOptions($options);
79 
80  if (ilObjDataCollectionAccess::hasPermissionToAddRecord($_GET['ref_id'], $reftable->getId())) {
81  $input->addCustomAttribute('data-ref="1"');
82  $input->addCustomAttribute('data-ref-table-id="' . $reftable->getId() . '"');
83  $input->addCustomAttribute('data-ref-field-id="' . $reffield->getId() . '"');
84  }
85 
86  return $input;
87  }
This class represents a selection list property in a property form.
static hasPermissionToAddRecord($ref_id, $table_id)
$_GET["client_id"]
static getFieldCache($field_id=0)
static getTableCache($table_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.
if(!is_array($argv)) $options
Class ilObjFile.
Class ilObjMediaObject.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ passThroughFilter()

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

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

References $pass, ilDclBaseFieldRepresentation\getField(), ilDclBaseRecordModel\getRecordFieldValue(), and ilDclBaseFieldModel\PROP_N_REFERENCE.

109  {
110  $value = $record->getRecordFieldValue($this->getField()->getId());
111 
112  $pass = false;
113  if ($filter && $this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE) && is_array($value) && in_array($filter, $value)) {
114  $pass = true;
115  }
116  if (!$filter || $filter == $value) {
117  $pass = true;
118  }
119 
120  return $pass;
121  }
getRecordFieldValue($field_id)
Get Field Value.
+ Here is the call graph for this function:

Field Documentation

◆ REFERENCE_SEPARATOR

const ilDclReferenceFieldRepresentation::REFERENCE_SEPARATOR = " -> "

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


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