ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilADTGroupFormBridge Class Reference
+ Inheritance diagram for ilADTGroupFormBridge:
+ Collaboration diagram for ilADTGroupFormBridge:

Public Member Functions

 getElements ()
 getElement ($a_name)
 addToForm ()
 Add ADT-specific fields to form.
 addJS (ilTemplate $a_tpl)
 Add ADT-specific JS-files to template.
 importFromPost ()
 Import values from form request POST data.
 validate ()
 Validate ADT and parse error codes.
- Public Member Functions inherited from ilADTFormBridge
 __construct (ilADT $a_adt)
 Constructor.
 getADT ()
 Get ADT.
 setForm (ilPropertyFormGUI $a_form)
 Set form.
 getForm ()
 Get form.
 setElementId ($a_value)
 Set element id (aka form field)
 getElementId ()
 Get element id.
 setTitle ($a_value)
 Set title (aka form field caption)
 getTitle ()
 Get title.
 setInfo ($a_value)
 Set info (aka form field info text)
 getInfo ()
 Get info.
 setParentElement ($a_value)
 Set parent element.
 getParentElement ()
 Get parent element.
 setDisabled ($a_value)
 Set disabled.
 isDisabled ()
 Get disabled.
 setRequired ($a_value)
 Set required.
 isRequired ()
 Get required.
 shouldBeImportedFromPost (ilADTFormBridge $a_parent_adt=null)
 Check if incoming values should be imported at all.
 setExternalErrors ($a_errors)

Protected Member Functions

 isValidADT (ilADT $a_adt)
 Check if given ADT is valid.
 prepareElements ()
- Protected Member Functions inherited from ilADTFormBridge
 setADT (ilADT $a_adt)
 Set ADT.
 addBasicFieldProperties (ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
 Helper method to handle generic properties like setRequired(), setInfo()
 findParentElementInForm ()
 Try to find parent element in form (could be option)
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element.
 isActiveForSubItems ($a_parent_option=null)
 Check if element is currently active for subitem(s)

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

ilADTGroupFormBridge::addJS ( ilTemplate  $a_tpl)

Add ADT-specific JS-files to template.

Parameters
ilTemplate$a_tpl

Reimplemented from ilADTFormBridge.

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

References prepareElements().

{
$this->prepareElements();
foreach($this->elements as $element)
{
$element->addJS($a_tpl);
}
}

+ Here is the call graph for this function:

ilADTGroupFormBridge::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTFormBridge.

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

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

{
if($this->getTitle())
{
$section->setTitle($this->getTitle());
if($this->getInfo())
{
$section->setInfo($this->getInfo());
}
$this->getForm()->addItem($section);
}
$this->prepareElements();
foreach($this->elements as $element)
{
$element->addToForm();
}
}

+ Here is the call graph for this function:

ilADTGroupFormBridge::getElement (   $a_name)

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

References prepareElements().

Referenced by ilADTTestGUI\prepareFormElements().

{
$this->prepareElements();
if(array_key_exists($a_name, $this->elements))
{
return $this->elements[$a_name];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilADTGroupFormBridge::getElements ( )

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

References $elements, and prepareElements().

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

{
$this->prepareElements();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilADTGroupFormBridge::importFromPost ( )

Import values from form request POST data.

Reimplemented from ilADTFormBridge.

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

References prepareElements().

{
$this->prepareElements();
foreach($this->elements as $element)
{
// parse parent element
$parent = $element->getParentElement();
if($parent)
{
if(is_array($parent))
{
$parent = $parent[0];
}
if(isset($adt_forms[$parent]))
{
$parent = $adt_forms[$parent];
}
else
{
$parent = null;
}
}
if($element->shouldBeImportedFromPost($parent))
{
$element->importFromPost();
}
}
}

+ Here is the call graph for this function:

ilADTGroupFormBridge::isValidADT ( ilADT  $a_adt)
protected

Check if given ADT is valid.

:TODO: This could be avoided with type-specifc constructors :TODO: bridge base class?

Parameters
ilADT$a_adt

Reimplemented from ilADTFormBridge.

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

{
return ($a_adt instanceof ilADTGroup);
}
ilADTGroupFormBridge::prepareElements ( )
protected

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

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

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

{
if(sizeof($this->elements))
{
return;
}
$this->elements = array();
// convert ADTs to form bridges
foreach($this->getADT()->getElements() as $name => $element)
{
$this->elements[$name] = $factory->getFormBridgeForInstance($element);
$this->elements[$name]->setForm($this->getForm());
$this->elements[$name]->setElementId($name);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilADTGroupFormBridge::validate ( )

Validate ADT and parse error codes.

Returns
boolean

Reimplemented from ilADTFormBridge.

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

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

{
global $lng;
$valid = true;
// ilADTFormBridge->isRequired() != ilADT->allowNull()
foreach($this->getElements() as $element_id => $element)
{
if($element->isRequired() && $element->getADT()->isNull())
{
$field = $this->getForm()->getItemByPostvar($element_id);
$field->setAlert($lng->txt("msg_input_is_required"));
$valid = false;
}
}
if(!$this->getADT()->isValid())
{
$tmp = array();
// map errors to elements
$mess = $this->getADT()->getValidationErrorsByElements();
foreach($mess as $error_code => $element_id)
{
$tmp[$element_id][] = $this->getADT()->translateErrorCode($error_code);
}
foreach($tmp as $element_id => $errors)
{
$field = $this->getForm()->getItemByPostvar($element_id);
$field->setAlert(implode("<br />", $errors));
}
$valid = false;
}
return $valid;
}

+ Here is the call graph for this function:

Field Documentation

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: