ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 26 of file class.ilADTFormBridge.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTFormBridge::__construct ( ilADT  $a_adt)

Reimplemented in ilADTExternalLinkFormBridge, and ilADTTextFormBridge.

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

44 {
45 global $DIC;
46
47 $this->lng = $DIC->language();
48
49 $this->setADT($a_adt);
50 }
global $DIC
Definition: shib_login.php:26

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 156 of file class.ilADTFormBridge.php.

156 : void
157 {
158 if ($this->isDisabled()) {
159 $a_field->setDisabled(true);
160 } elseif ($this->isRequired()) {
161 $a_field->setRequired(true);
162 }
163
164 $info = $this->getInfo();
165 if ($info) {
166 $a_field->setInfo($info);
167 }
168 }
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 218 of file class.ilADTFormBridge.php.

218 : void
219 {
220 }

◆ addToForm()

◆ addToParentElement()

ilADTFormBridge::addToParentElement ( ilFormPropertyGUI  $a_field)
protected

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

199 : void
200 {
201 $field = $this->findParentElementInForm();
202 if ($field instanceof ilSubEnabledFormPropertyGUI) {
203 $field->addSubItem($a_field);
204 } elseif ($this->getForm() instanceof ilPropertyFormGUI) {
205 $this->getForm()->addItem($a_field);
206 }
207 }
This class represents a property form user interface.
This class represents a property that may include a sub form.

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 170 of file class.ilADTFormBridge.php.

171 {
172 $parent_def = $this->getParentElement();
173 $parent_option = '';
174 if ($parent_def) {
175 if (is_array($parent_def)) {
176 $parent_option = $parent_def[1];
177 $parent_def = $parent_def[0];
178 }
179 $parent_field = $this->getForm()->getItemByPostVar($parent_def);
180 if ($parent_field instanceof ilSubEnabledFormPropertyGUI) {
181 // radio/checkbox group
182 if ($parent_option && method_exists($parent_field, "getOptions")) {
183 foreach ($parent_field->getOptions() as $option) {
184 if ($option->getValue() == $parent_option) {
185 $parent_field = $option;
186 break;
187 }
188 }
189 }
190 }
191
192 if ($parent_field) {
193 return $parent_field;
194 }
195 }
196 return null;
197 }
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 106 of file class.ilADTFormBridge.php.

106 : string
107 {
108 return $this->info;
109 }

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 126 of file class.ilADTFormBridge.php.

127 {
128 return $this->parent;
129 }

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 227 of file class.ilADTFormBridge.php.

227 : bool
228 {
229 return !$this->getADT()->isNull();
230 }

References getADT().

+ Here is the call graph for this function:

◆ isDisabled()

ilADTFormBridge::isDisabled ( )

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

136 : bool
137 {
138 return $this->disabled;
139 }

References $disabled.

Referenced by addBasicFieldProperties(), and shouldBeImportedFromPost().

+ Here is the caller graph for this function:

◆ isRequired()

ilADTFormBridge::isRequired ( )

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

146 : bool
147 {
148 return $this->required;
149 }

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 54 of file class.ilADTFormBridge.php.

54 : void
55 {
56 if (!$this->isValidADT($a_adt)) {
57 throw new InvalidArgumentException('ADTFormBridge Type mismatch.');
58 }
59 $this->adt = $a_adt;
60 }
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 131 of file class.ilADTFormBridge.php.

131 : void
132 {
133 $this->disabled = $a_value;
134 }

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 81 of file class.ilADTFormBridge.php.

81 : void
82 {
83 $this->id = $a_value;
84 }

◆ setExternalErrors()

ilADTFormBridge::setExternalErrors ( array  $a_errors)

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

281 : void
282 {
283 $field = $this->getForm()->getItemByPostVar($this->getElementId());
284 $field->setAlert(implode("<br />", $a_errors));
285 }

References getElementId(), and getForm().

+ Here is the call graph for this function:

◆ setForm()

ilADTFormBridge::setForm ( ilPropertyFormGUI  $a_form)

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

67 : void
68 {
69 $this->form = $a_form;
70 }
form( $class_path, string $cmd, string $submit_caption="")

References ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ setInfo()

ilADTFormBridge::setInfo ( string  $a_value)

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

101 : void
102 {
103 $this->info = trim($a_value);
104 }

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 114 of file class.ilADTFormBridge.php.

114 : void
115 {
116 if (!is_array($a_value)) {
117 $a_value = (string) $a_value;
118 }
119 $this->parent = $a_value;
120 }

◆ setRequired()

ilADTFormBridge::setRequired ( bool  $a_value)

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

141 : void
142 {
143 $this->required = $a_value;
144 }

◆ setTitle()

ilADTFormBridge::setTitle ( string  $a_value)

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

91 : void
92 {
93 $this->title = trim($a_value);
94 }

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 237 of file class.ilADTFormBridge.php.

237 : bool
238 {
239 if ($this->isDisabled()) {
240 return false;
241 }
242
243 // inactive parent elements disable importing
244 if ($a_parent_adt) {
245 $parent_option = null;
247 if (is_array($parent_element)) {
248 $parent_option = $parent_element[1];
249 }
250 return $a_parent_adt->isActiveForSubItems($parent_option);
251 }
252 return true;
253 }

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 260 of file class.ilADTFormBridge.php.

260 : bool
261 {
262 // ilADTFormBridge->isRequired() != ilADT->allowNull()
263 if ($this->isRequired() && $this->getADT()->isNull()) {
264 $field = $this->getForm()->getItemByPostVar($this->getElementId());
265 $field->setAlert($this->lng->txt("msg_input_is_required"));
266 return false;
267 } // no need to further validate if no value given
268 elseif (!$this->getADT()->isValid()) {
269 $tmp = [];
270 $mess = $this->getADT()->getValidationErrors();
271 foreach ($mess as $error_code) {
272 $tmp[] = $this->getADT()->translateErrorCode($error_code);
273 }
274 $field = $this->getForm()->getItemByPostVar($this->getElementId());
275 $field->setAlert(implode("<br />", $tmp));
276 return false;
277 }
278 return true;
279 }

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 28 of file class.ilADTFormBridge.php.

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

◆ $disabled

bool ilADTFormBridge::$disabled = false
protected

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

Referenced by isDisabled().

◆ $form

ilPropertyFormGUI ilADTFormBridge::$form
protected

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

Referenced by getForm().

◆ $id

string ilADTFormBridge::$id = null
protected

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

Referenced by getElementId().

◆ $info

string ilADTFormBridge::$info = ''
protected

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

Referenced by addBasicFieldProperties(), and getInfo().

◆ $lng

ilLanguage ilADTFormBridge::$lng
protected

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

◆ $parent

ilADTFormBridge::$parent
protected

◆ $parent_element

ilADTFormBridge::$parent_element
protected

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

Referenced by shouldBeImportedFromPost().

◆ $required

bool ilADTFormBridge::$required = false
protected

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

Referenced by isRequired().

◆ $title

string ilADTFormBridge::$title = ''
protected

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