ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTFormBridge Class Reference

ADT form bridge base class. More...

+ Inheritance diagram for ilADTFormBridge:
+ Collaboration diagram for ilADTFormBridge:

Public Member Functions

 __construct (ilADT $a_adt)
 
 getADT ()
 
 setForm (ilPropertyFormGUI $a_form)
 
 getForm ()
 
 setElementId (string $a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 setInfo (string $a_value)
 
 getInfo ()
 
 setParentElement ($a_value)
 
 getParentElement ()
 Get parent element. More...
 
 setDisabled (bool $a_value)
 
 isDisabled ()
 
 setRequired (bool $a_value)
 
 isRequired ()
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addJS (ilGlobalTemplateInterface $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 ()
 
 setExternalErrors (array $a_errors)
 

Protected Member Functions

 isValidADT (ilADT $a_adt)
 
 setADT (ilADT $a_adt)
 
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo() More...
 
 findParentElementInForm ()
 
 addToParentElement (ilFormPropertyGUI $a_field)
 
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s) More...
 

Protected Attributes

ilADT $adt
 
ilPropertyFormGUI $form
 
 $parent
 
string $id = null
 
string $title = ''
 
string $info = ''
 
 $parent_element
 
bool $required = false
 
bool $disabled = false
 
ilLanguage $lng
 

Detailed Description

ADT form bridge base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilADTFormBridge.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTFormBridge::__construct ( ilADT  $a_adt)

Definition at line 29 of file class.ilADTFormBridge.php.

References $DIC, isValidADT(), ILIAS\Repository\lng(), and setADT().

30  {
31  global $DIC;
32 
33  $this->lng = $DIC->language();
34 
35  $this->setADT($a_adt);
36  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addBasicFieldProperties()

ilADTFormBridge::addBasicFieldProperties ( ilFormPropertyGUI  $a_field,
ilADTDefinition  $a_def 
)
protected

Helper method to handle generic properties like setRequired(), setInfo()

Parameters
ilFormPropertyGUI$a_field
ilADTDefinition$a_def

Definition at line 142 of file class.ilADTFormBridge.php.

References getInfo(), isDisabled(), isRequired(), ilFormPropertyGUI\setDisabled(), ilFormPropertyGUI\setInfo(), and ilFormPropertyGUI\setRequired().

Referenced by ilADTTextFormBridge\addElementToForm(), ilADTLocationFormBridge\addToForm(), ilADTMultiTextFormBridge\addToForm(), ilADTBooleanFormBridge\addToForm(), ilADTDateFormBridge\addToForm(), ilADTMultiEnumFormBridge\addToForm(), ilADTInternalLinkFormBridge\addToForm(), ilADTIntegerFormBridge\addToForm(), ilADTFloatFormBridge\addToForm(), ilADTEnumFormBridge\addToForm(), ilADTDateTimeFormBridge\addToForm(), and ilADTExternalLinkFormBridge\addToForm().

142  : void
143  {
144  if ($this->isDisabled()) {
145  $a_field->setDisabled(true);
146  } elseif ($this->isRequired()) {
147  $a_field->setRequired(true);
148  }
149 
150  $info = $this->getInfo();
151  if ($info) {
152  $a_field->setInfo($info);
153  }
154  }
setRequired(bool $a_required)
setDisabled(bool $a_disabled)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addJS()

ilADTFormBridge::addJS ( ilGlobalTemplateInterface  $a_tpl)

Add ADT-specific JS-files to template.

Parameters
ilGlobalTemplate$a_tpl

Definition at line 204 of file class.ilADTFormBridge.php.

204  : void
205  {
206  }

◆ addToForm()

ilADTFormBridge::addToForm ( )
abstract

Add ADT-specific fields to form.

Referenced by addToParentElement().

+ Here is the caller graph for this function:

◆ addToParentElement()

ilADTFormBridge::addToParentElement ( ilFormPropertyGUI  $a_field)
protected

Definition at line 185 of file class.ilADTFormBridge.php.

References addToForm(), findParentElementInForm(), and getForm().

Referenced by ilADTTextFormBridge\addElementToForm(), ilADTLocationFormBridge\addToForm(), ilADTMultiTextFormBridge\addToForm(), ilADTBooleanFormBridge\addToForm(), ilADTDateFormBridge\addToForm(), ilADTMultiEnumFormBridge\addToForm(), ilADTInternalLinkFormBridge\addToForm(), ilADTIntegerFormBridge\addToForm(), ilADTFloatFormBridge\addToForm(), ilADTEnumFormBridge\addToForm(), ilADTDateTimeFormBridge\addToForm(), and ilADTExternalLinkFormBridge\addToForm().

185  : void
186  {
187  $field = $this->findParentElementInForm();
188  if ($field instanceof ilSubEnabledFormPropertyGUI) {
189  $field->addSubItem($a_field);
190  } elseif ($this->getForm() instanceof ilPropertyFormGUI) {
191  $this->getForm()->addItem($a_field);
192  }
193  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findParentElementInForm()

ilADTFormBridge::findParentElementInForm ( )
protected

Definition at line 156 of file class.ilADTFormBridge.php.

References getForm(), and getParentElement().

Referenced by addToParentElement().

157  {
158  $parent_def = $this->getParentElement();
159  $parent_option = '';
160  if ($parent_def) {
161  if (is_array($parent_def)) {
162  $parent_option = $parent_def[1];
163  $parent_def = $parent_def[0];
164  }
165  $parent_field = $this->getForm()->getItemByPostVar($parent_def);
166  if ($parent_field instanceof ilSubEnabledFormPropertyGUI) {
167  // radio/checkbox group
168  if ($parent_option && method_exists($parent_field, "getOptions")) {
169  foreach ($parent_field->getOptions() as $option) {
170  if ($option->getValue() == $parent_option) {
171  $parent_field = $option;
172  break;
173  }
174  }
175  }
176  }
177 
178  if ($parent_field) {
179  return $parent_field;
180  }
181  }
182  return null;
183  }
getParentElement()
Get parent element.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADT()

ilADTFormBridge::getADT ( )

Definition at line 48 of file class.ilADTFormBridge.php.

References $adt.

Referenced by ilADTTextFormBridge\addElementToForm(), ilADTBooleanFormBridge\addToForm(), ilADTLocationFormBridge\addToForm(), ilADTMultiTextFormBridge\addToForm(), ilADTDateFormBridge\addToForm(), ilADTLocalizedTextFormBridge\addToForm(), ilADTMultiEnumFormBridge\addToForm(), ilADTInternalLinkFormBridge\addToForm(), ilADTIntegerFormBridge\addToForm(), ilADTFloatFormBridge\addToForm(), ilADTEnumFormBridge\addToForm(), ilADTDateTimeFormBridge\addToForm(), ilADTExternalLinkFormBridge\addToForm(), ilADTTextFormBridge\addToForm(), ilADTBooleanFormBridge\importFromPost(), ilADTMultiTextFormBridge\importFromPost(), ilADTDateFormBridge\importFromPost(), ilADTDateTimeFormBridge\importFromPost(), ilADTInternalLinkFormBridge\importFromPost(), ilADTMultiEnumFormBridge\importFromPost(), ilADTLocationFormBridge\importFromPost(), ilADTIntegerFormBridge\importFromPost(), ilADTFloatFormBridge\importFromPost(), ilADTExternalLinkFormBridge\importFromPost(), ilADTLocalizedTextFormBridge\importFromPost(), ilADTEnumFormBridge\importFromPost(), ilADTTextFormBridge\importFromPost(), ilADTBooleanFormBridge\isActiveForSubItems(), ilADTMultiEnumFormBridge\isActiveForSubItems(), ilADTEnumFormBridge\isActiveForSubItems(), isActiveForSubItems(), ilADTGroupFormBridge\prepareElements(), ilADTGroupFormBridge\validate(), and validate().

48  : ilADT
49  {
50  return $this->adt;
51  }
ADT base class.
Definition: class.ilADT.php:11
+ Here is the caller graph for this function:

◆ getElementId()

◆ getForm()

◆ getInfo()

ilADTFormBridge::getInfo ( )

Definition at line 92 of file class.ilADTFormBridge.php.

References $info.

Referenced by addBasicFieldProperties(), and ilADTGroupFormBridge\addToForm().

92  : string
93  {
94  return $this->info;
95  }
+ Here is the caller graph for this function:

◆ getParentElement()

ilADTFormBridge::getParentElement ( )

Get parent element.

Returns
mixed

Definition at line 112 of file class.ilADTFormBridge.php.

References $parent.

Referenced by findParentElementInForm(), and shouldBeImportedFromPost().

113  {
114  return $this->parent;
115  }
+ Here is the caller graph for this function:

◆ getTitle()

◆ importFromPost()

ilADTFormBridge::importFromPost ( )
abstract

Import values from form request POST data.

Referenced by shouldBeImportedFromPost().

+ Here is the caller graph for this function:

◆ isActiveForSubItems()

ilADTFormBridge::isActiveForSubItems (   $a_parent_option = null)
protected

Check if element is currently active for subitem(s)

Parameters
mixed | null$a_parent_option
Returns
bool

Definition at line 213 of file class.ilADTFormBridge.php.

References getADT().

213  : bool
214  {
215  return !$this->getADT()->isNull();
216  }
+ Here is the call graph for this function:

◆ isDisabled()

ilADTFormBridge::isDisabled ( )

Definition at line 122 of file class.ilADTFormBridge.php.

References $disabled.

Referenced by addBasicFieldProperties(), and shouldBeImportedFromPost().

122  : bool
123  {
124  return $this->disabled;
125  }
+ Here is the caller graph for this function:

◆ isRequired()

ilADTFormBridge::isRequired ( )

Definition at line 132 of file class.ilADTFormBridge.php.

References $required.

Referenced by addBasicFieldProperties(), ilADTLocationFormBridge\addToForm(), ilADTEnumFormBridge\addToForm(), ilADTLocationFormBridge\importFromPost(), and validate().

132  : bool
133  {
134  return $this->required;
135  }
+ Here is the caller graph for this function:

◆ isValidADT()

ilADTFormBridge::isValidADT ( ilADT  $a_adt)
abstractprotected

Referenced by __construct(), and setADT().

+ Here is the caller graph for this function:

◆ setADT()

ilADTFormBridge::setADT ( ilADT  $a_adt)
protected

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

References isValidADT().

Referenced by __construct().

40  : void
41  {
42  if (!$this->isValidADT($a_adt)) {
43  throw new InvalidArgumentException('ADTFormBridge Type mismatch.');
44  }
45  $this->adt = $a_adt;
46  }
isValidADT(ilADT $a_adt)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDisabled()

ilADTFormBridge::setDisabled ( bool  $a_value)

Definition at line 117 of file class.ilADTFormBridge.php.

References ILIAS\UI\examples\Input\Field\Checkbox\disabled().

117  : void
118  {
119  $this->disabled = $a_value;
120  }
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:10
+ Here is the call graph for this function:

◆ setElementId()

ilADTFormBridge::setElementId ( string  $a_value)

Set element id (aka form field)

Parameters
string$a_value

Definition at line 67 of file class.ilADTFormBridge.php.

67  : void
68  {
69  $this->id = $a_value;
70  }

◆ setExternalErrors()

ilADTFormBridge::setExternalErrors ( array  $a_errors)

Definition at line 267 of file class.ilADTFormBridge.php.

References getElementId(), and getForm().

267  : void
268  {
269  $field = $this->getForm()->getItemByPostVar($this->getElementId());
270  $field->setAlert(implode("<br />", $a_errors));
271  }
+ Here is the call graph for this function:

◆ setForm()

ilADTFormBridge::setForm ( ilPropertyFormGUI  $a_form)

Definition at line 53 of file class.ilADTFormBridge.php.

References ILIAS\Repository\form().

53  : void
54  {
55  $this->form = $a_form;
56  }
form( $class_path, string $cmd)
+ Here is the call graph for this function:

◆ setInfo()

ilADTFormBridge::setInfo ( string  $a_value)

Definition at line 87 of file class.ilADTFormBridge.php.

References ILIAS\UI\examples\MessageBox\Info\info().

Referenced by ilADTTestGUI\prepareFormElements().

87  : void
88  {
89  $this->info = trim($a_value);
90  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParentElement()

ilADTFormBridge::setParentElement (   $a_value)
Parameters
mixed$a_value

Definition at line 100 of file class.ilADTFormBridge.php.

100  : void
101  {
102  if (!is_array($a_value)) {
103  $a_value = (string) $a_value;
104  }
105  $this->parent = $a_value;
106  }

◆ setRequired()

ilADTFormBridge::setRequired ( bool  $a_value)

Definition at line 127 of file class.ilADTFormBridge.php.

127  : void
128  {
129  $this->required = $a_value;
130  }

◆ setTitle()

ilADTFormBridge::setTitle ( string  $a_value)

Definition at line 77 of file class.ilADTFormBridge.php.

Referenced by ilADTTestGUI\prepareFormElements().

77  : void
78  {
79  $this->title = trim($a_value);
80  }
+ Here is the caller graph for this function:

◆ shouldBeImportedFromPost()

ilADTFormBridge::shouldBeImportedFromPost ( ilADTFormBridge  $a_parent_adt = null)

Check if incoming values should be imported at all.

Parameters
ilADTFormBridge$a_parent_adt
Returns
bool

Definition at line 223 of file class.ilADTFormBridge.php.

References $parent_element, getParentElement(), importFromPost(), and isDisabled().

223  : bool
224  {
225  if ($this->isDisabled()) {
226  return false;
227  }
228 
229  // inactive parent elements disable importing
230  if ($a_parent_adt) {
231  $parent_option = null;
233  if (is_array($parent_element)) {
234  $parent_option = $parent_element[1];
235  }
236  return $a_parent_adt->isActiveForSubItems($parent_option);
237  }
238  return true;
239  }
isActiveForSubItems($a_parent_option=null)
Check if element is currently active for subitem(s)
getParentElement()
Get parent element.
+ Here is the call graph for this function:

◆ validate()

ilADTFormBridge::validate ( )

Definition at line 246 of file class.ilADTFormBridge.php.

References getADT(), getElementId(), getForm(), isRequired(), and ILIAS\Repository\lng().

246  : bool
247  {
248  // ilADTFormBridge->isRequired() != ilADT->allowNull()
249  if ($this->isRequired() && $this->getADT()->isNull()) {
250  $field = $this->getForm()->getItemByPostVar($this->getElementId());
251  $field->setAlert($this->lng->txt("msg_input_is_required"));
252  return false;
253  } // no need to further validate if no value given
254  elseif (!$this->getADT()->isValid()) {
255  $tmp = [];
256  $mess = $this->getADT()->getValidationErrors();
257  foreach ($mess as $error_code) {
258  $tmp[] = $this->getADT()->translateErrorCode($error_code);
259  }
260  $field = $this->getForm()->getItemByPostVar($this->getElementId());
261  $field->setAlert(implode("<br />", $tmp));
262  return false;
263  }
264  return true;
265  }
+ Here is the call graph for this function:

Field Documentation

◆ $adt

ilADT ilADTFormBridge::$adt
protected

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

Referenced by ilADTLocationFormBridge\addToForm(), and getADT().

◆ $disabled

bool ilADTFormBridge::$disabled = false
protected

Definition at line 25 of file class.ilADTFormBridge.php.

Referenced by isDisabled().

◆ $form

ilPropertyFormGUI ilADTFormBridge::$form
protected

Definition at line 15 of file class.ilADTFormBridge.php.

Referenced by getForm().

◆ $id

string ilADTFormBridge::$id = null
protected

Definition at line 20 of file class.ilADTFormBridge.php.

Referenced by getElementId().

◆ $info

string ilADTFormBridge::$info = ''
protected

Definition at line 22 of file class.ilADTFormBridge.php.

Referenced by getInfo().

◆ $lng

ilLanguage ilADTFormBridge::$lng
protected

Definition at line 27 of file class.ilADTFormBridge.php.

◆ $parent

ilADTFormBridge::$parent
protected

◆ $parent_element

ilADTFormBridge::$parent_element
protected

Definition at line 23 of file class.ilADTFormBridge.php.

Referenced by shouldBeImportedFromPost().

◆ $required

bool ilADTFormBridge::$required = false
protected

Definition at line 24 of file class.ilADTFormBridge.php.

Referenced by isRequired().

◆ $title

string ilADTFormBridge::$title = ''
protected

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