ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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)
 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.
 addToForm ()
 Add ADT-specific fields to form.
 addJS (ilTemplate $a_tpl)
 Add ADT-specific JS-files to template.
 shouldBeImportedFromPost (ilADTFormBridge $a_parent_adt=null)
 Check if incoming values should be imported at all.
 importFromPost ()
 Import values from form request POST data.
 validate ()
 Validate ADT and parse error codes.
 setExternalErrors ($a_errors)

Protected Member Functions

 isValidADT (ilADT $a_adt)
 Check if given ADT is valid.
 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

 $adt
 $form
 $id
 $title
 $info
 $parent_element
 $required
 $disabled

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

Constructor & Destructor Documentation

ilADTFormBridge::__construct ( ilADT  $a_adt)

Constructor.

Parameters
ilADT$a_adt
Returns
self

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

References setADT().

{
$this->setADT($a_adt);
}

+ Here is the call graph for this function:

Member Function Documentation

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

Add ADT-specific JS-files to template.

Parameters
ilTemplate$a_tpl

Reimplemented in ilADTGroupFormBridge.

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

{
}
ilADTFormBridge::addToParentElement ( ilFormPropertyGUI  $a_field)
protected

Add form field to parent element.

Parameters
ilFormPropertyGUI$a_field

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

References findParentElementInForm(), and getForm().

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

{
$field = $this->findParentElementInForm();
if($field)
{
$field->addSubItem($a_field);
}
else if($this->getForm() instanceof ilPropertyFormGUI)
{
$this->getForm()->addItem($a_field);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilADTFormBridge::findParentElementInForm ( )
protected

Try to find parent element in form (could be option)

Returns
ilFormPropertyGUI

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

References getForm(), and getParentElement().

Referenced by addToParentElement().

{
$parent_def = $this->getParentElement();
if($parent_def)
{
if(is_array($parent_def))
{
$parent_option = $parent_def[1];
$parent_def = $parent_def[0];
}
// :TODO: throw exception on invalid definition ?!
$parent_field = $this->getForm()->getItemByPostVar($parent_def);
if($parent_field instanceof ilSubEnabledFormPropertyGUI)
{
// radio/checkbox group
if($parent_option && method_exists($parent_field, "getOptions"))
{
foreach($parent_field->getOptions() as $option)
{
if($option->getValue() == $parent_option)
{
$parent_field = $option;
break;
}
}
}
}
if($parent_field)
{
return $parent_field;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilADTFormBridge::getInfo ( )

Get info.

Returns
string

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

References $info.

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

{
return $this->info;
}

+ Here is the caller graph for this function:

ilADTFormBridge::getParentElement ( )

Get parent element.

Returns
string

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

Referenced by findParentElementInForm(), and shouldBeImportedFromPost().

{
return $this->parent;
}

+ Here is the caller graph for this function:

ilADTFormBridge::isActiveForSubItems (   $a_parent_option = null)
protected

Check if element is currently active for subitem(s)

Parameters
mixed$a_parent_option
Returns
bool

Reimplemented in ilADTEnumFormBridge, ilADTMultiEnumFormBridge, and ilADTBooleanFormBridge.

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

References getADT().

{
return !$this->getADT()->isNull();
}

+ Here is the call graph for this function:

ilADTFormBridge::isDisabled ( )

Get disabled.

Returns
bool

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

References $disabled.

Referenced by addBasicFieldProperties(), and shouldBeImportedFromPost().

{
}

+ Here is the caller graph for this function:

ilADTFormBridge::isValidADT ( ilADT  $a_adt)
abstractprotected

Check if given ADT is valid.

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

Parameters
ilADT$a_adt

Reimplemented in ilADTTextFormBridge, ilADTDateFormBridge, ilADTDateTimeFormBridge, ilADTEnumFormBridge, ilADTGroupFormBridge, ilADTMultiEnumFormBridge, ilADTBooleanFormBridge, ilADTFloatFormBridge, ilADTIntegerFormBridge, ilADTLocationFormBridge, and ilADTMultiTextFormBridge.

Referenced by setADT().

+ Here is the caller graph for this function:

ilADTFormBridge::setADT ( ilADT  $a_adt)
protected

Set ADT.

Exceptions
Exception
Parameters
ilADT$a_adt

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

References isValidADT().

Referenced by __construct().

{
if(!$this->isValidADT($a_adt))
{
throw new Exception('ADTFormBridge Type mismatch.');
}
$this->adt = $a_adt;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilADTFormBridge::setDisabled (   $a_value)

Set disabled.

Parameters
bool$a_value

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

{
$this->disabled = (bool)$a_value;
}
ilADTFormBridge::setElementId (   $a_value)

Set element id (aka form field)

Parameters
string$a_value

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

{
$this->id = (string)$a_value;
}
ilADTFormBridge::setExternalErrors (   $a_errors)

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

References getElementId(), and getForm().

{
$field = $this->getForm()->getItemByPostvar($this->getElementId());
$field->setAlert(implode("<br />", $a_errors));
}

+ Here is the call graph for this function:

ilADTFormBridge::setForm ( ilPropertyFormGUI  $a_form)

Set form.

Parameters
ilPropertyFormGUI$a_form

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

{
$this->form = $a_form;
}
ilADTFormBridge::setInfo (   $a_value)

Set info (aka form field info text)

Parameters
string$a_value

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

Referenced by ilADTTestGUI\prepareFormElements().

{
$this->info = trim($a_value);
}

+ Here is the caller graph for this function:

ilADTFormBridge::setParentElement (   $a_value)

Set parent element.

Parameters
string | array$a_value

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

{
if(!is_array($a_value))
{
$a_value = (string)$a_value;
}
$this->parent = $a_value;
}
ilADTFormBridge::setRequired (   $a_value)

Set required.

Parameters
bool$a_value

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

{
$this->required = (bool)$a_value;
}
ilADTFormBridge::setTitle (   $a_value)

Set title (aka form field caption)

Parameters
string$a_value

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

Referenced by ilADTTestGUI\prepareFormElements().

{
$this->title = trim($a_value);
}

+ Here is the caller graph for this function:

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

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

{
if($this->isDisabled())
{
return false;
}
// inactive parent elements disable importing
if($a_parent_adt)
{
$parent_option = null;
if(is_array($parent_element))
{
$parent_option = $parent_element[1];
}
return $a_parent_adt->isActiveForSubItems($parent_option);
}
return true;
}

+ Here is the call graph for this function:

ilADTFormBridge::validate ( )

Validate ADT and parse error codes.

Returns
boolean

Reimplemented in ilADTGroupFormBridge, ilADTDateFormBridge, ilADTDateTimeFormBridge, and ilADTBooleanFormBridge.

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

References $lng, getADT(), getElementId(), getForm(), and isRequired().

{
global $lng;
// ilADTFormBridge->isRequired() != ilADT->allowNull()
if($this->isRequired() && $this->getADT()->isNull())
{
$field = $this->getForm()->getItemByPostvar($this->getElementId());
$field->setAlert($lng->txt("msg_input_is_required"));
return false;
}
// no need to further validate if no value given
else if(!$this->getADT()->isValid())
{
$tmp = array();
$mess = $this->getADT()->getValidationErrors();
foreach($mess as $error_code)
{
$tmp[] = $this->getADT()->translateErrorCode($error_code);
}
$field = $this->getForm()->getItemByPostvar($this->getElementId());
$field->setAlert(implode("<br />", $tmp));
return false;
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilADTFormBridge::$adt
protected

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

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

ilADTFormBridge::$disabled
protected

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

Referenced by isDisabled().

ilADTFormBridge::$form
protected

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

Referenced by getForm().

ilADTFormBridge::$id
protected

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

Referenced by getElementId().

ilADTFormBridge::$info
protected

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

Referenced by addBasicFieldProperties(), and getInfo().

ilADTFormBridge::$parent_element
protected

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

Referenced by shouldBeImportedFromPost().

ilADTFormBridge::$required
protected

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

Referenced by isRequired().

ilADTFormBridge::$title
protected

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

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


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