ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 26 of file class.ilADTFormBridge.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTFormBridge::__construct ( ilADT  $a_adt)

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

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

44  {
45  global $DIC;
46 
47  $this->lng = $DIC->language();
48 
49  $this->setADT($a_adt);
50  }
global $DIC
Definition: shib_login.php:22
+ 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.

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

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

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)
+ 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 218 of file class.ilADTFormBridge.php.

218  : void
219  {
220  }

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

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

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

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 that may include a sub form.
+ 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.

References getForm(), getParentElement(), and null.

Referenced by addToParentElement().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getParentElement()
Get parent element.
This class represents a property that may include a sub form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADT()

ilADTFormBridge::getADT ( )

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

References $adt.

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

62  : ilADT
63  {
64  return $this->adt;
65  }
ADT base class.
Definition: class.ilADT.php:25
+ Here is the caller graph for this function:

◆ getElementId()

◆ getForm()

◆ getInfo()

ilADTFormBridge::getInfo ( )

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

References $info.

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

106  : string
107  {
108  return $this->info;
109  }
+ 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.

References $parent.

Referenced by findParentElementInForm(), and shouldBeImportedFromPost().

127  {
128  return $this->parent;
129  }
+ 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 227 of file class.ilADTFormBridge.php.

References getADT().

227  : bool
228  {
229  return !$this->getADT()->isNull();
230  }
+ Here is the call graph for this function:

◆ isDisabled()

ilADTFormBridge::isDisabled ( )

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

References $disabled.

Referenced by addBasicFieldProperties(), and shouldBeImportedFromPost().

136  : bool
137  {
138  return $this->disabled;
139  }
+ Here is the caller graph for this function:

◆ isRequired()

ilADTFormBridge::isRequired ( )

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

References $required.

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

146  : bool
147  {
148  return $this->required;
149  }
+ 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 54 of file class.ilADTFormBridge.php.

References isValidADT().

Referenced by __construct().

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

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

131  : void
132  {
133  $this->disabled = $a_value;
134  }
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ 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.

References getElementId(), and getForm().

281  : void
282  {
283  $field = $this->getForm()->getItemByPostVar($this->getElementId());
284  $field->setAlert(implode("<br />", $a_errors));
285  }
+ Here is the call graph for this function:

◆ setForm()

ilADTFormBridge::setForm ( ilPropertyFormGUI  $a_form)

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

References ILIAS\Repository\form().

67  : void
68  {
69  $this->form = $a_form;
70  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ setInfo()

ilADTFormBridge::setInfo ( string  $a_value)

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

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

Referenced by ilADTTestGUI\prepareFormElements().

101  : void
102  {
103  $this->info = trim($a_value);
104  }
info()
description: > Example for rendering a info message box.
Definition: info.php:34
+ 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.

Referenced by ilADTTestGUI\prepareFormElements().

91  : void
92  {
93  $this->title = trim($a_value);
94  }
+ 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.

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getParentElement()
Get parent element.
+ Here is the call graph for this function:

◆ validate()

ilADTFormBridge::validate ( )

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

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

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  }
+ 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 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: