ILIAS  release_8 Revision v8.23
class.ilDclSelectionFieldRepresentation.php
Go to the documentation of this file.
1 <?php
2 
20 {
21  // those should be overwritten by subclasses
22  public const PROP_SELECTION_TYPE = '';
23  public const PROP_SELECTION_OPTIONS = '';
24 
25  protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ilRadioOption
26  {
27  $opt = parent::buildFieldCreationInput($dcl, $mode);
28 
29  $selection_options = $this->buildOptionsInput();
30  $opt->addSubItem($selection_options);
31 
32  $selection_type = new ilRadioGroupInputGUI(
33  $this->lng->txt('dcl_selection_type'),
34  'prop_' . static::PROP_SELECTION_TYPE
35  );
36  $selection_type->setRequired(true);
37 
38  $option_1 = new ilRadioOption(
41  );
42  $selection_type->addOption($option_1);
43 
44  $option_2 = new ilRadioOption(
47  );
48  $selection_type->addOption($option_2);
49 
50  $option_3 = new ilRadioOption(
53  );
54  $selection_type->addOption($option_3);
55 
56  $opt->addSubItem($selection_type);
57 
58  return $opt;
59  }
60 
64  public function getInputField(ilPropertyFormGUI $form, ?int $record_id = null): ilFormPropertyGUI
65  {
67  $options = ilDclSelectionOption::getAllForField($this->getField()->getId());
68  switch ($this->getField()->getProperty(static::PROP_SELECTION_TYPE)) {
70  $input = new ilMultiSelectInputGUI(
71  $this->getField()->getTitle(),
72  'field_' . $this->getField()->getId()
73  );
74 
75  $input->setHeight(100);
76  $input->setHeightUnit('%; max-height: 150px');
77  $input->setWidth(100);
78  $input->setWidthUnit('%');
79 
80  $array = array();
81  foreach ($options as $opt) {
82  $array[$opt->getOptId()] = $opt->getValue();
83  }
84  $input->setOptions($array);
85  break;
87  $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
88  $array = array();
89  foreach ($options as $opt) {
90  $array[$opt->getOptId()] = $opt->getValue();
91  }
92  $input->setOptions(array("" => $this->lng->txt('dcl_please_select')) + $array);
93  break;
95  default:
96  $input = new ilRadioGroupInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
97  foreach ($options as $opt) {
98  $input->addOption(new ilRadioOption($opt->getValue(), $opt->getOptId()));
99  }
100  $input->setValue(array_keys($options)[0]);
101  break;
102  }
103  $this->setupInputField($input, $this->getField());
104 
105  return $input;
106  }
107 
112  public function addFilterInputFieldToTable(ilTable2GUI $table)
113  {
114  $input = $table->addFilterItemByMetaType(
115  "filter_" . $this->getField()->getId(),
117  false,
118  $this->getField()->getId()
119  );
120 
121  $options = ilDclSelectionOption::getAllForField($this->getField()->getId());
122  $array = array('' => $this->lng->txt('dcl_all_entries'));
123  foreach ($options as $opt) {
124  $array[$opt->getOptId()] = $opt->getValue();
125  }
126 
127  $array['none'] = $this->lng->txt('dcl_no_entry');
128 
129  $input->setOptions($array);
130 
131  $this->setupFilterInputField($input);
132 
133  return $this->getFilterInputFieldValue($input);
134  }
135 
136  abstract protected function buildOptionsInput(): ilDclGenericMultiInputGUI;
137 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildFieldCreationInput(ilObjDataCollection $dcl, string $mode='create')
getInputField(ilPropertyFormGUI $form, ?int $record_id=null)
Returns field-input.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...