ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTMultiEnumFormBridge.php
Go to the documentation of this file.
1<?php
2
3require_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?>
ADT form bridge base class.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
getElementId()
Get element id.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
isValidADT(ilADT $a_adt)
Check if given ADT is valid.
importFromPost()
Import values from form request POST data.
isActiveForSubItems($a_parent_option=null)
Check if element is currently active for subitem(s)
addToForm()
Add ADT-specific fields to form.
ADT base class.
Definition: class.ilADT.php:12
This class represents a property in a property form.
This class represents an option in a checkbox group.
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options