ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilADTEnumFormBridge Class Reference
+ Inheritance diagram for ilADTEnumFormBridge:
+ Collaboration diagram for ilADTEnumFormBridge:

Public Member Functions

 setAutoSort ($a_value)
 
 forceRadio ($a_value, array $a_info=null)
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 importFromPost ()
 Import values from form request POST data. More...
 
- Public Member Functions inherited from ilADTFormBridge
 __construct (ilADT $a_adt)
 Constructor. More...
 
 getADT ()
 Get ADT. More...
 
 setForm (ilPropertyFormGUI $a_form)
 Set form. More...
 
 getForm ()
 Get form. More...
 
 setElementId ($a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 Get element id. More...
 
 setTitle ($a_value)
 Set title (aka form field caption) More...
 
 getTitle ()
 Get title. More...
 
 setInfo ($a_value)
 Set info (aka form field info text) More...
 
 getInfo ()
 Get info. More...
 
 setParentElement ($a_value)
 Set parent element. More...
 
 getParentElement ()
 Get parent element. More...
 
 setDisabled ($a_value)
 Set disabled. More...
 
 isDisabled ()
 Get disabled. More...
 
 setRequired ($a_value)
 Set required. More...
 
 isRequired ()
 Get required. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addJS (ilTemplate $a_tpl)
 Add ADT-specific JS-files to template. More...
 
 shouldBeImportedFromPost (ilADTFormBridge $a_parent_adt=null)
 Check if incoming values should be imported at all. More...
 
 importFromPost ()
 Import values from form request POST data. More...
 
 validate ()
 Validate ADT and parse error codes. More...
 
 setExternalErrors ($a_errors)
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 
- Protected Member Functions inherited from ilADTFormBridge
 isValidADT (ilADT $a_adt)
 Check if given ADT is valid. More...
 
 setADT (ilADT $a_adt)
 Set ADT. More...
 
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo() More...
 
 findParentElementInForm ()
 Try to find parent element in form (could be option) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 

Protected Attributes

 $force_radio
 
 $option_infos
 
 $auto_sort = true
 
- Protected Attributes inherited from ilADTFormBridge
 $adt
 
 $form
 
 $id
 
 $title
 
 $info
 
 $parent_element
 
 $required
 
 $disabled
 

Detailed Description

Definition at line 5 of file class.ilADTEnumFormBridge.php.

Member Function Documentation

◆ addToForm()

ilADTEnumFormBridge::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTFormBridge.

Definition at line 30 of file class.ilADTEnumFormBridge.php.

31 {
32 global $lng;
33
34 $def = $this->getADT()->getCopyOfDefinition();
35 $selection = $this->getADT()->getSelection();
36
37 $options = $def->getOptions();
38
39 if((bool)$this->auto_sort)
40 {
41 asort($options);
42 }
43
44 if(!$this->isRequired())
45 {
46 $options = array("" => "-") + $options;
47 }
48 else if($this->getADT()->isNull())
49 {
50 $options = array("" => $lng->txt("please_select")) + $options;
51 }
52
53 if(!(bool)$this->force_radio)
54 {
55 $select = new ilSelectInputGUI($this->getTitle(), $this->getElementId());
56
57 $select->setOptions($options);
58 }
59 else
60 {
61 $select = new ilRadioGroupInputGUI($this->getTitle(), $this->getElementId());
62
63 foreach($options as $value => $caption)
64 {
65 $option = new ilRadioOption($caption, $value);
66 if(is_array($this->option_infos) && array_key_exists($value, $this->option_infos))
67 {
68 $option->setInfo($this->option_infos[$value]);
69 }
70 $select->addOption($option);
71 }
72 }
73
74 $this->addBasicFieldProperties($select, $def);
75
76 $select->setValue($selection);
77
78 $this->addToParentElement($select);
79 }
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.
isRequired()
Get required.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options

References $lng, $options, ilADTFormBridge\addBasicFieldProperties(), ilADTFormBridge\addToParentElement(), ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), ilADTFormBridge\getTitle(), and ilADTFormBridge\isRequired().

+ Here is the call graph for this function:

◆ forceRadio()

ilADTEnumFormBridge::forceRadio (   $a_value,
array  $a_info = null 
)

Definition at line 21 of file class.ilADTEnumFormBridge.php.

22 {
23 $this->force_radio = (bool)$a_value;
24 if($this->force_radio)
25 {
26 $this->option_infos = $a_info;
27 }
28 }

◆ importFromPost()

ilADTEnumFormBridge::importFromPost ( )

Import values from form request POST data.

Reimplemented from ilADTFormBridge.

Definition at line 81 of file class.ilADTEnumFormBridge.php.

82 {
83 // ilPropertyFormGUI::checkInput() is pre-requisite
84 $this->getADT()->setSelection($this->getForm()->getInput($this->getElementId()));
85
86 $field = $this->getForm()->getItemByPostvar($this->getElementId());
87 $field->setValue($this->getADT()->getSelection());
88 }

References ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), and ilADTFormBridge\getForm().

+ Here is the call graph for this function:

◆ isActiveForSubItems()

ilADTEnumFormBridge::isActiveForSubItems (   $a_parent_option = null)
protected

Check if element is currently active for subitem(s)

Parameters
mixed$a_parent_option
Returns
bool

Reimplemented from ilADTFormBridge.

Definition at line 90 of file class.ilADTEnumFormBridge.php.

91 {
92 return ($this->getADT()->getSelection() == $a_parent_option);
93 }

References ilADTFormBridge\getADT().

+ Here is the call graph for this function:

◆ isValidADT()

ilADTEnumFormBridge::isValidADT ( ilADT  $a_adt)
protected

Check if given ADT is valid.

:TODO: This could be avoided with type-specifc constructors :TODO: bridge base class?

Parameters
ilADT$a_adt

Reimplemented from ilADTFormBridge.

Definition at line 11 of file class.ilADTEnumFormBridge.php.

12 {
13 return ($a_adt instanceof ilADTEnum);
14 }

◆ setAutoSort()

ilADTEnumFormBridge::setAutoSort (   $a_value)

Definition at line 16 of file class.ilADTEnumFormBridge.php.

17 {
18 $this->auto_sort = (bool)$a_value;
19 }

Referenced by ilAdvancedMDFieldDefinitionSelect\prepareElementForEditor().

+ Here is the caller graph for this function:

Field Documentation

◆ $auto_sort

ilADTEnumFormBridge::$auto_sort = true
protected

Definition at line 9 of file class.ilADTEnumFormBridge.php.

◆ $force_radio

ilADTEnumFormBridge::$force_radio
protected

Definition at line 7 of file class.ilADTEnumFormBridge.php.

◆ $option_infos

ilADTEnumFormBridge::$option_infos
protected

Definition at line 8 of file class.ilADTEnumFormBridge.php.


The documentation for this class was generated from the following file: