ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilADTMultiEnumFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 require_once "Services/ADT/classes/Bridges/class.ilADTFormBridge.php";
4 
6 {
7  protected $option_infos; // [array]
8  protected $auto_sort = true; // [bool]
9 
10  protected function isValidADT(ilADT $a_adt)
11  {
12  return ($a_adt instanceof ilADTMultiEnum);
13  }
14 
15  public function setOptionInfos(array $a_info = null)
16  {
17  $this->option_infos = $a_info;
18  }
19 
20  public function setAutoSort($a_value)
21  {
22  $this->auto_sort = (bool)$a_value;
23  }
24 
25  public function addToForm()
26  {
27  global $lng;
28 
29  $def = $this->getADT()->getCopyOfDefinition();
30 
31  $options = $def->getOptions();
32 
33  if((bool)$this->auto_sort)
34  {
35  asort($options);
36  }
37 
38  $cbox = new ilCheckboxGroupInputGUI($this->getTitle(), $this->getElementId());
39 
40  foreach($options as $value => $caption)
41  {
42  $option = new ilCheckboxOption($caption, $value);
43  if(is_array($this->option_infos) && array_key_exists($value, $this->option_infos))
44  {
45  $option->setInfo($this->option_infos[$value]);
46  }
47  $cbox->addOption($option);
48  }
49 
50  $this->addBasicFieldProperties($cbox, $def);
51 
52  $cbox->setValue($this->getADT()->getSelections());
53 
54  $this->addToParentElement($cbox);
55  }
56 
57  public function importFromPost()
58  {
59  // ilPropertyFormGUI::checkInput() is pre-requisite
60  $this->getADT()->setSelections($this->getForm()->getInput($this->getElementId()));
61 
62  $field = $this->getForm()->getItemByPostvar($this->getElementId());
63  $field->setValue($this->getADT()->getSelections());
64  }
65 
66  protected function isActiveForSubItems($a_parent_option = null)
67  {
68  $current = $this->getADT()->getSelections();
69  return (is_array($current) && in_array($a_parent_option, $current));
70  }
71 }
72 
73 ?>
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents an option in a checkbox group.
ADT form bridge base class.
isActiveForSubItems($a_parent_option=null)
ADT base class.
Definition: class.ilADT.php:11
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
if(!is_array($argv)) $options
This class represents a property in a property form.
Create styles array
The data for the language used.
getElementId()
Get element id.
global $lng
Definition: privfeed.php:17