ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTLocationFormBridge Class Reference
+ Inheritance diagram for ilADTLocationFormBridge:
+ Collaboration diagram for ilADTLocationFormBridge:

Public Member Functions

 addToForm ()
 
 importFromPost ()
 
- Public Member Functions inherited from ilADTFormBridge
 __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)
 
- Protected Member Functions inherited from ilADTFormBridge
 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...
 

Additional Inherited Members

- Protected Attributes inherited from ilADTFormBridge
ilADT $adt
 
ilPropertyFormGUI $form
 
 $parent
 
string $id = null
 
string $title = ''
 
string $info = ''
 
 $parent_element
 
bool $required = false
 
bool $disabled = false
 
ilLanguage $lng
 

Detailed Description

Definition at line 5 of file class.ilADTLocationFormBridge.php.

Member Function Documentation

◆ addToForm()

ilADTLocationFormBridge::addToForm ( )

Definition at line 12 of file class.ilADTLocationFormBridge.php.

References ilADTFormBridge\$adt, ilADTFormBridge\$title, ilADTFormBridge\addBasicFieldProperties(), ilADTFormBridge\addToParentElement(), ilADTFormBridge\getADT(), ilADT\getCopyOfDefinition(), ilMapUtil\getDefaultSettings(), ilADTFormBridge\getElementId(), ilADTFormBridge\getTitle(), ilADT\isNull(), ilADTFormBridge\isRequired(), and ILIAS\Repository\lng().

12  : void
13  {
14  $adt = $this->getADT();
15 
16  $default = false;
17  if ($adt->isNull()) {
18  // see ilPersonalProfileGUI::addLocationToForm()
19  // use installation default
21  $adt->setLatitude((float) $def["latitude"]);
22  $adt->setLongitude((float) $def["longitude"]);
23  $adt->setZoom((int) $def["zoom"]);
24 
25  $default = true;
26  }
27 
28  // :TODO: title?
29  $title = $this->isRequired()
30  ? $this->getTitle()
31  : $this->lng->txt("location");
32 
33  $loc = new ilLocationInputGUI($title, $this->getElementId());
34  $loc->setLongitude($adt->getLongitude());
35  $loc->setLatitude($adt->getLatitude());
36  $loc->setZoom($adt->getZoom());
37 
39 
40  if (!$this->isRequired()) {
41  $optional = new ilCheckboxInputGUI($this->getTitle(), $this->getElementId() . "_tgl");
42  $optional->addSubItem($loc);
43  $this->addToParentElement($optional);
44 
45  if (!$default && !$adt->isNull()) {
46  $optional->setChecked(true);
47  }
48  } else {
49  $this->addToParentElement($loc);
50  }
51  }
addToParentElement(ilFormPropertyGUI $a_field)
This class represents a checkbox property in a property form.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
static getDefaultSettings()
Get default longitude, latitude and zoom.
This class represents a location property in a property form.
isNull()
Is currently null.
getCopyOfDefinition()
Get copy of definition.
+ Here is the call graph for this function:

◆ importFromPost()

ilADTLocationFormBridge::importFromPost ( )

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

References ilADTFormBridge\getADT(), ilADTFormBridge\getElementId(), ilADTFormBridge\getForm(), and ilADTFormBridge\isRequired().

53  : void
54  {
55  $do_import = true;
56  if (!$this->isRequired()) {
57  $toggle = $this->getForm()->getInput($this->getElementId() . "_tgl");
58  if (!$toggle) {
59  $do_import = false;
60  }
61  }
62 
63  if ($do_import) {
64  // ilPropertyFormGUI::checkInput() is pre-requisite
65  $incoming = $this->getForm()->getInput($this->getElementId());
66  $this->getADT()->setLongitude((float) $incoming["longitude"]);
67  $this->getADT()->setLatitude((float) $incoming["latitude"]);
68  $this->getADT()->setZoom((int) $incoming["zoom"]);
69  } else {
70  $this->getADT()->setLongitude(null);
71  $this->getADT()->setLatitude(null);
72  $this->getADT()->setZoom(null);
73  }
74 
75  $field = $this->getForm()->getItemByPostVar($this->getElementId());
76  $field->setLongitude($this->getADT()->getLongitude());
77  $field->setLatitude($this->getADT()->getLatitude());
78  $field->setZoom($this->getADT()->getZoom());
79  }
+ Here is the call graph for this function:

◆ isValidADT()

ilADTLocationFormBridge::isValidADT ( ilADT  $a_adt)
protected

Definition at line 7 of file class.ilADTLocationFormBridge.php.

7  : bool
8  {
9  return ($a_adt instanceof ilADTLocation);
10  }

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