ILIAS  release_8 Revision v8.24
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)

Reimplemented in ilADTExternalLinkFormBridge, and ilADTTextFormBridge.

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

30 {
31 global $DIC;
32
33 $this->lng = $DIC->language();
34
35 $this->setADT($a_adt);
36 }
global $DIC
Definition: feed.php:28

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

+ 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.

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)

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

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

+ 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

Reimplemented in ilADTGroupFormBridge.

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

204 : void
205 {
206 }

◆ addToForm()

◆ addToParentElement()

ilADTFormBridge::addToParentElement ( ilFormPropertyGUI  $a_field)
protected

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

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 class represents a property form user interface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References findParentElementInForm(), and getForm().

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

+ 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.

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.

References getForm(), and getParentElement().

Referenced by addToParentElement().

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

◆ getADT()

ilADTFormBridge::getADT ( )

◆ getElementId()

◆ getForm()

◆ getInfo()

ilADTFormBridge::getInfo ( )

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

92 : string
93 {
94 return $this->info;
95 }

References $info.

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

+ 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.

113 {
114 return $this->parent;
115 }

References $parent.

Referenced by findParentElementInForm(), and shouldBeImportedFromPost().

+ Here is the caller graph for this function:

◆ getTitle()

◆ importFromPost()

◆ 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

Reimplemented in ilADTBooleanFormBridge, ilADTEnumFormBridge, and ilADTMultiEnumFormBridge.

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

213 : bool
214 {
215 return !$this->getADT()->isNull();
216 }

References getADT().

+ Here is the call graph for this function:

◆ isDisabled()

ilADTFormBridge::isDisabled ( )

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

122 : bool
123 {
124 return $this->disabled;
125 }

References $disabled.

Referenced by addBasicFieldProperties(), and shouldBeImportedFromPost().

+ Here is the caller graph for this function:

◆ isRequired()

ilADTFormBridge::isRequired ( )

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

132 : bool
133 {
134 return $this->required;
135 }

References $required.

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

+ Here is the caller graph for this function:

◆ isValidADT()

◆ setADT()

ilADTFormBridge::setADT ( ilADT  $a_adt)
protected

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

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)

References isValidADT().

Referenced by __construct().

+ 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.

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

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

+ 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.

267 : void
268 {
269 $field = $this->getForm()->getItemByPostVar($this->getElementId());
270 $field->setAlert(implode("<br />", $a_errors));
271 }

References getElementId(), and getForm().

+ Here is the call graph for this function:

◆ setForm()

ilADTFormBridge::setForm ( ilPropertyFormGUI  $a_form)

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

53 : void
54 {
55 $this->form = $a_form;
56 }
form( $class_path, string $cmd)

References ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ setInfo()

ilADTFormBridge::setInfo ( string  $a_value)

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

87 : void
88 {
89 $this->info = trim($a_value);
90 }

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

Referenced by ilADTTestGUI\prepareFormElements().

+ 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.

77 : void
78 {
79 $this->title = trim($a_value);
80 }

Referenced by ilADTTestGUI\prepareFormElements().

+ 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.

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)

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

+ Here is the call graph for this function:

◆ validate()

ilADTFormBridge::validate ( )

Reimplemented in ilADTBooleanFormBridge, ilADTDateFormBridge, ilADTDateTimeFormBridge, and ilADTGroupFormBridge.

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

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 }

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

+ 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 addBasicFieldProperties(), and 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: