ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTBasedObjectGUI Class Reference

ADT based-object GUI base class. More...

+ Inheritance diagram for ilADTBasedObjectGUI:
+ Collaboration diagram for ilADTBasedObjectGUI:

Public Member Functions

 __construct (ilObjectGUI $a_parent_gui)
 Constructor Parent GUI is just needed for testing (ilCtrl) More...
 
 editAction (ilADTGroupFormBridge $a_form=null)
 
 updateAction ()
 Parse incoming values and update if valid PhpParamsInspection. More...
 

Protected Member Functions

 initObject ()
 Init ADT-based object. More...
 
 prepareFormElements (ilADTGroupFormBridge $a_adt_form)
 Prepare/customize form elements. More...
 
 initForm ()
 Init ADT-based form. More...
 

Protected Attributes

ilADTBasedObject $object = null
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 

Private Attributes

ilObjectGUI $gui
 

Detailed Description

ADT based-object GUI 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 12 of file class.ilADTBasedObjectGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilADTBasedObjectGUI::__construct ( ilObjectGUI  $a_parent_gui)

Constructor Parent GUI is just needed for testing (ilCtrl)

Parameters
ilObjectGUI$a_parent_gui

Definition at line 26 of file class.ilADTBasedObjectGUI.php.

References $DIC, ILIAS\Repository\ctrl(), initObject(), and ILIAS\Repository\lng().

27  {
28  global $DIC;
29  $this->tpl = $DIC->ui()->mainTemplate();
30  $this->lng = $DIC->language();
31  $this->ctrl = $DIC->ctrl();
32 
33  $this->gui = $a_parent_gui;
34  $this->object = $this->initObject();
35  }
global $DIC
Definition: feed.php:28
initObject()
Init ADT-based object.
+ Here is the call graph for this function:

Member Function Documentation

◆ editAction()

ilADTBasedObjectGUI::editAction ( ilADTGroupFormBridge  $a_form = null)

Definition at line 47 of file class.ilADTBasedObjectGUI.php.

References initForm(), and prepareFormElements().

Referenced by updateAction().

47  : bool
48  {
49  if (!$a_form) {
50  $a_form = $this->initForm();
51  }
52 
53  $this->tpl->setContent($a_form->getForm()->getHTML());
54  return true;
55  }
initForm()
Init ADT-based form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilADTBasedObjectGUI::initForm ( )
protected

Init ADT-based form.

Returns
ilADTFormBridge $a_form

PhpParamsInspection

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

References ILIAS\Repository\ctrl(), ilADTFactory\getInstance(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and prepareFormElements().

Referenced by editAction(), and updateAction().

68  {
69  $form = new ilPropertyFormGUI();
70  $form->setFormAction($this->ctrl->getFormAction($this->gui, "updateAction"));
71 
72  $adt_form = ilADTFactory::getInstance()->getFormBridgeForInstance($this->object->getProperties());
73 
74  // has to be done BEFORE prepareFormElements() ...
75  $adt_form->setForm($form);
76 
78  $this->prepareFormElements($adt_form);
79 
80  $adt_form->addToForm();
81  $adt_form->addJS($this->tpl);
82 
83  // :TODO:
84  $form->addCommandButton("updateAction", $this->lng->txt("save"));
85 
86  return $adt_form;
87  }
ADT form bridge base class.
prepareFormElements(ilADTGroupFormBridge $a_adt_form)
Prepare/customize form elements.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initObject()

ilADTBasedObjectGUI::initObject ( )
abstractprotected

Init ADT-based object.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ prepareFormElements()

ilADTBasedObjectGUI::prepareFormElements ( ilADTGroupFormBridge  $a_adt_form)
abstractprotected

Prepare/customize form elements.

Parameters
ilADTGroupFormBridge$a_adt_form

Referenced by editAction(), and initForm().

+ Here is the caller graph for this function:

◆ updateAction()

ilADTBasedObjectGUI::updateAction ( )

Parse incoming values and update if valid PhpParamsInspection.

Definition at line 93 of file class.ilADTBasedObjectGUI.php.

References $valid, ILIAS\Repository\ctrl(), editAction(), initForm(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

93  : bool
94  {
95  $adt_form = $this->initForm();
96  $valid = $adt_form->getForm()->checkInput();
97 
98  $old_chksum = $this->object->getProperties()->getCheckSum();
99 
100  $adt_form->importFromPost();
101  $valid = $adt_form->validate();
102 
103  $changed = ($old_chksum != $this->object->getProperties()->getCheckSum());
104 
105  // validation errors have top priority
106  if (!$valid) {
107  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_input_not_valid"));
108  return $this->editAction($adt_form);
109  }
110 
111  // :TODO: experimental, update only if necessary
112  if ($changed) {
113  if ($this->object->update()) {
114  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
115  } else {
116  // error occured in db-layer (primary/unique)
117  foreach ($this->object->getDBErrors() as $element_id => $codes) {
118  $element = $adt_form->getElement($element_id);
119  if ($element) {
120  $element->setExternalErrors($this->object->translateDBErrorCodes($codes));
121  }
122  }
123 
124  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_input_not_valid"));
125  return $this->editAction($adt_form);
126  }
127  }
128 
129  $this->ctrl->redirect($this->gui, "edit");
130  return true;
131  }
$valid
editAction(ilADTGroupFormBridge $a_form=null)
initForm()
Init ADT-based form.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilADTBasedObjectGUI::$ctrl
protected

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

◆ $gui

ilObjectGUI ilADTBasedObjectGUI::$gui
private

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

◆ $lng

ilLanguage ilADTBasedObjectGUI::$lng
protected

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

◆ $object

ilADTBasedObject ilADTBasedObjectGUI::$object = null
protected

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

◆ $tpl

ilGlobalTemplateInterface ilADTBasedObjectGUI::$tpl
protected

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


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