ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 90 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().

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

◆ buildFieldCreationInput()

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

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

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

130  {
131  $opt = parent::buildFieldCreationInput($dcl, $mode);
132 
133  $options = array();
134  // Get Tables
135  $tables = $dcl->getTables();
136  foreach ($tables as $table) {
137  foreach ($table->getRecordFields() as $field) {
138  //referencing references may lead to endless loops.
139  if ($field->getDatatypeId() != ilDclDatatype::INPUTFORMAT_REFERENCE) {
140  $options[$field->getId()] = $table->getTitle() . self::REFERENCE_SEPARATOR . $field->getTitle();
141  }
142  }
143  }
144  $prop_table_selection = new ilSelectInputGUI($this->lng->txt('dcl_reference_title'), 'prop_' . ilDclBaseFieldModel::PROP_REFERENCE);
145  $prop_table_selection->setOptions($options);
146 
147  $opt->addSubItem($prop_table_selection);
148 
149  $prop_ref_link = new ilDclCheckboxInputGUI($this->lng->txt('dcl_reference_link'), 'prop_' . ilDclBaseFieldModel::PROP_REFERENCE_LINK);
150  $prop_ref_link->setInfo($this->lng->txt('dcl_reference_link_info'));
151  $opt->addSubItem($prop_ref_link);
152 
153  $prop_multi_select = new ilDclCheckboxInputGUI($this->lng->txt('dcl_multiple_selection'), 'prop_' . ilDclBaseFieldModel::PROP_N_REFERENCE);
154  $opt->addSubItem($prop_multi_select);
155 
156  return $opt;
157  }
This class represents a selection list property in a property form.
setInfo($a_info)
Set Information Text.
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
Class ilDclCheckboxInputGUI.
if(empty($password)) $table
Definition: pwgen.php:24
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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, $key, $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().

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

◆ passThroughFilter()

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

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

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

112  {
113  $value = $record->getRecordFieldValue($this->getField()->getId());
114 
115  $pass = false;
116  if ($filter && $this->getField()->getProperty(ilDclBaseFieldModel::PROP_N_REFERENCE) && is_array($value) && in_array($filter, $value)) {
117  $pass = true;
118  }
119  if (!$filter || $filter == $value) {
120  $pass = true;
121  }
122 
123  return $pass;
124  }
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: