ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilADTGroupFormBridge Class Reference
+ Inheritance diagram for ilADTGroupFormBridge:
+ Collaboration diagram for ilADTGroupFormBridge:

Public Member Functions

 getElements ()
 
 getElement ($a_name)
 
 addToForm ()
 
 addJS (ilTemplate $a_tpl)
 
 importFromPost ()
 
 validate ()
 
- 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)
 
 prepareElements ()
 
- 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

 $elements
 
- Protected Attributes inherited from ilADTFormBridge
 $adt
 
 $form
 
 $id
 
 $title
 
 $info
 
 $parent_element
 
 $required
 
 $disabled
 

Detailed Description

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

Member Function Documentation

◆ addJS()

ilADTGroupFormBridge::addJS ( ilTemplate  $a_tpl)

Definition at line 71 of file class.ilADTGroupFormBridge.php.

References prepareElements().

72  {
73  $this->prepareElements();
74  foreach($this->elements as $element)
75  {
76  $element->addJS($a_tpl);
77  }
78  }
+ Here is the call graph for this function:

◆ addToForm()

ilADTGroupFormBridge::addToForm ( )

Definition at line 49 of file class.ilADTGroupFormBridge.php.

References $section, ilADTFormBridge\getForm(), ilADTFormBridge\getInfo(), ilADTFormBridge\getTitle(), and prepareElements().

50  {
51  if($this->getTitle())
52  {
54  $section->setTitle($this->getTitle());
55 
56  if($this->getInfo())
57  {
58  $section->setInfo($this->getInfo());
59  }
60 
61  $this->getForm()->addItem($section);
62  }
63 
64  $this->prepareElements();
65  foreach($this->elements as $element)
66  {
67  $element->addToForm();
68  }
69  }
This class represents a section header in a property form.
$section
Definition: Utf8Test.php:83
+ Here is the call graph for this function:

◆ getElement()

ilADTGroupFormBridge::getElement (   $a_name)

Definition at line 40 of file class.ilADTGroupFormBridge.php.

References prepareElements().

Referenced by ilADTTestGUI\prepareFormElements().

41  {
42  $this->prepareElements();
43  if(array_key_exists($a_name, $this->elements))
44  {
45  return $this->elements[$a_name];
46  }
47  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getElements()

ilADTGroupFormBridge::getElements ( )

Definition at line 34 of file class.ilADTGroupFormBridge.php.

References $elements, and prepareElements().

Referenced by prepareElements(), ilADTTestGUI\prepareFormElements(), and validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importFromPost()

ilADTGroupFormBridge::importFromPost ( )

Definition at line 80 of file class.ilADTGroupFormBridge.php.

References prepareElements().

81  {
82  $this->prepareElements();
83  foreach($this->elements as $element)
84  {
85  // parse parent element
86  $parent = $element->getParentElement();
87  if($parent)
88  {
89  if(is_array($parent))
90  {
91  $parent = $parent[0];
92  }
93  if(isset($adt_forms[$parent]))
94  {
95  $parent = $adt_forms[$parent];
96  }
97  else
98  {
99  $parent = null;
100  }
101  }
102  if($element->shouldBeImportedFromPost($parent))
103  {
104  $element->importFromPost();
105  }
106  }
107  }
+ Here is the call graph for this function:

◆ isValidADT()

ilADTGroupFormBridge::isValidADT ( ilADT  $a_adt)
protected

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

10  {
11  return ($a_adt instanceof ilADTGroup);
12  }

◆ prepareElements()

ilADTGroupFormBridge::prepareElements ( )
protected

Definition at line 14 of file class.ilADTGroupFormBridge.php.

References array, ilADTFormBridge\getADT(), getElements(), ilADTFormBridge\getForm(), and ilADTFactory\getInstance().

Referenced by addJS(), addToForm(), getElement(), getElements(), and importFromPost().

15  {
16  if(sizeof($this->elements))
17  {
18  return;
19  }
20 
21  $this->elements = array();
22  $factory = ilADTFactory::getInstance();
23 
24  // convert ADTs to form bridges
25 
26  foreach($this->getADT()->getElements() as $name => $element)
27  {
28  $this->elements[$name] = $factory->getFormBridgeForInstance($element);
29  $this->elements[$name]->setForm($this->getForm());
30  $this->elements[$name]->setElementId($name);
31  }
32  }
static getInstance()
Get singleton.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validate()

ilADTGroupFormBridge::validate ( )

Definition at line 109 of file class.ilADTGroupFormBridge.php.

References $errors, $lng, $valid, array, ilADTFormBridge\getADT(), getElements(), and ilADTFormBridge\getForm().

110  {
111  global $lng;
112 
113  $valid = true;
114 
115  // ilADTFormBridge->isRequired() != ilADT->allowNull()
116  foreach($this->getElements() as $element_id => $element)
117  {
118  if($element->isRequired() && $element->getADT()->isNull())
119  {
120  $field = $this->getForm()->getItemByPostvar($element_id);
121  $field->setAlert($lng->txt("msg_input_is_required"));
122  $valid = false;
123  }
124  // #17232 - date time input GUI special case
125  else if(!$element->validate())
126  {
127  $valid = false;
128  }
129  }
130 
131  if(!$this->getADT()->isValid())
132  {
133  $tmp = array();
134 
135  // map errors to elements
136 
137  $mess = $this->getADT()->getValidationErrorsByElements();
138  foreach($mess as $error_code => $element_id)
139  {
140  $tmp[$element_id][] = $this->getADT()->translateErrorCode($error_code);
141  }
142 
143  foreach($tmp as $element_id => $errors)
144  {
145  $field = $this->getForm()->getItemByPostvar($element_id);
146  $field->setAlert(implode("<br />", $errors));
147  }
148 
149  $valid = false;
150  }
151 
152  return $valid;
153  }
$valid
Create styles array
The data for the language used.
$errors
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

Field Documentation

◆ $elements

ilADTGroupFormBridge::$elements
protected

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

Referenced by getElements().


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