ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $DIC;
28 
29  $lng = $DIC['lng'];
30 
31  $def = $this->getADT()->getCopyOfDefinition();
32 
33  $options = $def->getOptions();
34 
35  if ((bool) $this->auto_sort) {
36  asort($options);
37  }
38 
39  $cbox = new ilCheckboxGroupInputGUI($this->getTitle(), $this->getElementId());
40 
41  foreach ($options as $value => $caption) {
42  $option = new ilCheckboxOption($caption, $value);
43  if (is_array($this->option_infos) && array_key_exists($value, $this->option_infos)) {
44  $option->setInfo($this->option_infos[$value]);
45  }
46  $cbox->addOption($option);
47  }
48 
49  $this->addBasicFieldProperties($cbox, $def);
50 
51  $cbox->setValue($this->getADT()->getSelections());
52 
53  $this->addToParentElement($cbox);
54  }
55 
56  public function importFromPost()
57  {
58  // ilPropertyFormGUI::checkInput() is pre-requisite
59  $this->getADT()->setSelections($this->getForm()->getInput($this->getElementId()));
60 
61  $field = $this->getForm()->getItemByPostvar($this->getElementId());
62  $field->setValue($this->getADT()->getSelections());
63  }
64 
65  protected function isActiveForSubItems($a_parent_option = null)
66  {
67  $current = $this->getADT()->getSelections();
68  return (is_array($current) && in_array($a_parent_option, $current));
69  }
70 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents an option in a checkbox group.
global $DIC
Definition: saml.php:7
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()
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
$def
Definition: croninfo.php:21
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20