ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilDclSelectionFieldRepresentation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  // those should be overwritten by subclasses
24  public const PROP_SELECTION_TYPE = '';
25  public const PROP_SELECTION_OPTIONS = '';
26 
27  protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption
28  {
29  $opt = parent::buildFieldCreationInput($dcl, $mode);
30 
31  $selection_options = $this->buildOptionsInput();
32  $opt->addSubItem($selection_options);
33 
34  $selection_type = new ilRadioGroupInputGUI(
35  $this->lng->txt('dcl_selection_type'),
36  'prop_' . static::PROP_SELECTION_TYPE
37  );
38  $selection_type->setRequired(true);
39 
40  $options = [
44  ];
45 
46  foreach ($options as $option) {
47  $selection_type->addOption(new ilRadioOption($this->lng->txt('dcl_' . $option), $option));
48  }
49 
50  $opt->addSubItem($selection_type);
51 
52  return $opt;
53  }
54 
58  public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFormPropertyGUI
59  {
61  $options = ilDclSelectionOption::getAllForField((int) $this->getField()->getId());
62  switch ($this->getField()->getProperty(static::PROP_SELECTION_TYPE)) {
64  $input = new ilMultiSelectInputGUI(
65  $this->getField()->getTitle(),
66  'field_' . $this->getField()->getId()
67  );
68 
69  $input->setHeight(100);
70  $input->setHeightUnit('%; max-height: 150px');
71  $input->setWidth(100);
72  $input->setWidthUnit('%');
73 
74  $array = [];
75  foreach ($options as $opt) {
76  $array[$opt->getOptId()] = $opt->getValue();
77  }
78  $input->setOptions($array);
79  break;
81  $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
82  $array = [];
83  foreach ($options as $opt) {
84  $array[$opt->getOptId()] = $opt->getValue();
85  }
86  $input->setOptions(["" => $this->lng->txt('dcl_please_select')] + $array);
87  break;
89  default:
90  $input = new ilRadioGroupInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
91  foreach ($options as $opt) {
92  $input->addOption(new ilRadioOption($opt->getValue(), (string) $opt->getOptId()));
93  }
94  $input->setValue((string) array_keys($options)[0]);
95  break;
96  }
97  $this->setupInputField($input, $this->getField());
98 
99  return $input;
100  }
101 
106  public function addFilterInputFieldToTable(ilTable2GUI $table)
107  {
108  $input = $table->addFilterItemByMetaType(
109  "filter_" . $this->getField()->getId(),
111  false,
112  $this->getField()->getId()
113  );
114 
115  $options = ilDclSelectionOption::getAllForField((int) $this->getField()->getId());
116  $array = ['' => $this->lng->txt('dcl_all_entries')];
117  foreach ($options as $opt) {
118  $array[$opt->getOptId()] = $opt->getValue();
119  }
120 
121  $array['none'] = $this->lng->txt('dcl_no_entry');
122 
123  $input->setOptions($array);
124 
125  $this->setupFilterInputField($input);
126 
127  return $this->getFilterInputFieldValue($input);
128  }
129 
130  abstract protected function buildOptionsInput(): ilDclGenericMultiInputGUI;
131 }
This class represents an option in a radio group.
buildFieldCreationInput(ilObjDataCollection $dcl, string $mode='create')
This class represents a selection list property in a property form.
getInputField(ilPropertyFormGUI $form, ?int $record_id=null)
Returns field-input.
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class represents a multi selection list property in a property form.
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
This class represents a property in a property form.
static getAllForField(int $field_id)
setupFilterInputField(?ilTableFilterItem $input)
Set basic settings for filter-input-gui.
setRequired(bool $a_required)