ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDclSelectionFieldRepresentation.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 {
11 
12  // those should be overwritten by subclasses
13  const PROP_SELECTION_TYPE = '';
15 
16 
23  protected function buildFieldCreationInput(ilObjDataCollection $dcl, $mode = 'create')
24  {
25  $opt = parent::buildFieldCreationInput($dcl, $mode);
26 
27  $selection_options = $this->buildOptionsInput();
28  $opt->addSubItem($selection_options);
29 
30  $selection_type = new ilRadioGroupInputGUI($this->lng->txt('dcl_selection_type'), 'prop_' . static::PROP_SELECTION_TYPE);
31  $selection_type->setRequired(true);
32 
33  $option_1 = new ilRadioOption(
34  $this->lng->txt('dcl_' . ilDclSelectionFieldModel::SELECTION_TYPE_SINGLE),
36  );
37  $selection_type->addOption($option_1);
38 
39  $option_2 = new ilRadioOption(
40  $this->lng->txt('dcl_' . ilDclSelectionFieldModel::SELECTION_TYPE_MULTI),
42  );
43  $selection_type->addOption($option_2);
44 
45  $option_3 = new ilRadioOption(
46  $this->lng->txt('dcl_' . ilDclSelectionFieldModel::SELECTION_TYPE_COMBOBOX),
48  );
49  $selection_type->addOption($option_3);
50 
51  $opt->addSubItem($selection_type);
52 
53  return $opt;
54  }
55 
56 
63  public function getInputField(ilPropertyFormGUI $form, $record_id = 0)
64  {
66  $options = ilDclSelectionOption::getAllForField($this->getField()->getId());
67  switch ($this->getField()->getProperty(static::PROP_SELECTION_TYPE)) {
69  // global $DIC;
70  // $DIC->ui()->mainTemplate()->addOnLoadCode('$("#field_' . $this->getField()->getId() . '").removeClass("input")');
71  $input = new ilMultiSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
72 
73  $input->setHeight(100);
74  $input->setHeightUnit('%; max-height: 150px');
75  $input->setWidth(100);
76  $input->setWidthUnit('%');
77 
78  $array = array();
79  foreach ($options as $opt) {
80  $array[$opt->getOptId()] = $opt->getValue();
81  }
82  $input->setOptions($array);
83  break;
85  $input = new ilSelectInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
86  $array = array();
87  foreach ($options as $opt) {
88  $array[$opt->getOptId()] = $opt->getValue();
89  }
90  $input->setOptions(array("" => $this->lng->txt('dcl_please_select')) + $array);
91  break;
93  default:
94  $input = new ilRadioGroupInputGUI($this->getField()->getTitle(), 'field_' . $this->getField()->getId());
95  foreach ($options as $opt) {
96  $input->addOption(new ilRadioOption($opt->getValue(), $opt->getOptId()));
97  }
98  $input->setValue(array_keys($options)[0]);
99  break;
100  }
101  $this->setupInputField($input, $this->getField());
102 
103  return $input;
104  }
105 
106 
112  public function addFilterInputFieldToTable(ilTable2GUI $table)
113  {
114  $input = $table->addFilterItemByMetaType("filter_" . $this->getField()->getId(), ilTable2GUI::FILTER_SELECT, false, $this->getField()->getId());
115 
116  $options = ilDclSelectionOption::getAllForField($this->getField()->getId());
117  $array = array('' => $this->lng->txt('dcl_all_entries'));
118  foreach ($options as $opt) {
119  $array[$opt->getOptId()] = $opt->getValue();
120  }
121 
122  $array['none'] = $this->lng->txt('dcl_no_entry');
123 
124  $input->setOptions($array);
125 
126  $this->setupFilterInputField($input);
127 
128  return $this->getFilterInputFieldValue($input);
129  }
130 
131 
135  abstract protected function buildOptionsInput();
136 }
This class represents an option in a radio group.
This class represents a property form user interface.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
buildFieldCreationInput(ilObjDataCollection $dcl, $mode='create')
Class ilDclSelectionFieldRepresentation.
setupInputField(ilFormPropertyGUI $input, ilDclBaseFieldModel $field)
Sets basic settings on field-input.
This class represents a multi selection list property in a property form.
This class represents a property in a property form.
addSubItem($a_item)
Add Subitem.
setupFilterInputField(ilFormPropertyGUI $input)
Set basic settings for filter-input-gui.
getInputField(ilPropertyFormGUI $form, $record_id=0)
Returns field-input.
Class ilDclBaseFieldRepresentation.
Class ilObjDataCollection.
setRequired($a_required)
Set Required.